Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-11-24
skip_specs: true
34 changes: 34 additions & 0 deletions openspec/changes/4649-build-the-runner-and-mcp-images/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Design

## Decisions

- **Merge the jobs `runner-image` and `mcp-server-image` of `.github/workflows/ci.yml` into one job that builds both targets with one `docker/bake-action` step.**: The issue asks for one job and one bake call, and the account runs at most 20 hosted jobs at one time; since #4361 the `mcp-server` target builds on the Service chain, so the merge removes one hosted job and the setup it repeats.
- **Write the bake definition to `docker-bake.hcl` in a step before `docker/bake-action` in `.github/workflows/ci.yml`.**: `docker/bake-action` expects file paths in `files`, not inline HCL. Writing the file dynamically in the job keeps the change in `.github/workflows/ci.yml`, commits no static bake file to git, and expands `${{ github.repository }}`.
- **Keep the id `mcp-server-image` and the name `Runner Image` on the merged job.**: The requirement `The release gate equals the pull request gate` of `openspec/specs/mcp-server-image/spec.md` names job `mcp-server-image` of `ci.yml`, and the requirement `The scan of the runner image reports and stops no build` of `roadmap-implement-runner` names the Runner Image job of `ci.yml`; a new id or name makes one of them false and needs a spec delta that the paths of this change cannot carry.
- **Keep the `cache-from` ref of each target in `.github/workflows/ci.yml`, inside the generated HCL, as `cache-from = ["type=registry,ref=ghcr.io/${{ github.repository }}/runner:buildcache"]` and its `mcp-server` sibling.**: The requirement `Each image build keeps its own registry cache` of `container-image-layers` asks for that ref of each target and bans `type=gha`; the step text sits in the workflow, so the `${{ github.repository }}` expression expands and no literal repository path is written.
- **Set `no-cache-filter` on the `mcp-server` target only.**: `Dockerfile:179:RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/*` is the final stage of `mcp-server`, and the runner stage runs no upgrade of its own, as `docs/CLUSTER.md:76:the runner runs no` says.
- **Set `timeout-minutes: 18` on the merged job, 12 on the bake step and 4 on each scan step.**: The Runner Image job took 4:15 and 6:27 cold (comment 5) and the MCP server build's median is 118 s (comment 4), so the merged job runs about 9 minutes; `.github/workflows/ci.yml:36:# Each job limit is about two times the longest run of the job, and 5 minutes at least, so a hung` asks for about two times, and `tests/invariants/test_workflow_contracts.py:95:def test_every_job_has_a_limit_and_each_step_limit_is_under_it` refuses a step limit that is not under its job's.
- **Keep the runner smoke test, the runner scan, the MCP server smoke test and the MCP server scan unchanged in the merged job, with their scripts, the categories `trivy-image-runner` and `trivy-image-mcp-server`, and exit code 0 for the runner scan.**: The base requirements hold the runner smoke text equal to the release's, the MCP smoke text equal to the release's, the two categories and the runner exit code 0, so a changed text, category or exit code would make one of them false.
- **Keep one `Detect Image Content Changes` step with the same `IMAGE_CONTENT_PATHS` list in the merged job.**: `tests/invariants/test_architectural_invariants.py:689:def test_image_path_filter_covers_dockerfile_sources` requires the filter of the image job to cover every path that the `Dockerfile` copies, and both targets build from that one `Dockerfile`.
- **Update `tests/invariants/test_runner_image.py`, `tests/invariants/test_mcp_server_image.py`, `tests/invariants/test_architectural_invariants.py` and the run-step allowlist of `tests/commands/test_ci.py` to read the merged job.**: `tests/invariants/test_runner_image.py:36:job = _workflow("ci.yml")["jobs"]["runner-image"]` reads the deleted job, `tests/invariants/test_mcp_server_image.py:30` reads the step `Build and Load MCP Server Image`, and `tests/commands/test_ci.py:1775:allowlist: dict[tuple[str, str], str] = {` refuses a run step that its allowlist does not name.
- **Plan no spec delta.**: The change edits a workflow and tests, and each base requirement that the workflow serves stays true with the kept id, name, smoke texts, categories, exit code and cache ref, so no requirement text changes.

## Rejected alternatives

