From c4cd716dae5ee730a91933e9b46f8e2047b4fc27 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Sun, 8 Feb 2026 13:06:55 +0100 Subject: [PATCH] perf: optimize docker build with pnpm cache mounts and less aggressive pruning --- .gitea/workflows/deploy.yml | 2 +- Dockerfile | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 1f8cedc..3d7260f 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -44,7 +44,7 @@ jobs: shell: bash run: | docker image prune -f || true - docker builder prune -f --filter "until=24h" || true + docker builder prune -f --filter "until=168h" || true - name: Checkout repository uses: actions/checkout@v4 diff --git a/Dockerfile b/Dockerfile index 0527aa0..02153b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,12 +20,18 @@ ENV SENTRY_SUPPRESS_TURBOPACK_WARNING=1 # Enable pnpm RUN corepack enable -# Copy workspace configuration +# Set pnpm home and store directory for caching +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN mkdir -p /pnpm/store + +# Copy workspace configuration and manifests for better caching COPY pnpm-lock.yaml pnpm-workspace.yaml package.json .npmrc ./ COPY apps/web/package.json ./apps/web/package.json -# Install dependencies (use cache mount if possible, but keep it simple as per standard) -RUN pnpm install --no-frozen-lockfile +# Install dependencies with cache mount +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ + pnpm install --frozen-lockfile # Copy source COPY . .