Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions .github/workflows/component-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ on:
required: false
type: string
description: 'Git SHA to checkout and build from. Defaults to the triggering commit SHA.'
prebuilt-artifact:
required: false
type: string
default: ''
description: "Name of an artifact an earlier job in the run uploaded, downloaded into the root of the build context before the Docker build, such as a binary compiled on the runner. Artifacts don't keep file modes, so the Dockerfile should COPY it with --chmod."
dockerfile-cache-mounts:
required: false
type: boolean
default: true
description: "Restore and save the Dockerfile's RUN --mount=type=cache contents on ARC. Turn it off when the build skips the stages that use them, such as with a prebuilt-artifact."
secrets:
AWS_ACCOUNT_ID:
required: true
Expand Down Expand Up @@ -128,6 +138,11 @@ jobs:
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
ref: ${{ inputs.git-sha || github.sha }}
- name: Download prebuilt artifact
if: ${{ inputs.prebuilt-artifact != '' }}
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: ${{ inputs.prebuilt-artifact }}
- name: Configure AWS credentials via assumed role
uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6
with:
Expand All @@ -151,7 +166,7 @@ jobs:
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
- name: Restore Dockerfile cache mounts
id: cache-mounts
if: ${{ (inputs.use-arc-runners && github.event.repository.private) && env.S3_CACHE != 'true' }}
if: ${{ (inputs.use-arc-runners && github.event.repository.private) && inputs.dockerfile-cache-mounts && env.S3_CACHE != 'true' }}
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with: &cache-mounts
path: ${{ runner.temp }}/buildkit-cache-mounts
Expand All @@ -160,7 +175,7 @@ jobs:
buildkit-cache-mounts-${{ inputs.docker-file-name }}-
- name: Restore Dockerfile cache mounts (S3)
id: cache-mounts-s3
if: ${{ env.S3_CACHE == 'true' }}
if: ${{ inputs.dockerfile-cache-mounts && env.S3_CACHE == 'true' }}
uses: runs-on/cache@88d90644011a3a9957fd141a106f5a94f9794203 # v5.0.7
env:
RUNS_ON_S3_BUCKET_CACHE: monta-github-ci-cache
Expand All @@ -171,7 +186,7 @@ jobs:
AWS_REGION: eu-west-1
with: *cache-mounts
- name: Inject Dockerfile cache mounts into the builder
if: ${{ (inputs.use-arc-runners && github.event.repository.private) }}
if: ${{ (inputs.use-arc-runners && github.event.repository.private) && inputs.dockerfile-cache-mounts }}
uses: reproducible-containers/buildkit-cache-dance@5422eac04292c961a382e0f584ea0f03ad9da723 # v3.4.0
with:
dockerfile: ${{ inputs.docker-file-name }}
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/deploy-generic-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ on:
required: false
type: string
description: 'Git SHA to checkout and build from. Defaults to the triggering commit SHA.'
prebuilt-artifact:
required: false
type: string
default: ''
description: "Name of an artifact an earlier job in the run uploaded, downloaded into the root of the build context before the Docker build. Needs the caller to run that job first: pass it in the same workflow run (see component-build.yml)."
dockerfile-cache-mounts:
required: false
type: boolean
default: true
description: "Restore and save the Dockerfile's RUN --mount=type=cache contents on ARC. Turn it off when the build skips the stages that use them."
argocd-resource-name:
required: false
type: string
Expand Down Expand Up @@ -179,6 +189,8 @@ jobs:
additional-build-args: ${{ inputs.additional-build-args }}
ecr-repository-name: ${{ inputs.ecr-repository-name }}
git-sha: ${{ inputs.git-sha }}
prebuilt-artifact: ${{ inputs.prebuilt-artifact }}
dockerfile-cache-mounts: ${{ inputs.dockerfile-cache-mounts }}
secrets:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

## Recent Changes (2026-11-15)
1. **Dockerfile cache mounts are saved only when the lockfiles change again, on S3 too**: the per-commit key from 2026-11-14 is gone. Measured on infra-portal's backend deploys: a fresh Go build cache cut `go build` from ~130 s to 6.8 s, but every build then paid ~70 s to restore and inject ~600 MB of cache mounts and ~135 s to extract (cache-dance's post step, 125 s) and upload them, so the build job was about a minute slower than without the cache at all. Extraction is skipped only on an exact key hit, so a key that never hits makes every build pay it. The cache mounts stay in `runner.temp`. A repo that wants a fresh compile cache is better off compiling on the runner (e.g. `actions/setup-go`'s cache) and copying the artifact into the image.
2. **`prebuilt-artifact` and `dockerfile-cache-mounts` on `component-build.yml` and `deploy-generic-v2.yml`**: a caller can compile on the runner in a job of its own (with a runner-side compile cache, such as `actions/setup-go` plus `runs-on/cache`), upload the result as an artifact and pass its name as `prebuilt-artifact`; the build job downloads it into the root of the build context before `docker build`, so the Dockerfile only `COPY --chmod=755`s it (artifacts drop file modes). `dockerfile-cache-mounts: false` skips restoring, injecting and saving the Dockerfile's cache mounts, which such a Dockerfile no longer uses: on infra-portal they cost ~70 s to restore and inject and, saved, ~135 s to extract and upload. Both default to the old behaviour.

## Recent Changes (2026-11-14)
1. **Dockerfile cache mounts live outside the checkout and, on S3, are saved every build** (per-commit key reverted 2026-11-15, see above): `component-build.yml` restores the cache mounts into `${{ runner.temp }}/buildkit-cache-mounts` (and cache-dance's scratch dir into `runner.temp`) instead of `buildkit-cache-mounts` in the checkout. With the folder in the checkout, a Dockerfile that runs `COPY . .` without a `.dockerignore` shipped the whole restored cache (1.3 GB for infra-portal's Go caches) as build context, baked it into a layer and compressed it into the registry cache on every build. On the S3 backend the key also ends in the commit SHA, so every build saves its caches and the next one restores the newest saved for the Dockerfile (the existing prefix restore key). Before, the key changed only with the lockfiles, so the Go build cache (and Gradle's) went stale with every commit: infra-portal's `go build` took ~130 s with the cache restored, against ~11 s locally with a fresh one. The `actions/cache` backend keeps the lockfile-only key, since per-commit saves would churn the 10 GB GitHub cache quota.
Expand Down