From 53d830512410965e4240806df1cab4ab24177cda Mon Sep 17 00:00:00 2001 From: nwittstruck Date: Sun, 7 Jan 2024 14:35:55 +0100 Subject: [PATCH 1/3] chore: add production build step --- .github/workflows/release.yml | 1 + Dockerfile | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ad5c50..e1b2c7b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,7 @@ on: push: branches: - main + - 7-chore-clean-up-dockerfile env: REGISTRY: ghcr.io diff --git a/Dockerfile b/Dockerfile index 7a87451..0418db2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,31 @@ FROM node:20-bullseye-slim as base -RUN apt-get update && apt-get install -y make g++ python3 -RUN ln -sf /usr/bin/python3 /usr/bin/python +FROM base as production_buildstage -RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app WORKDIR /home/node/app +COPY package.json package-lock.json ./ + +RUN npm ci + +COPY --chown=node:node . ./ +RUN npm run build FROM base as production -COPY package*.json ./ + +ENV NODE_ENV=production USER node +WORKDIR /home/node/app + +COPY package.json package-lock.json ./ RUN npm ci -COPY --chown=node:node . ./ -RUN npm run build +COPY --from=production_buildstage /home/node/app/dist /home/node/app/dist -EXPOSE 8080 +USER node ENTRYPOINT ["npm", "run", "start:prod"] FROM base as development -USER node + +WORKDIR /home/node/app From 6b781ac6f125b8bd66f321d92e523dca9840ca3c Mon Sep 17 00:00:00 2001 From: nwittstruck Date: Sun, 7 Jan 2024 14:58:51 +0100 Subject: [PATCH 2/3] chore: add production build step: remove github action build steps for branch --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e1b2c7b..5ad5c50 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,6 @@ on: push: branches: - main - - 7-chore-clean-up-dockerfile env: REGISTRY: ghcr.io From 9f9c69edb195a5ccd408c7f210d4219a9a2e2b87 Mon Sep 17 00:00:00 2001 From: nwittstruck Date: Sun, 7 Jan 2024 14:59:26 +0100 Subject: [PATCH 3/3] chore: add production build step: USER node was already set --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0418db2..0a3511c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,6 @@ RUN npm ci COPY --from=production_buildstage /home/node/app/dist /home/node/app/dist -USER node - ENTRYPOINT ["npm", "run", "start:prod"] FROM base as development