From 75db48348a2d4c8354c9b9003c619b2312f31487 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni <6173598+dpschen@users.noreply.github.com> Date: Tue, 20 May 2025 17:14:40 +0200 Subject: [PATCH] feat: improve docker layers (#803) Via lockfile-first copy and better dockerignore --- .dockerignore | 11 +++++++++++ Dockerfile | 12 ++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index 5026e6472..fae5509f9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,10 @@ +# Source-control & editors +.git +.github +.vscode +.idea +*.swp + files/ dist/ logs/ @@ -16,3 +23,7 @@ docker-manifest-unstable.tmpl /frontend/node_modules/ /frontend/.direnv /frontend/dist + +# OS +.DS_Store +Thumbs.db diff --git a/Dockerfile b/Dockerfile index 37391210c..ac54cc98d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,11 +7,15 @@ ENV PNPM_CACHE_FOLDER=.cache/pnpm/ ENV PUPPETEER_SKIP_DOWNLOAD=true ENV CYPRESS_INSTALL_BINARY=0 -COPY frontend/ ./ - +# First copy lockfile & manifest => they rarely change +COPY frontend/pnpm-lock.yaml frontend/package.json ./ RUN npm install -g corepack && corepack enable && \ - pnpm install --frozen-lockfile --prefer-offline && \ - pnpm run build + pnpm fetch --prod # installs into cache only + +# Copy the rest => invalidates only when code changes +COPY frontend/ ./ +RUN pnpm install --frozen-lockfile --offline && \ + pnpm run build FROM --platform=$BUILDPLATFORM ghcr.io/techknowlogick/xgo:go-1.23.x@sha256:d45f463381d025efa2fa0fb8617d2b04694e650bfd5d206ae1ef13d0c78fdea6 AS apibuilder