chore(docker): cache pnpm store to avoid re-downloading deps

Source is copied before install because the root postinstall (nuxt prepare)
needs it, so the dependency layer can't be cached by ordering alone. A
BuildKit cache mount on pnpm's store keeps packages across builds instead.
This commit is contained in:
Julien Calixte
2026-05-27 23:31:32 +02:00
parent 1194edcf75
commit 230d523891

View File

@@ -5,7 +5,11 @@ FROM node:24-alpine AS build
RUN corepack enable RUN corepack enable
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN pnpm install --frozen-lockfile # Cache the pnpm store across builds so dependencies aren't re-downloaded on
# every source change. Source is copied first because the root `postinstall`
# (nuxt prepare) needs it.
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile
RUN pnpm build RUN pnpm build
# --- Runtime stage: minimal image running the built server --- # --- Runtime stage: minimal image running the built server ---