- **Keep the two `docker/build-push-action` steps and put them in one job.**: `.github/workflows/ci.yml:599:uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc` and `.github/workflows/ci.yml:704:target: mcp-server` show one build per step, so the shared build graph of one bake call is lost, and the issue names `docker buildx bake`.
- **A matrix over the two images.**: `.github/workflows/ci.yml:539:runner-image:` and `.github/workflows/ci.yml:640:mcp-server-image:` are one hosted job each today; a matrix entry gets its own runner, so it removes no hosted job.
- **Commit a static `docker-bake.hcl` at the repository root.**: A static file cannot expand the `${{ github.repository }}` expression directly and widens the change to a path that the issue does not name.
- **Run `docker buildx bake` in a `run` step of the job.**: `tests/commands/test_ci.py:1775:allowlist: dict[tuple[str, str], str] = {` refuses a run step that the allowlist does not name, and a run step loses the load and cache handling of the action.
- **Rename the merged job to the id `image-build` with the name `Container Images`.**: The requirements `The release gate equals the pull request gate` of `openspec/specs/mcp-server-image/spec.md` and `The scan of the runner image reports and stops no build` of `roadmap-implement-runner` name the job `mcp-server-image` and the Runner Image job of `ci.yml`, so a new id and name would make both false.
- **Merge the Service image job into the same job.**: `.github/workflows/ci.yml:504:no-cache-filters: service` shows that the Service target has its own final stage that runs `apt-get upgrade`, and the issue scopes the merge to the `runner` and `mcp-server` targets.
- **Keep `timeout-minutes: 12` on the merged job, or raise it to 24.**: `.github/workflows/ci.yml:546:timeout-minutes: 12` is the limit of the runner job, whose longest cold run was 6:27; the merged job runs the work of both, and 24 holds a runner twice as long as that run when a build hangs.
- **Pin `docker/bake-action` by a version tag such as `docker/bake-action@v8`.**: `tests/invariants/test_workflow_contracts.py:519:def test_every_remote_action_is_pinned_to_a_commit_sha` refuses a remote action that no 40-character commit SHA pins.
- **Set `no-cache-filter` on the `runner` target too.**: `Dockerfile:79:through Renovate, so the runner runs no` shows that the runner stage runs no `apt-get upgrade` of its own, so it has no final stage that a cached layer would keep stale.
- **Write the cache ref as a literal repository path, such as `ghcr.io/dan-petty/devops-cli/runner:buildcache`.**: The requirement `Each image build keeps its own registry cache` of `container-image-layers` names `ghcr.io/${{ github.repository }}/<target>:buildcache`, and the workflow step expands that expression, so the ref keeps its form and no literal path is written.
- **Keep two jobs and join them with a shared `needs`.**: `.github/workflows/ci.yml:539:runner-image:` and `.github/workflows/ci.yml:640:mcp-server-image:` are two hosted jobs today, so a shared `needs` keeps both runners per push, which is the cost this item removes.

## Unchanged references

- `openspec/specs/mcp-server-image/spec.md` (job id in a requirement): The merged job keeps the id `mcp-server-image`, the MCP server smoke text and the category `trivy-image-mcp-server`, so the requirements `The release gate equals the pull request gate` and `MCP server image gate` stay true.
- `openspec/specs/roadmap-implement-runner/spec.md` (job name in a requirement): The merged job keeps the name `Runner Image`, the runner smoke text, the action `.github/actions/image-scan`, exit code 0 and the category `trivy-image-runner`.
- `docs/CLUSTER.md` (job name and cache form in a document): The Runner Image job still scans the runner image with exit code 0, the runner target still sets no `no-cache-filter`, and each target still reads the registry cache of its own name.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Proposal

## Why

Each push runs two hosted image jobs of `.github/workflows/ci.yml` that build one image each, and #4649 asks for one job that builds both images with one bake call. The account runs at most 20 hosted jobs at one time, so the job that the merge removes shortens the queue of every pull request. At the staged commit `mcp-server` builds on the Service chain, so the merge removes one hosted job and the setup it repeats, not the repeated runner build that the issue names.

## What Changes

