Update Docker to Node 12 and use multistage builds to reduce image size (#2703)

This commit is contained in:
Daniel Chesterton 2020-01-11 14:11:27 +00:00 committed by Koen Kanters
parent e76633519f
commit 77fc851236

View File

@ -1,21 +1,30 @@
FROM node:10-alpine
FROM node:12-alpine as base
# Copy files
ADD . /app
RUN cp /app/data/configuration.yaml /app
RUN cp /app/docker/run.sh /app
RUN chmod +x /app/run.sh
WORKDIR /app
RUN apk add --no-cache tzdata eudev
COPY package.json .
# Dependencies
FROM base as dependencies
COPY npm-shrinkwrap.json .
RUN apk add --no-cache --virtual .buildtools make gcc g++ python linux-headers git && \
npm install --production && \
apk del .buildtools
# Release
FROM base as release
COPY --from=dependencies /app/node_modules ./node_modules
COPY lib ./lib
COPY index.js docker/run.sh data/configuration.yaml ./
RUN chmod +x /app/run.sh
RUN mkdir /app/data
# Write .hash.json
ARG COMMIT
RUN echo "{\"hash\": \"$COMMIT\"}" > .hash.json
# Install dependencies
RUN apk add --update --no-cache tzdata udev eudev && \
apk add --update --no-cache --virtual .buildtools make gcc g++ python linux-headers udev git && \
npm install --unsafe-perm --production && \
apk del .buildtools
# Entrypoint
ENTRYPOINT ["./run.sh"]