From 6513fdee411a4ceacdb53119af80fe84d7f71716 Mon Sep 17 00:00:00 2001 From: Michelle Date: Fri, 13 Mar 2026 22:41:18 +0100 Subject: [PATCH] fix(Dockerfile): update base image and streamline build stages --- Dockerfile | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5145aee..0ad27a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,31 @@ -# ── Stage 1: Build frontend ────────────────────────────────────────────────── -FROM node:20-bullseye-slim AS builder +# ── Stage 1: Install dependencies ──────────────────────────────────────────── +FROM node:22-trixie-slim AS deps WORKDIR /app -# Install build tools and sqlite headers for native modules +ENV DEBIAN_FRONTEND=noninteractive + +# Install build tools for native modules (better-sqlite3, pdfkit) RUN apt-get update && apt-get install -y --no-install-recommends \ - python3 build-essential libsqlite3-dev ca-certificates \ + python3 build-essential libsqlite3-dev \ && rm -rf /var/lib/apt/lists/* COPY package.json package-lock.json* ./ + +# Install all dependencies (including dev for vite build) RUN npm ci +# ── Stage 2: Build frontend ───────────────────────────────────────────────── +FROM deps AS builder + COPY . . RUN npm run build -# Produce production node_modules (compile native modules here for the target arch) -RUN npm ci --omit=dev && npm cache clean --force -# ── Stage 2: Production image ─────────────────────────────────────────────── +# Prune dev dependencies in-place (avoids a second npm ci) +RUN npm prune --omit=dev -FROM node:20-bullseye-slim - -# Allow forcing build from source (useful when prebuilt binaries are not available) -ARG BUILD_FROM_SOURCE=false -ENV npm_config_build_from_source=${BUILD_FROM_SOURCE} +# ── Stage 3: Production image ─────────────────────────────────────────────── +FROM node:22-trixie-slim WORKDIR /app