Skip to content

Keep the Lean build trees out of the web image - #24

Merged
Gabrielebattimelli merged 1 commit into
mainfrom
fix/image-bloat
Aug 16, 2026
Merged

Keep the Lean build trees out of the web image#24
Gabrielebattimelli merged 1 commit into
mainfrom
fix/image-bloat

Conversation

@Gabrielebattimelli

Copy link
Copy Markdown
Member

Root cause of the 2026-08-16 outage

The deployed image was 21 GB. A locally-built one is ~2.9 GB.

14G   /app/physlib    <- entire Lean/Mathlib build tree
236M  /app/jixia      <- analyzer build
148M  /app/chroma     <- the index (the only one that belongs)

The indexing workflow clones PhysLib and jixia into the working directory and builds them with Lake. COPY . . then baked all 14 GB into the web image. .dockerignore did list .lake/ and *.olean, but those patterns only match at the repo root — not the nested physlib/.lake/... paths the workflow creates.

Heroku gives a dyno ~60s to boot. A 21 GB image cannot be pulled and started in that window, so it was killed before it could come up.

Every prior observation fits: same commit (the build context differed), no R14/R15 (never got far enough to allocate), SIGTERM ~1.3s after Ready, and it only ever broke on workflow-built images. Local builds had no physlib/ directory at all — which is why this was not reproducible locally, and why the earlier -H 0.0.0.0 fix looked like a complete solution when it was not.

What

  • Exclude physlib/, jixia/, and nested **/.lake/, **/*.olean, **/*.ilean.
  • Check the built image size before releasing. Fails above 6 GB (healthy ~3 GB) and prints the largest /app entries so the cause is immediately visible.

The size guard is the part that generalises — it catches any future context leak, not just this one.

Verified

Reproduced the CI layout locally by planting 800 MB physlib/ and 200 MB jixia/ trees:

/app/physlib: No such file or directory   OK
/app/jixia:   No such file or directory   OK
148M /app/chroma                          OK - index still ships

The 2026-08-16 deploy shipped a 21 GB image and the dyno could not boot
inside the platform's startup window, so the site was down until it was
rolled back manually.

The indexing workflow clones physlib/ and jixia/ into the working directory
and builds them with Lake, so COPY . . baked the whole Lean toolchain into
the web image: physlib/ alone was 14 GB, against 148 MB of index that
actually needs to ship. .dockerignore did list .lake/ and *.olean, but those
patterns only match at the root, not the nested paths the workflow creates.

Exclude physlib/ and jixia/ outright, plus nested **/.lake/ and **/*.olean.
Verified by planting 800 MB and 200 MB dummy trees to reproduce the CI
layout: both are excluded from the built image and chroma/ still ships.

Also check the built image size before releasing it, failing with the
largest /app entries listed if it exceeds 6 GB (a healthy image is ~3 GB).
The size limit is the part that generalises: it catches any future leak into
the build context, not just this one. Local builds never had physlib/ in the
first place, which is why this was invisible until it reached production.
Copilot AI lite review requested due to automatic review settings August 16, 2026 13:19
@Gabrielebattimelli
Gabrielebattimelli merged commit 57e5963 into main Aug 16, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reduces the deployed web image size and prevents future “build context leaks” (e.g., nested Lean build trees) from shipping to Heroku, which previously caused a boot-time outage due to an oversized image.

Changes:

  • Expands .dockerignore to exclude physlib/, jixia/, and nested Lean build artifacts (**/.lake/, **/*.olean, **/*.ilean).
  • Adds a GitHub Actions size gate that builds the Docker image and fails the workflow if it exceeds a configured threshold (6 GB), printing the largest /app entries for diagnosis.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/weekly-index.yml Adds an image-size guard step before releasing to prevent deploying oversized images.
.dockerignore Ensures nested Lean/Lake build outputs and cloned repos don’t enter the Docker build context.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +335 to 338
- name: Release Docker image
if: steps.gate.outputs.proceed == 'true'
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
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.

2 participants