- The jobs `runner-image` and `mcp-server-image` of `.github/workflows/ci.yml` become one job, with the id `mcp-server-image` and the name `Runner Image`, so one push starts one hosted image job.
- A step writes `docker-bake.hcl` with targets `runner` and `mcp-server`. One `docker/bake-action` step replaces the two `docker/build-push-action` steps, pinned to a full 40-character commit SHA with a version comment.
- Each target keeps its local tag and its `cache-from` of `type=registry,ref=ghcr.io/${{ github.repository }}/<target>:buildcache` inside the workflow, with no literal repository path and no `type=gha` entry, and the `mcp-server` target keeps `no-cache-filter = ["mcp-server"]`.
- The merged job runs both smoke tests and both scans, with the categories `trivy-image-runner` and `trivy-image-mcp-server`, and the runner scan keeps `exit-code: "0"`.
- The merged job sets `timeout-minutes: 18`, the bake step 12 and each scan step 4.
- `tests/invariants/test_runner_image.py`, `tests/invariants/test_mcp_server_image.py`, `tests/invariants/test_architectural_invariants.py` and the run-step allowlist of `tests/commands/test_ci.py` read the merged job.
- The change carries no spec delta: it edits a workflow and its tests, and every base requirement that names the job, its smoke tests, its scans and its registry cache stays true, because the cache ref of each target stays in `.github/workflows/ci.yml` with the `${{ github.repository }}` expression.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

None.

## Impact

- Code: `.github/workflows/ci.yml`
- Tests: `tests/invariants/test_runner_image.py`, `tests/invariants/test_mcp_server_image.py`, `tests/invariants/test_architectural_invariants.py`, `tests/commands/test_ci.py`

## Feasibility

