build(Docker): improve image size, by deleting unnecessary node_modules fodler from dist folder

added a TODO as well, to get rid of this strange step here at some point
This commit is contained in:
Panagiotis Papadopoulos 2025-03-05 08:54:42 +01:00 committed by Panagiotis Papadopoulos
parent 3553d64060
commit 38690053a8
2 changed files with 8 additions and 0 deletions

View File

@ -10,6 +10,7 @@ COPY . .
RUN npm ci && \
npm run build:prepare-dist && \
npm cache clean --force && \
rm -rf dist/node_modules && \
mv dist/* \
start-docker.sh \
package-lock.json \
@ -17,6 +18,9 @@ RUN npm ci && \
rm -rf /usr/src/app/build
#TODO: move package-lock copying into copy-dist
#TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work
# currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down),
# as we install necessary dependencies in runtime buildstage anyways
# Runtime stage
FROM node:22.14.0-bullseye-slim

View File

@ -10,6 +10,7 @@ COPY . .
RUN npm ci && \
npm run build:prepare-dist && \
npm cache clean --force && \
rm -rf dist/node_modules && \
mv dist/* \
start-docker.sh \
package-lock.json \
@ -17,6 +18,9 @@ RUN npm ci && \
rm -rf /usr/src/app/build
#TODO: move package-lock copying into copy-dist
#TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work
# currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down),
# as we install necessary dependencies in runtime buildstage anyways
# Runtime stage
FROM node:22.14.0-alpine