perf(docker): prune devDeps and cleanup node_modules in all backend Dockerfiles

Add pnpm prune --prod and remove .ts/.map/test/docs files from
node_modules in the builder stage for chat, todo, calendar, clock,
and contacts backends. Same approach as mana-core-auth optimization.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-03-20 19:42:01 +01:00
parent 152fa5fe08
commit 70671e2b2b
5 changed files with 35 additions and 0 deletions

View file

@ -59,6 +59,13 @@ RUN pnpm build
WORKDIR /app/apps/calendar/apps/backend
RUN pnpm build
# Remove devDependencies and unnecessary files from node_modules
WORKDIR /app
RUN pnpm prune --prod --no-optional 2>/dev/null || true \
&& find node_modules -name '*.ts' -not -name '*.d.ts' -delete 2>/dev/null || true \
&& find node_modules -name '*.map' -delete 2>/dev/null || true \
&& find node_modules -type d \( -name 'test' -o -name 'tests' -o -name '__tests__' -o -name 'docs' \) -prune -exec rm -rf {} + 2>/dev/null || true
# Production stage
FROM node:20-alpine AS production

View file

@ -63,6 +63,13 @@ RUN pnpm build
WORKDIR /app/apps/chat/apps/backend
RUN pnpm build
# Remove devDependencies and unnecessary files from node_modules
WORKDIR /app
RUN pnpm prune --prod --no-optional 2>/dev/null || true \
&& find node_modules -name '*.ts' -not -name '*.d.ts' -delete 2>/dev/null || true \
&& find node_modules -name '*.map' -delete 2>/dev/null || true \
&& find node_modules -type d \( -name 'test' -o -name 'tests' -o -name '__tests__' -o -name 'docs' \) -prune -exec rm -rf {} + 2>/dev/null || true
# Production stage
FROM node:20-alpine AS production

View file

@ -52,6 +52,13 @@ RUN pnpm build
WORKDIR /app/apps/clock/apps/backend
RUN pnpm build
# Remove devDependencies and unnecessary files from node_modules
WORKDIR /app
RUN pnpm prune --prod --no-optional 2>/dev/null || true \
&& find node_modules -name '*.ts' -not -name '*.d.ts' -delete 2>/dev/null || true \
&& find node_modules -name '*.map' -delete 2>/dev/null || true \
&& find node_modules -type d \( -name 'test' -o -name 'tests' -o -name '__tests__' -o -name 'docs' \) -prune -exec rm -rf {} + 2>/dev/null || true
# Production stage
FROM node:20-alpine AS production

View file

@ -54,6 +54,13 @@ RUN pnpm build
WORKDIR /app/apps/contacts/apps/backend
RUN pnpm build
# Remove devDependencies and unnecessary files from node_modules
WORKDIR /app
RUN pnpm prune --prod --no-optional 2>/dev/null || true \
&& find node_modules -name '*.ts' -not -name '*.d.ts' -delete 2>/dev/null || true \
&& find node_modules -name '*.map' -delete 2>/dev/null || true \
&& find node_modules -type d \( -name 'test' -o -name 'tests' -o -name '__tests__' -o -name 'docs' \) -prune -exec rm -rf {} + 2>/dev/null || true
# Production stage
FROM node:20-alpine AS production

View file

@ -59,6 +59,13 @@ RUN pnpm build
WORKDIR /app/apps/todo/apps/backend
RUN pnpm build
# Remove devDependencies and unnecessary files from node_modules
WORKDIR /app
RUN pnpm prune --prod --no-optional 2>/dev/null || true \
&& find node_modules -name '*.ts' -not -name '*.d.ts' -delete 2>/dev/null || true \
&& find node_modules -name '*.map' -delete 2>/dev/null || true \
&& find node_modules -type d \( -name 'test' -o -name 'tests' -o -name '__tests__' -o -name 'docs' \) -prune -exec rm -rf {} + 2>/dev/null || true
# Production stage
FROM node:20-alpine AS production