Skip to content

ci: speed up backend image build (step 1)#4685

Merged
marcoacierno merged 1 commit into
mainfrom
optimise-build-speed
Jun 20, 2026
Merged

ci: speed up backend image build (step 1)#4685
marcoacierno merged 1 commit into
mainfrom
optimise-build-speed

Conversation

@marcoacierno

Copy link
Copy Markdown
Member

What

Two changes to .github/workflows/build-backend.yml:

  1. Move build cache from GitHub Actions cache → ECR registry (same pycon-backend repo, :buildcache tag).
  2. Drop the QEMU setup step — the runner is ubuntu-24.04-arm building linux/arm64 natively, no emulation needed.

Why

The backend image build was taking ~12 min. Almost none of it was compiling — it was moving big layers around. Breakdown of the Build and push step (~11m55s):

Phase Time
Real build work (uv sync, schema, .venv copy, collectstatic) ~2.5 min
Export image → ECR ~3.5 min
Export build cache → GitHub Actions (mode=max) ~7 min

The dominant cost was exporting the cache to the GHA backend: mode=max re-uploads every layer of every stage to a separate, rate-limited store. The heavy .venv layer (multi-GB — sentence-transformers pulls in torch + transformers) got uploaded twice: once to ECR as the image, once to GHA as cache.

Pointing the cache at the same ECR repo lets the image push and cache export share one content-addressed store, so shared layers upload once, and ECR isn't throttled like the GHA cache backend. Expected saving ~3–4 min/build.

Notes

  • image-manifest=true,oci-mediatypes=true are required — ECR rejects buildkit's legacy cache-manifest format.
  • mode=max kept on purpose: this is a multi-stage build; min would stop caching the intermediate uv sync / pnpm build stages, which would then re-run on every ephemeral CI runner.
  • First run after merge: the :buildcache tag doesn't exist yet → cache miss, builds fresh, creates it. Speedup lands on run Login / Authentication #2+.

This is step 1

This is the first step. The real fix is shrinking the image: the multi-GB .venv (torch/transformers via sentence-transformers, plus scikit-learn/nltk) bloats every phase — .venv copy, image export, image push, and cache export. Step 2 will move the ML stuff out (CPU-only torch / a separate ML worker image) so the web image stays small. That's the change that cuts every phase regardless of cache backend; this PR just stops the bleeding on the cache export first.

🤖 Generated with Claude Code

Move the backend build cache from the GitHub Actions cache backend to
the ECR registry, and drop the unused QEMU setup step.

The 12-minute backend builds were dominated by exporting the build cache
to GitHub Actions (~7 min, mode=max re-uploading every layer of every
stage to a throttled backend). Pointing the cache at the same ECR repo
lets the image push and cache export share one content-addressed store,
so the heavy .venv layer uploads once instead of twice, and ECR is not
rate-limited like the GHA cache backend.

image-manifest=true,oci-mediatypes=true are required: ECR rejects
buildkit's legacy cache-manifest format. mode=max is kept on purpose —
this is a multi-stage build and min would stop caching the intermediate
uv sync / pnpm build stages, which would re-run on every ephemeral CI
runner.

QEMU is removed because the runner is ubuntu-24.04-arm building
linux/arm64 natively, so no emulation is needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pycon Building Building Preview Jun 20, 2026 7:47pm

@marcoacierno marcoacierno merged commit 4c3a02c into main Jun 20, 2026
5 of 6 checks passed
@marcoacierno marcoacierno deleted the optimise-build-speed branch June 20, 2026 19:48
@claude

claude Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Switches backend Docker build cache from GitHub Actions to ECR registry and removes the now-redundant QEMU setup step since the runner is natively ARM.

No issues found.

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