Skip to content

ci: keep BuildKit state on a RunsOn sticky disk and allow Testcontainers reuse - #40

Merged
hbrombeer merged 1 commit into
mainfrom
ci-cache-tuning
Oct 30, 2026
Merged

hbrombeer merged 1 commit into
mainfrom
ci-cache-tuning

Conversation

@hbrombeer

Copy link
Copy Markdown
Member

Docker builds: sticky BuildKit state

Every image build ran Gradle from scratch, ~3 min in service-moderation, because the Dockerfiles' RUN --mount=type=cache,target=/root/.gradle/... mounts are never exported by any cache backend (type=gha, s3, registry). The default RunsOn label now adds sticky=docker:30gb, and runs-on/action runs in buildkit mode. The Buildx builder's whole state, cache mounts included, then lives on an EBS disk that is snapshotted per repo and branch, with fallback to the default branch.

  • The builder name comes from the action output, and cleanup: false lets the RunsOn post step snapshot the disk.
  • A runner override has no sticky label, so the mode is skipped. GitHub-hosted (public) builds are unchanged.
  • No Dockerfile changes.

Measured on groundsgg/service-moderation#150 (PR build, 4 vCPU spot):

Gradle in image Build step
before (cold, every build) 3:09 190 s
source change, warm sticky disk 1:01, no Gradle distribution download 68 s
unchanged source (rerun) layer CACHED 5 s

Gradle CI: Testcontainers reuse

Quarkus Dev Services request container reuse, but Testcontainers ignored the request ("Reuse was requested but the environment does not support the reuse of containers", 6× per run in service-moderation). The runner now opts in through ~/.testcontainers.properties. This is safe because the runner is discarded after the job. On #150 the warning is gone and the tests stay green; the test duration barely moved there (307 s → 292 s).

Tests

  • New contract test test_sticky_buildkit_state_only_with_the_default_runs_on_label.
  • The resolver now handles hyphenated step ids.
  • python -m unittest discover -s tests: 11 tests OK.

…ers reuse

Docker image builds resolved Gradle from scratch every time (~3 min in
service-moderation): the Dockerfiles' --mount=type=cache mounts are not
carried by any cache exporter. The default RunsOn label now adds a
sticky=docker disk and runs-on/action in buildkit mode, so the builder's
whole state, cache mounts included, is snapshotted per repo and branch.

Gradle CI opts the ephemeral runner into Testcontainers reuse, which Quarkus
Dev Services already request.
@hbrombeer
hbrombeer marked this pull request as ready for review October 30, 2026 09:24
@hbrombeer
hbrombeer merged commit e689c5d into main Oct 30, 2026
3 checks passed
@hbrombeer
hbrombeer deleted the ci-cache-tuning branch October 30, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant