From 8f3d3d62df16f3b5cdaaee4fce4c81f7e1798cba Mon Sep 17 00:00:00 2001 From: Travis Shivers Date: Sun, 23 Aug 2020 20:26:06 -0500 Subject: [PATCH] build(docker): build production deps in target platform --- Dockerfile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 03db29b5..eb378dc3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,14 @@ ARG REVISION RUN npm run build -RUN npm prune --production +# dependency environment +FROM node:current-alpine as dependency-stage +RUN mkdir /app && chown -R node:node /app +WORKDIR /app +RUN apk add --no-cache python make g++ +USER node +COPY --chown=node:node package*.json ./ +RUN npm ci --only=production # production environment FROM node:current-alpine as production-stage @@ -28,8 +35,8 @@ RUN mkdir /app && chown -R node:node /app WORKDIR /app COPY --chown=node:node server.js . COPY --chown=node:node config config +COPY --chown=node:node --from=dependency-stage /app/node_modules node_modules COPY --chown=node:node --from=build-stage /app/dist dist -COPY --chown=node:node --from=build-stage /app/node_modules node_modules ARG VERSION LABEL org.opencontainers.image.version=$VERSION