fix(docker): slim runner stage — native deps in separate build stage (567MB → 248MB)

This commit is contained in:
null 2026-05-17 16:34:36 -05:00
parent b428348a4c
commit 762c9d899d
1 changed files with 12 additions and 3 deletions

View File

@ -18,6 +18,16 @@ COPY . .
# Build the frontend
RUN npm run build
# Native modules stage — compile better-sqlite3 in a dedicated stage
FROM node:20-alpine AS native-deps
WORKDIR /app
COPY package.json package-lock.json* ./
RUN apk add --no-cache python3 make g++
RUN npm ci --omit=dev
# Production stage
FROM node:20-alpine AS runner
@ -51,9 +61,8 @@ COPY --from=builder /app/package.json /app/package-lock.json* ./
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/server ./server
# Install build tools for native modules + production dependencies
RUN apk add --no-cache python3 make g++
RUN npm ci --omit=dev
# Copy compiled native modules from native-deps stage (no build tools in final image)
COPY --from=native-deps /app/node_modules ./node_modules
# Expose backend port
EXPOSE 3001