From 01d5ebbdb8f75a2f9e63a26a8ac2fd827c3f40db Mon Sep 17 00:00:00 2001 From: DevContainer User Date: Tue, 3 Mar 2026 16:51:22 +0000 Subject: [PATCH] perf: cache base image pull only, rebuild all our layers ARG CACHE_BUST placed immediately after FROM so only the base image layer is served from GHA cache. All RUN/ENV/COPY layers are rebuilt every build via CACHE_BUST=$GITHUB_SHA. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/build-and-push.yaml | 4 +++- .github/workflows/release-unified.yaml | 4 +++- Dockerfile | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index 5f8f81c..8a0f3c7 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -56,5 +56,7 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - no-cache: true + build-args: CACHE_BUST=${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max platforms: linux/amd64 diff --git a/.github/workflows/release-unified.yaml b/.github/workflows/release-unified.yaml index 0b4d85f..602129f 100644 --- a/.github/workflows/release-unified.yaml +++ b/.github/workflows/release-unified.yaml @@ -96,7 +96,9 @@ jobs: with: context: . push: true - no-cache: true + build-args: CACHE_BUST=${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} diff --git a/Dockerfile b/Dockerfile index 1d0f6f2..86090c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ FROM jlesage/baseimage-gui:ubuntu-22.04-v4 +# Bust cache for all layers below (base image pull is still cached) +ARG CACHE_BUST + # Set environment variables ENV APP_NAME="Dev Container" \ KEEP_APP_RUNNING=1 \