build(Docker): improve image size, by deleting node-compile-cache

This commit is contained in:
Panagiotis Papadopoulos 2025-03-05 09:09:54 +01:00 committed by Panagiotis Papadopoulos
parent 907b8c503e
commit 70e227f4c3
2 changed files with 13 additions and 6 deletions

View File

@ -14,7 +14,9 @@ RUN npm ci && \
mv dist/* \
start-docker.sh \
/usr/src/app/ && \
rm -rf /usr/src/app/build
rm -rf \
/usr/src/app/build \
/tmp/node-compile-cache
#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),
@ -29,14 +31,16 @@ WORKDIR /usr/src/app
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gosu && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apt/*
rm -rf \
/var/lib/apt/lists/* \
/var/cache/apt/*
COPY --from=builder /usr/src/app ./
RUN sed -i "/electron/d" package.json && \
npm ci --omit=dev && \
npm cache clean --force
npm cache clean --force && \
rm -rf /tmp/node-compile-cache
# Configure container
EXPOSE 8080

View File

@ -14,7 +14,9 @@ RUN npm ci && \
mv dist/* \
start-docker.sh \
/usr/src/app/ && \
rm -rf /usr/src/app/build
rm -rf \
/usr/src/app/build \
/tmp/node-compile-cache
#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),
@ -32,7 +34,8 @@ COPY --from=builder /usr/src/app ./
RUN sed -i "/electron/d" package.json && \
npm ci --omit=dev && \
npm cache clean --force
npm cache clean --force && \
rm -rf /tmp/node-compile-cache
# Add application user
RUN adduser -s /bin/false node; exit 0