From 31ddb902f8c72fdb45dd25429fa51a82706e2958 Mon Sep 17 00:00:00 2001 From: Justin McLellan Date: Sat, 4 Jul 2026 01:01:43 -0500 Subject: [PATCH] Cache-mount the pnpm store in the Docker build Shares a warm, content-addressable pnpm store (id=pnpm-store) across C4G app builds on the same BuildKit instance so slow/interrupted installs on the deploy server reuse already-downloaded packages. Applied to both the deps and builder install steps. Co-Authored-By: Claude Opus 4.8 (1M context) --- Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 21de9de..ddbb9ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,8 +13,9 @@ WORKDIR /app COPY package.json pnpm-lock.yaml ./ # Install dependencies -RUN corepack enable && corepack prepare pnpm@latest --activate && \ - pnpm install --frozen-lockfile --prod +RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \ + corepack enable && corepack prepare pnpm@latest --activate && \ + pnpm install --frozen-lockfile --prod --store-dir=/pnpm/store # Rebuild the source code only when needed FROM base AS builder @@ -32,8 +33,9 @@ ENV NEXTAUTH_URL=$NEXTAUTH_URL COPY package.json pnpm-lock.yaml ./ # Install ALL dependencies (skip postinstall to avoid prisma generate before schema exists) -RUN corepack enable && corepack prepare pnpm@latest --activate && \ - pnpm install --frozen-lockfile --ignore-scripts +RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \ + corepack enable && corepack prepare pnpm@latest --activate && \ + pnpm install --frozen-lockfile --ignore-scripts --store-dir=/pnpm/store # Copy source code COPY . .