feat(image): build a CI image with the lint and build tooling baked in #3

Merged
Defame1297 merged 2 commits from feat/ci-image into main 2026-10-25 10:49:49 +00:00
Owner

Why

Lint and Build install OS packages, the pinned Python tools and every pre-commit hook environment on each run (PR #1: Lint 86s, Build 50s, of which the Go toolchain download for gitleaks/actionlint alone was ~47s). This bakes them into git.rkdr.net/mortis/ci.

What

  • images/ci/Dockerfile, multi-stage (os → build → final):
    • build: venv from requirements-dev.txt; Python 3.11 and 3.13 via uv (pinned uv==0.13.5; they make ansible-test sanity run its compile test instead of skipping it); pre-commit install-hooks from .pre-commit-config.yaml, then a yamllint run to prove the cache works. uv, pip caches and the Go build cache stay in the build stage.
    • final: base packages (git, shellcheck, python3, ca-certificates) + COPY --from=build of /opt/venv, /opt/python, /opt/pre-commit. Each is its own layer (Cloudflare caps a pushed layer at 100 MB).
    • /opt/ci-pins.sha256 records the checksums of the two pin files. A job can run sha256sum -c /opt/ci-pins.sha256 in its checkout and fall back to installing at run time when a PR changes a pin (PRs cannot build images).
  • image.yml: matrix over both images (max-parallel: 1), molecule-ubuntu2404 unchanged (sub-path context), ci with the repo root as context. Also triggers on requirements-dev.txt / .pre-commit-config.yaml changes.

Not in this PR

Nothing consumes the image yet. After merge image.yml builds it on main; that run shows the real layer sizes (the build stage prints them too) and the digest. A follow-up PR switches lint.yml / build.yml to that digest, with the drift fallback. Not baked yet: the ansible-test sanity --requirements per-test virtualenvs (about 25s of Build), which need a stub-collection prewarm; to be measured first.

Risks (unverifiable without a build)

  • A layer over 100 MB fails the push with 413. Most likely the pre-commit cache (Go toolchain). Fallback: delete the toolchain/module cache from the hook environments in the build stage.
  • pre-commit install-hooks in a kaniko RUN under Docker's default seccomp on the runner; the job container has a memory cap.
  • A failed build changes nothing in use: the molecule image is built first and the workflows still use ubuntu:24.04.

🤖 Generated with Claude Code

## Why Lint and Build install OS packages, the pinned Python tools and every pre-commit hook environment on each run (PR #1: Lint 86s, Build 50s, of which the Go toolchain download for gitleaks/actionlint alone was ~47s). This bakes them into `git.rkdr.net/mortis/ci`. ## What - `images/ci/Dockerfile`, multi-stage (`os` → `build` → `final`): - **build**: venv from `requirements-dev.txt`; Python 3.11 and 3.13 via uv (pinned `uv==0.13.5`; they make `ansible-test sanity` run its compile test instead of skipping it); `pre-commit install-hooks` from `.pre-commit-config.yaml`, then a `yamllint` run to prove the cache works. uv, pip caches and the Go build cache stay in the build stage. - **final**: base packages (git, shellcheck, python3, ca-certificates) + `COPY --from=build` of `/opt/venv`, `/opt/python`, `/opt/pre-commit`. Each is its own layer (Cloudflare caps a pushed layer at 100 MB). - `/opt/ci-pins.sha256` records the checksums of the two pin files. A job can run `sha256sum -c /opt/ci-pins.sha256` in its checkout and fall back to installing at run time when a PR changes a pin (PRs cannot build images). - `image.yml`: matrix over both images (`max-parallel: 1`), `molecule-ubuntu2404` unchanged (sub-path context), `ci` with the repo root as context. Also triggers on `requirements-dev.txt` / `.pre-commit-config.yaml` changes. ## Not in this PR Nothing consumes the image yet. After merge `image.yml` builds it on `main`; that run shows the real layer sizes (the build stage prints them too) and the digest. A follow-up PR switches `lint.yml` / `build.yml` to that digest, with the drift fallback. Not baked yet: the `ansible-test sanity --requirements` per-test virtualenvs (about 25s of Build), which need a stub-collection prewarm; to be measured first. ## Risks (unverifiable without a build) - A layer over 100 MB fails the push with 413. Most likely the pre-commit cache (Go toolchain). Fallback: delete the toolchain/module cache from the hook environments in the build stage. - `pre-commit install-hooks` in a kaniko `RUN` under Docker's default seccomp on the runner; the job container has a memory cap. - A failed build changes nothing in use: the molecule image is built first and the workflows still use `ubuntu:24.04`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Claude added 2 commits 2026-10-25 10:47:20 +00:00
Lint and Build install OS packages, the pinned Python tools and every
pre-commit hook environment on each run (about 40s of the 50 to 86s). Bake
them into git.rkdr.net/mortis/ci instead:

- images/ci/Dockerfile, multi-stage: the build stage creates the venv from
  requirements-dev.txt, installs Python 3.11 and 3.13 (uv, for the ansible-test
  compile check that is skipped today) and runs `pre-commit install-hooks`
  from .pre-commit-config.yaml; the final stage copies only the results.
  Several layers, each meant to stay below Cloudflare's 100 MB request limit.
- The image records the sha256 of the two pin files it was built from
  (/opt/ci-pins.sha256) so a job can detect drift and fall back to
  installing at run time.
- image.yml builds both images in a matrix (molecule-ubuntu2404 unchanged,
  ci with the repository root as build context) and also runs when the pin
  files change.

Nothing consumes the image yet: the workflows switch to its digest in a
follow-up once the first build has shown the real layer sizes.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
feat(image): build the ci image next to the molecule image
Lint / lint (pull_request) Successful in 1m23s
Build / build (pull_request) Successful in 50s
98ca27bbc0
Matrix over both images. molecule-ubuntu2404 keeps its sub-path context;
ci uses the repository root as context (its Dockerfile copies the pin
files) and also rebuilds when requirements-dev.txt or
.pre-commit-config.yaml change.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
Defame1297 merged commit 2684378925 into main 2026-10-25 10:49:49 +00:00
Defame1297 deleted branch feat/ci-image 2026-10-25 10:49: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#3