From 1725b2a3aa0bec1048b405ffe1653267c8e77a19 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 10 Aug 2022 13:26:02 +0200 Subject: [PATCH] create-app: update Dockerfile to set NODE_ENV=production Signed-off-by: Patrik Oldsberg --- docs/deployment/docker.md | 6 ++++++ packages/backend/Dockerfile | 3 +++ .../templates/default-app/packages/backend/Dockerfile | 3 +++ 3 files changed, 12 insertions(+) diff --git a/docs/deployment/docker.md b/docs/deployment/docker.md index ff31a6a81f..d46aff1b06 100644 --- a/docs/deployment/docker.md +++ b/docs/deployment/docker.md @@ -69,6 +69,9 @@ RUN apt-get update && \ USER node WORKDIR /app +# This switches many Node.js dependencies to production mode. +ENV NODE_ENV production + # Copy repo skeleton first, to avoid unnecessary docker cache invalidation. # The skeleton contains the package.json of each package in the monorepo, # and along with yarn.lock and the root package.json, that's enough to run yarn install. @@ -190,6 +193,9 @@ RUN apt-get update && \ USER node WORKDIR /app +# This switches many Node.js dependencies to production mode. +ENV NODE_ENV production + # Copy the install dependencies from the build stage and context COPY --from=build --chown=node:node /app/yarn.lock /app/package.json /app/packages/backend/dist/skeleton.tar.gz ./ RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz diff --git a/packages/backend/Dockerfile b/packages/backend/Dockerfile index bda34fa045..ed18da530b 100644 --- a/packages/backend/Dockerfile +++ b/packages/backend/Dockerfile @@ -22,6 +22,9 @@ RUN apt-get update && \ USER node WORKDIR /app +# This switches many Node.js dependencies to production mode. +ENV NODE_ENV production + # Copy repo skeleton first, to avoid unnecessary docker cache invalidation. # The skeleton contains the package.json of each package in the monorepo, # and along with yarn.lock and the root package.json, that's enough to run yarn install. diff --git a/packages/create-app/templates/default-app/packages/backend/Dockerfile b/packages/create-app/templates/default-app/packages/backend/Dockerfile index c926ba350b..682798b826 100644 --- a/packages/create-app/templates/default-app/packages/backend/Dockerfile +++ b/packages/create-app/templates/default-app/packages/backend/Dockerfile @@ -22,6 +22,9 @@ RUN apt-get update && \ USER node WORKDIR /app +# This switches many Node.js dependencies to production mode. +ENV NODE_ENV production + # Copy repo skeleton first, to avoid unnecessary docker cache invalidation. # The skeleton contains the package.json of each package in the monorepo, # and along with yarn.lock and the root package.json, that's enough to run yarn install.