From 77fc851236e398d69048ebe1f8748823e712c5cf Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Sat, 11 Jan 2020 14:11:27 +0000 Subject: [PATCH] Update Docker to Node 12 and use multistage builds to reduce image size (#2703) --- docker/Dockerfile | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 2fc9c7bf5..0495730e6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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"]