From 762c9d899d66a2ad244c29edb9701cd4702dea8f Mon Sep 17 00:00:00 2001 From: null Date: Sun, 17 May 2026 16:34:36 -0500 Subject: [PATCH] =?UTF-8?q?fix(docker):=20slim=20runner=20stage=20?= =?UTF-8?q?=E2=80=94=20native=20deps=20in=20separate=20build=20stage=20(56?= =?UTF-8?q?7MB=20=E2=86=92=20248MB)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9ba70ce..560edb6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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