Skip to content

Commit

Permalink
fix: Docker multi platform build
Browse files Browse the repository at this point in the history
  • Loading branch information
svrooij committed Oct 22, 2020
1 parent e0c7442 commit 97abb53
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
13 changes: 8 additions & 5 deletions .build/node-prune.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/bin/sh

# This script will run node-prune only on linux/amd64 because it isn't supported on other platforms.
if [$PLATFORM == "linux/amd64"]
if [$TARGETPLATFORM == "linux/amd64"]
then
curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | sh -s -- -b /usr/local/bin
npm prune --production
/usr/local/bin/node-prune
apk add --no-cache curl
curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | sh -s -- -b /usr/local/bin
npm prune --production
/usr/local/bin/node-prune
else
npm prune --production
npm prune --production
fi
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
FROM node:current-alpine as deps
WORKDIR /usr/src/app
COPY package*.json ./.build/node-prune.sh ./
RUN apk add --no-cache curl && \
npm ci --only=production && \
RUN npm ci --only=production && \
chmod +x node-prune.sh && \
./node-prune.sh

Expand Down
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,47 @@ Will set the temperature to 20º for 48 minutes.

An empty message to `evohome/set/thermostat/livingroom` will revert the `livingroom` back to the schedule.

## Use [PM2](http://pm2.keymetrics.io) to run in background
## Run in Docker

You can run this app in docker. We provide an image for `linux/amd64` `linux/arm/v7` and `linux/arm64`.
Everything is configurable with environment variables, docker compose sample:

```yaml
version: "3.7"
services:
evohome:
image: svrooij/evohome2mqtt
restart: unless-stopped # This makes sure that on a crash it will automatically be restarted.
environment:
- EVOHOME2MQTT_USER=your_user_name # Replace with your username for the evohome system
- EVOHOME2MQTT_PASSWORD=complicated_password_I_hope # Replace with your password for the evohome system
- EVOHOME2MQTT_MQTT=mqtt://emqx:1883 # EMQX is a nice mqtt broker
depends_on:
- emqx
# Optional MQTT server (I like emqx over mosquitto)
emqx:
image: emqx/emqx
restart: unless-stopped
ports:
- "1883:1883"
- "18083:18083"
```
Off course you can also start it wil the following oneline.
```sh
# Start in current process CTRL+C quits the app
docker run -e "EVOHOME2MQTT_USER=your_user_name" -e "EVOHOME2MQTT_PASSWORD=complicated_password" -e "EVOHOME2MQTT_MQTT=mqtt://emqx:1883" -n evohome svrooij/evohome2mqtt

# Start in background
docker run -d -e "EVOHOME2MQTT_USER=your_user_name" -e "EVOHOME2MQTT_PASSWORD=complicated_password" -e "EVOHOME2MQTT_MQTT=mqtt://emqx:1883" -n evohome svrooij/evohome2mqtt
# Follow logs from running in background
docker logs -f evohome
```

### Use PM2 to run in background (deprecated)

In the past running this app with PM2 was recommended, currently (Oct 2020) I would suggest to use docker.

If everything works as expected, you should make the app run in the background automatically. Personally I use PM2 for this. And they have a great [guide for this](http://pm2.keymetrics.io/docs/usage/quick-start/).

Expand Down

0 comments on commit 97abb53

Please sign in to comment.