Add possibility to override execution command at runtime (#3722)

* Add possibility to override execution command at runtime

The entrypoint script initialize container data at runtime.
CMD defines the default executable and can be overridden at runtime.

* Set execution permission to entrypoint script

Necessary to prevent run errors, for example in windows env
This commit is contained in:
Gabriele Besta 2020-06-13 13:20:41 +02:00 committed by GitHub
parent 4b845f923e
commit e0a6b7d348
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -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"]

View File

@ -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 "$@"