fix(images): prune the unused Go binaries from the ci image #123

Merged
Defame1297 merged 1 commits from ci/ci-image-prune-go-binaries into main 2026-11-14 15:17:49 +00:00
Owner

Fixes the failed image build of ci 0.2.16 after #121. Refs #112, #118. This is another PR 1 of the two-PR loop: the consumer pins still move in a second PR once the image is built on main.

What failed

The Images run for the #121 merge built ci 0.2.16 and passed every step, including the new ruff and shellcheck smoke steps, then failed at the push: 413 Payload Too Large from Cloudflare on a blob upload. That is the 100 MB-per-layer limit that CLAUDE.md and the Dockerfile header warn about. Lint, Build and the 24.04 image job passed; ci 0.2.16 was never published (the version lookup said "not published yet" and the push failed), so nothing is on the registry to move or rebuild.

Cause

I read the published 0.2.15 manifest and each layer from the registry (anonymous pull token):

  • The /opt/pre-commit layer (layer 5) was 75.5 MB compressed before this change, 137 MB raw, against a limit of 100 MB (95.4 MiB).
  • The two new hook environments (ruff 26 MB, shellcheck-py 18 MB compressed, from a local build of the same hooks) push it past the limit. Re-gzipping the published layer and adding them gives about 113 MiB, about 124 MiB scaled to what the registry stores (my gzip -6 runs about 9% under the registry), against 95.4 MiB.
  • Most of that layer is not needed. pre-commit installs every main package of a Go hook repository, so next to the gitleaks and actionlint binaries the hooks call it leaves gitleaks' config (19 MB) and actionlint's check-checks and three generate-* tools (about 40 MB). The .pre-commit-hooks.yaml of both repositories names only gitleaks and actionlint as entries; nothing in this repository's workflows, scripts or docs references the others.

Fix

  • After the existing cleanup of the Go toolchains, delete everything in each golangenv-*/bin except gitleaks and actionlint. The smoke test that runs all six hooks comes after it, so a wrongly deleted binary fails the image build, not the jobs.
  • Print the compressed size of /opt/venv, /opt/python, /opt/collections and /opt/pre-commit at the end of that step: the number the limit applies to. The old du lines stay for the per-environment view.
  • ci 0.2.16 -> 0.2.17 (scripts/bump_image_versions.py): the bump check requires a version above the 0.2.16 that is now in the matrix on main. 0.2.16 stays unpublished.
  • docs/images/ci.md describes the cleanup.

