fix(docker): slim runner stage — native deps in separate build stage (567MB → 248MB)
This commit is contained in:
parent
b428348a4c
commit
762c9d899d
15
Dockerfile
15
Dockerfile
|
|
@ -18,6 +18,16 @@ COPY . .
|
||||||
# Build the frontend
|
# Build the frontend
|
||||||
RUN npm run build
|
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
|
# Production stage
|
||||||
FROM node:20-alpine AS runner
|
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/dist ./dist
|
||||||
COPY --from=builder /app/server ./server
|
COPY --from=builder /app/server ./server
|
||||||
|
|
||||||
# Install build tools for native modules + production dependencies
|
# Copy compiled native modules from native-deps stage (no build tools in final image)
|
||||||
RUN apk add --no-cache python3 make g++
|
COPY --from=native-deps /app/node_modules ./node_modules
|
||||||
RUN npm ci --omit=dev
|
|
||||||
|
|
||||||
# Expose backend port
|
# Expose backend port
|
||||||
EXPOSE 3001
|
EXPOSE 3001
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue