diff --git a/docker/Dockerfile b/docker/Dockerfile index 48d199c22..0d32f05cb 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,12 +3,12 @@ FROM node:12-alpine as base WORKDIR /app RUN apk add --no-cache tzdata eudev -COPY package.json . +COPY package.json ./ # Dependencies FROM base as dependencies -COPY npm-shrinkwrap.json . +COPY npm-shrinkwrap.json ./ RUN apk add --no-cache --virtual .buildtools make gcc g++ python linux-headers git && \ npm ci --production && \ @@ -19,12 +19,15 @@ FROM base as release COPY --from=dependencies /app/node_modules ./node_modules COPY lib ./lib -COPY index.js docker/run.sh data/configuration.yaml ./ +COPY index.js data/configuration.yaml ./ + +COPY docker/docker-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-entrypoint.sh -RUN chmod +x /app/run.sh RUN mkdir /app/data ARG COMMIT RUN echo "{\"hash\": \"$COMMIT\"}" > .hash.json -ENTRYPOINT ["./run.sh"] +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["npm", "start"] diff --git a/docker/run.sh b/docker/docker-entrypoint.sh similarity index 94% rename from docker/run.sh rename to docker/docker-entrypoint.sh index d628827e3..4f1c4fa37 100644 --- a/docker/run.sh +++ b/docker/docker-entrypoint.sh @@ -1,4 +1,5 @@ #!/bin/sh +set -e if [ ! -z "$ZIGBEE2MQTT_DATA" ]; then DATA="$ZIGBEE2MQTT_DATA" @@ -13,4 +14,4 @@ if [ ! -f "$DATA/configuration.yaml" ]; then cp /app/configuration.yaml "$DATA/configuration.yaml" fi -exec npm start +exec "$@"