Verified

  • I replicated the image's hook step locally with this repository's real .pre-commit-config.yaml (hooks installed into a scratch PRE_COMMIT_HOME, same cleanup, same six smoke hooks): the pre-commit home measures 226.8 MB compressed with the toolchains, 89.9 MB with them removed (what 0.2.16 pushed), 57.3 MB with the unused binaries also pruned, in gzip -6 MiB. That is about 63 MiB scaled to the registry, a margin of roughly a third of the limit. All six hooks pass after pruning, and the surviving binaries are exactly gitleaks and actionlint.
  • The new find ... -delete expression was run on a fake tree and kept gitleaks, actionlint and the Python ruff, removing the rest. The new size-printing function was run under dash (the image build's /bin/sh).
  • check_image_versions.py pins and bump origin/main pass.

Not verified

  • The image build itself and the push: they run only on main, never on a pull request, so the first real test is the merge. The local replication used this host's Python 3.13 where the image has 3.14, and a local Go toolchain download; sizes should be close, not identical.
  • Margin: ruff and shellcheck-py were measured from a local cache, not from the image's environments.

Things to know

  • Each new hook environment adds 15 to 25 MB to this layer; the sizes the build now prints are the thing to read before adding one.
  • After the merge: image.yml builds ci 0.2.17 on main; the pin-follow PR then moves lint.yml and build.yml from 0.2.15 to it. Until then Lint on main runs on the old image and takes the install path, as in #121.

🤖 Generated with Claude Code

Fixes the failed image build of `ci` 0.2.16 after #121. Refs #112, #118. This is another PR 1 of the two-PR loop: the consumer pins still move in a second PR once the image is built on `main`. ## What failed The Images run for the #121 merge built `ci` 0.2.16 and passed every step, including the new ruff and shellcheck smoke steps, then failed at the push: `413 Payload Too Large` from Cloudflare on a blob upload. That is the 100 MB-per-layer limit that `CLAUDE.md` and the Dockerfile header warn about. Lint, Build and the 24.04 image job passed; `ci` 0.2.16 was never published (the version lookup said "not published yet" and the push failed), so nothing is on the registry to move or rebuild. ## Cause I read the published 0.2.15 manifest and each layer from the registry (anonymous pull token): - The `/opt/pre-commit` layer (layer 5) was **75.5 MB compressed** before this change, 137 MB raw, against a limit of 100 MB (95.4 MiB). - The two new hook environments (ruff 26 MB, shellcheck-py 18 MB compressed, from a local build of the same hooks) push it past the limit. Re-gzipping the published layer and adding them gives about 113 MiB, about 124 MiB scaled to what the registry stores (my gzip -6 runs about 9% under the registry), against 95.4 MiB. - Most of that layer is not needed. pre-commit installs every main package of a Go hook repository, so next to the `gitleaks` and `actionlint` binaries the hooks call it leaves gitleaks' `config` (19 MB) and actionlint's `check-checks` and three `generate-*` tools (about 40 MB). The `.pre-commit-hooks.yaml` of both repositories names only `gitleaks` and `actionlint` as entries; nothing in this repository's workflows, scripts or docs references the others. ## Fix - After the existing cleanup of the Go toolchains, delete everything in each `golangenv-*/bin` except `gitleaks` and `actionlint`. The smoke test that runs all six hooks comes after it, so a wrongly deleted binary fails the image build, not the jobs. - Print the compressed size of `/opt/venv`, `/opt/python`, `/opt/collections` and `/opt/pre-commit` at the end of that step: the number the limit applies to. The old `du` lines stay for the per-environment view. - `ci` 0.2.16 -> 0.2.17 (`scripts/bump_image_versions.py`): the `bump` check requires a version above the 0.2.16 that is now in the matrix on `main`. 0.2.16 stays unpublished. - `docs/images/ci.md` describes the cleanup. ## Verified - I replicated the image's hook step locally with this repository's real `.pre-commit-config.yaml` (hooks installed into a scratch `PRE_COMMIT_HOME`, same cleanup, same six smoke hooks): the pre-commit home measures **226.8 MB** compressed with the toolchains, **89.9 MB** with them removed (what 0.2.16 pushed), **57.3 MB** with the unused binaries also pruned, in gzip -6 MiB. That is about 63 MiB scaled to the registry, a margin of roughly a third of the limit. All six hooks pass after pruning, and the surviving binaries are exactly `gitleaks` and `actionlint`. - The new `find ... -delete` expression was run on a fake tree and kept `gitleaks`, `actionlint` and the Python `ruff`, removing the rest. The new size-printing function was run under `dash` (the image build's `/bin/sh`). - `check_image_versions.py pins` and `bump origin/main` pass. ## Not verified - The image build itself and the push: they run only on `main`, never on a pull request, so the first real test is the merge. The local replication used this host's Python 3.13 where the image has 3.14, and a local Go toolchain download; sizes should be close, not identical. - Margin: ruff and shellcheck-py were measured from a local cache, not from the image's environments. ## Things to know - Each new hook environment adds 15 to 25 MB to this layer; the sizes the build now prints are the thing to read before adding one. - After the merge: `image.yml` builds `ci` 0.2.17 on `main`; the pin-follow PR then moves `lint.yml` and `build.yml` from 0.2.15 to it. Until then Lint on `main` runs on the old image and takes the install path, as in #121. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Claude added 1 commit 2026-11-14 15:15:09 +00:00
fix(images): prune the unused Go binaries from the ci image
Build / build (pull_request) Successful in 12s
Lint / lint (pull_request) Successful in 48s
Molecule / molecule (pull_request) Successful in 2s
cd5c2353fc
The push of ci 0.2.16 failed with 413 Payload Too Large from Cloudflare: its /opt/pre-commit layer, 75.5 MB compressed in 0.2.15, grew past the 100 MB limit with the ruff and shellcheck-py environments. About half of that layer was binaries no hook runs: pre-commit installs every main package of a Go hook repository, which leaves gitleaks' config and actionlint's check-checks and generate-* next to the gitleaks and actionlint binaries the hooks call.

Delete everything in each golangenv-*/bin except those two, before the smoke test that runs all six hooks, so a wrongly deleted binary fails the image build. Replicated locally with this repository's hook config: the pre-commit home goes from 89.9 MB to 57.3 MB compressed (gzip -6, about 9% under what the registry stores) and all six hooks still pass. The build now also prints the compressed size of each directory a later COPY turns into a layer, the figure the limit applies to.

ci 0.2.16 was never published (the push failed), so it is skipped: 0.2.16 -> 0.2.17, which the bump check requires because the matrix on main already says 0.2.16.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
Defame1297 merged commit c258a107fe into main 2026-11-14 15:17:49 +00:00
Defame1297 deleted branch ci/ci-image-prune-go-binaries 2026-11-14 15:17:49 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#123