fix(Dockerfile): update base image and streamline build stages
All checks were successful
Build & Push Docker Image / build (push) Successful in 4m17s
All checks were successful
Build & Push Docker Image / build (push) Successful in 4m17s
This commit is contained in:
27
Dockerfile
27
Dockerfile
@@ -1,28 +1,31 @@
|
|||||||
# ── Stage 1: Build frontend ──────────────────────────────────────────────────
|
# ── Stage 1: Install dependencies ────────────────────────────────────────────
|
||||||
FROM node:20-bullseye-slim AS builder
|
FROM node:22-trixie-slim AS deps
|
||||||
|
|
||||||
WORKDIR /app
|
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 \
|
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/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY package.json package-lock.json* ./
|
COPY package.json package-lock.json* ./
|
||||||
|
|
||||||
|
# Install all dependencies (including dev for vite build)
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
|
# ── Stage 2: Build frontend ─────────────────────────────────────────────────
|
||||||
|
FROM deps AS builder
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
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
|
# ── Stage 3: Production image ───────────────────────────────────────────────
|
||||||
|
FROM node:22-trixie-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}
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user