- The `probes` say, word for word: The path `.github/workflows/ci.yml` is a file of the staging commit. The path `docker-bake.hcl` is no file of the staging commit. No commit in the history deleted or renamed it. The plan edits the workflow and creates no file.
- The premise of the issue is false at the staged commit: the body calls the `mcp-server` stage a child of `runner` at `Dockerfile:121`, and `Dockerfile:177:FROM mcp-server-deps AS mcp-server` builds it on the Service chain, which `Dockerfile:170:FROM service-deps AS mcp-server-deps` starts, while the runner chain starts at `Dockerfile:82:FROM devtools AS runner-deps`.
- Comment 4 of the owner, 2026-11-19, says the MCP server image stays on `python:3.14-slim-trixie`, so after #4361 it no longer builds FROM runner and its job no longer repeats the runner build; comment 5 gives two cold runs of the Runner Image job of 4:15 and 6:27, most of it in the `load: true` export and the Trivy scan. The plan therefore claims one hosted job and the setup it repeats, and no repeated runner build.
- The `false_premise` finding is fixed: `docker/bake-action` requires a bake file path in `files`. A workflow step writes `docker-bake.hcl` before the bake step, so the change stays in `.github/workflows/ci.yml` and commits no static bake file to git.
- The `spec_delta_wrong` finding is fixed: the `cache-from` of each target stays in `.github/workflows/ci.yml` in the generated bake file. The `${{ github.repository }}` expression and the `:buildcache` tag stay in the workflow, and no literal repository path is written; the requirement `Each image build keeps its own registry cache` of `container-image-layers` asks for that ref and no `type=gha`, and `docs/CLUSTER.md:76:Each image build reads the registry cache of its target` states the same form.
- The action documentation check is verified: `docker/bake-action` splits `files` by newline or comma into file paths and passes `--file` flags to `docker buildx bake`. It does not accept inline HCL text in `files`. Writing `docker-bake.hcl` in a step gives the action a valid file path.
- `read_file` on `.github/workflows/ci.yml` lines 495 to 760 showed the two jobs at `.github/workflows/ci.yml:539:runner-image:` and `.github/workflows/ci.yml:640:mcp-server-image:`, the two builds at `.github/workflows/ci.yml:599:uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc` with `.github/workflows/ci.yml:603:target: runner` and `.github/workflows/ci.yml:704:target: mcp-server`, and the MCP cache filter at `.github/workflows/ci.yml:708:no-cache-filters: mcp-server`.
- The same call showed the two cache lines at `.github/workflows/ci.yml:608:cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/runner:buildcache` and `.github/workflows/ci.yml:710:cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/mcp-server:buildcache`, both smoke tests by their bounds at `.github/workflows/ci.yml:620:if [ "$size" -gt 7000000000 ]` and `.github/workflows/ci.yml:722:if [ "$size" -gt 3000000000 ]`, the two scans at `.github/workflows/ci.yml:632:category: trivy-image-runner` with `.github/workflows/ci.yml:636:exit-code: "0"` and `.github/workflows/ci.yml:730:category: trivy-image-mcp-server`, and the pull request cache rule at `.github/workflows/ci.yml:506:write none: the release is the one writer of the tag (#4646)`.
- The job limit rule is at `.github/workflows/ci.yml:36:# Each job limit is about two times the longest run of the job, and 5 minutes at least, so a hung`, and `tests/invariants/test_workflow_contracts.py:95:def test_every_job_has_a_limit_and_each_step_limit_is_under_it` refuses a step limit that is not under its job's.
- The tests that read the two jobs are `tests/invariants/test_runner_image.py:36:job = _workflow("ci.yml")["jobs"]["runner-image"]`, `tests/invariants/test_mcp_server_image.py:29:job = _workflow("ci.yml")["jobs"]["mcp-server-image"]` and the parameter `tests/invariants/test_architectural_invariants.py:685:("runner-image", "Dockerfile"),`, and the run-step allowlist is `tests/commands/test_ci.py:1775:allowlist: dict[tuple[str, str], str] = {`, which holds `tests/commands/test_ci.py:1786:("runner-image", "Run Runner Image Smoke Test"): "Docker container tool smoke tests",`.
- The `references` call for `runner-image` answered `files 22, lines 24`, and the four paths outside `openspec/changes/archive/` are `.github/workflows/ci.yml`, `tests/commands/test_ci.py`, `tests/invariants/test_architectural_invariants.py` and `tests/invariants/test_runner_image.py`, which are the changes of groups 1 to 3; the 18 archived files stay unchanged, because an archived change is a record.
- The `references` call for `mcp-server-image` answered `files 26, lines 36`, and the five paths outside `openspec/changes/archive/` are those four and `openspec/specs/mcp-server-image/spec.md`, which decision 3 covers; the 21 archived files stay unchanged, for the same reason.
- The base specs stay true: the merged job keeps the id `mcp-server-image`, which the requirement `The release gate equals the pull request gate` of `openspec/specs/mcp-server-image/spec.md` names, and the name `Runner Image`, which the requirement `The scan of the runner image reports and stops no build` of `openspec/specs/roadmap-implement-runner/spec.md` names, and it keeps both smoke texts, both categories and `exit-code: "0"`.
- The `no-cache-filter` of `mcp-server` rests on `Dockerfile:179:RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/*`, and the runner stage runs no upgrade of its own, as `docs/CLUSTER.md:76:the runner runs no` and `Dockerfile:79:through Renovate, so the runner runs no` say, so the runner target sets no `no-cache-filter`.
- The plan calls no function; the implement step resolves the 40-character commit SHA of `docker/bake-action` with a network read of the GitHub API, which is a precondition of that step and of no group command.
- The verify programs are `uv run devops ci --check --only actionlint,zizmor` and `uv run devops ci test tests/invariants`, which run `uv`, `devops`, `pytest`, `actionlint` and `zizmor`: each is a runner tool of the image, none is `NOT_IN_RUNNER`, the plan introduces no program, and a failing row stops the step with the failure class `test`; the pod runs with `readOnlyRootFilesystem: true`, `runAsNonRoot: true`, `capabilities.drop: ALL`, `allowPrivilegeEscalation: false` and `seccompProfile: RuntimeDefault`.
- The workflow steps run on a GitHub-hosted runner and need `docker` and `docker buildx`, which are `NOT_IN_RUNNER` for the pod, so no group command builds an image.
- The first checks against the real system: `uv run devops ci --check --only actionlint,zizmor` parses and lints the edited workflow; `uv run devops ci test tests/invariants` and `uv run devops ci test tests/commands/test_ci.py` read the job ids, the step names and the run steps of `.github/workflows/ci.yml`; and after the merge `gh api repos/dan-petty/devops-cli/actions/runs/<run-id>/jobs --jq '.jobs[] | [.name, .started_at, .completed_at]'` gives the run of the merged job.
- The dependency #4646 is delivered: `.github/workflows/ci.yml:506:write none: the release is the one writer of the tag (#4646)` shows that the pull request jobs write no cache, so the merged job reads the registry cache of each target and writes none.

## Existing Tool Considered

The official, maintained Docker action `docker/bake-action` covers the need: one step resolves the `runner` and `mcp-server` targets of one `Dockerfile` in one build graph, loads both images, and keeps each target's tags, `cache-from` and `no-cache-filter` in the workflow. The repository pins no other action for a bake, and `docker/build-push-action` stays in the Service image job and in the release. The change writes no tool of its own and no new code.

## Dependencies

- #4646: it stopped the cache export of the pull request image jobs and its change is archived, so the merged job reads the registry cache of each target with `cache-from` and writes none, and the release stays the one writer of the cache.
Loading