Skip to content

perf(ci): build the Runner and MCP images in one bake job #4649

Done

Description

@dan-petty

Problem or Motivation

The mcp-server stage is FROM runner (Dockerfile:121). So each push builds the runner stage in two jobs (build means 140.5 s and 146.1 s, measured).

Saving: 1 job and about 1.5 runner-min per push (estimated).

Found by the CI and test audit of 2026-11-11. The account runs at most 20 hosted jobs at one time (measured), so each job that does no work makes the queue of each pull request longer.

Proposed Solution & Architectural Design

Risk: Low. Neither check is required.

Target Subsystem

SDLC, Git & PR Governance (.github/workflows/ci.yml).

Existing Tool Considered

docker buildx bake through the official docker/bake-action. No new tool to build. Cost: about 30,000 tokens and 2 hours.

Acceptance Criteria

  • One job per push builds both images.
  • The runner stage builds one time.
  • Both smoke tests and both scans run.

Dependencies

Depends on #4646.

Alternatives check of 2026-11-13: not-applicable.
Class: perf, no search.
Tool: none found.

Proposed design

Problem statement

The mcp-server stage is FROM runner (Dockerfile:161), so each push to a pull request builds the runner stage twice: once in the runner-image job and again in the mcp-server-image job. The change merges the two jobs into one job that builds both images with one docker/bake-action step, then runs both smoke tests and both Trivy scans. It removes one hosted job per push from an account that runs at most 20 at a time, so each pull request waits in a shorter queue.

Acceptance criteria

Requirement: One job builds both images

The workflow .github/workflows/ci.yml SHALL build the runner and mcp-server targets in one job.

Scenario: One image job for the two targets

  • WHEN a test reads the jobs of .github/workflows/ci.yml
  • THEN exactly one job builds the runner and mcp-server targets, and no other job builds either target

Requirement: One bake step holds both targets

The merged job MUST pass both targets to one docker/bake-action step.

Scenario: One bake step holds both targets

  • WHEN a test reads the steps of the merged job
  • THEN one docker/bake-action step lists the runner and mcp-server targets, and the job holds no docker/build-push-action step

Requirement: Both images load under their current tags

The bake step SHALL load the images devops-cli-runner:local and devops-cli-mcp-server:local.

Scenario: Smoke tests read the loaded images

  • WHEN the bake step ends
  • THEN the smoke test of each image runs against its loaded tag

Requirement: Both smoke tests run

The merged job MUST run the smoke test of the runner image and the smoke test of the mcp-server image.

Scenario: Both smoke tests in one job

  • WHEN an image input changed
  • THEN the job runs the runner smoke test and the MCP Server smoke test, and a failing test fails the job

Requirement: Both scans run with their ignore files

The merged job MUST scan each image with Trivy at the severity HIGH,CRITICAL and with the ignore files of that image.

Scenario: MCP Server scan keeps its ignore file

  • WHEN the job scans devops-cli-mcp-server:local
  • THEN the scan step sets trivyignores: .trivyignore,.trivyignore-mcp-server

Requirement: Each target rebuilds its own final stage

The bake definition MUST set no-cache-filter to runner on the runner target and to mcp-server on the mcp-server target.

Scenario: The apt-get upgrade layer is not reused

  • WHEN an earlier run cached the runner or mcp-server stage
  • THEN each target rebuilds its own final stage and reuses no layer of its apt-get upgrade

Requirement: The job skips when no image input changes

The merged job SHALL skip the bake, the smoke tests and the scans when no path of IMAGE_CONTENT_PATHS changes.

Scenario: Pull request with no image input change

  • WHEN a pull request changes no path of IMAGE_CONTENT_PATHS
  • THEN the job runs no bake, smoke-test or scan step and reports success

Requirement: The merged job sets a limit over its longest run

The merged job MUST set a timeout-minutes value of about two times its longest run, as the workflow comment asks.

Scenario: Job limit and step limits

  • WHEN a test reads the merged job
  • THEN the job sets timeout-minutes: 18, the bake step sets 12, and each smoke-test and scan step sets a shorter limit

Requirement: The required checks keep their names

The change MUST NOT rename the jobs Static Analysis and Tests & Coverage.

Scenario: The ruleset reads the two names

  • WHEN a test reads the job names of .github/workflows/ci.yml
  • THEN the jobs Static Analysis and Tests & Coverage keep their names

Requirement: The bake action is pinned

The docker/bake-action step MUST pin the action to a full commit SHA with a version comment, as every other action of the workflow.

Scenario: The bake step pins its action

  • WHEN a test reads the uses of the bake step
  • THEN the value is docker/bake-action@<40 hex characters> with a # v<version> comment

Requirement: The image invariants read the merged job

The tests that read the image jobs SHALL read the merged job.

Scenario: The image invariants run

  • WHEN the suite runs tests/invariants and tests/commands/test_ci.py
  • THEN no test names runner-image or mcp-server-image, and each asserts both targets, both smoke tests and both scans of the merged job

Existing Tool Considered

docker/bake-action, the official maintained Docker action for docker buildx bake, covers the need: one step builds both targets, loads both images, and keeps the cache options of the build. The alternatives check of 2026-11-13 gave not-applicable for a perf item, made no search and named no tool, so this answer rests on the issue's own choice of the action. The action is not yet used in this repository, so the change adds it pinned to a full commit SHA with a version comment, as docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 is pinned (.github/workflows/ci.yml:570). It lacks the smoke tests and the Trivy scans: those stay as steps of the same job. The change writes no tool of its own and no new code.

Key questions

  • Which jobs build the two images today?: The job runner-image (.github/workflows/ci.yml:513) builds the target runner with docker/build-push-action (.github/workflows/ci.yml:568-582), and the job mcp-server-image (.github/workflows/ci.yml:613) builds the target mcp-server with the same action (.github/workflows/ci.yml:668-680). Each job runs on its own runner, so each builds the shared runner stage. [sources: .github/workflows/ci.yml:513, .github/workflows/ci.yml:568, .github/workflows/ci.yml:613, .github/workflows/ci.yml:668]
  • Does the mcp-server stage build FROM the runner stage?: Yes. Dockerfile:161 is FROM runner AS mcp-server, and tests/invariants/test_mcp_server_image.py:36 asserts that the mcp-server stage inherits runner. The body's Dockerfile:121 is stale: line 121 installs the dev requirements, and the runner stage starts at Dockerfile:126. [sources: tests/invariants/test_mcp_server_image.py:36]
  • Does one bake build of both targets build the runner stage one time?: The merged job uses one docker/bake-action step with both targets, which is the form that resolves both targets against one Dockerfile and one build graph, so the parent stage of mcp-server (Dockerfile:161) is built by that one build. Two docker/build-push-action steps in one job would each start their own build, and since perf(ci): stop the cache export of pull request image builds #4646 the pull request jobs write no cache, so the second step would build the runner stage again. No measured run exists at this commit: the job-time check confirms the saving after the first run, and the offline test asserts the single bake step with both targets. (best practice) [sources: .github/workflows/ci.yml:568, .github/workflows/ci.yml:668, .github/workflows/ci.yml:474]
    • Chosen: One docker/bake-action step with both targets. Both targets are resolved against one Dockerfile and one build graph, so the shared runner stage is built by one build.
    • Rejected: Two docker/build-push-action steps in one job. Each step is its own build, and the pull request jobs write no cache (.github/workflows/ci.yml:474-478), so the second step builds the runner stage again.
    • Rejected: A matrix over the two images. Each matrix entry gets its own runner, which is exactly today's two jobs.
  • How does the merged job define the two bake targets?: The job writes an inline HCL definition in the files input of the docker/bake-action step, so the change stays in .github/workflows/ci.yml as the body scopes it. (best practice) [sources: .github/workflows/ci.yml:545]
    • Chosen: Inline HCL in the files input of docker/bake-action. The action writes the definition to a file of its own, so the change stays in the workflow file that the body names.
    • Rejected: A new docker-bake.hcl at the repository root. It adds a file that the issue does not name, and the body keeps the change to ci.yml.
    • Rejected: docker buildx bake in a run step. The step then writes and reads its own HCL file, and it loses the load and cache handling of the maintained action.
  • Which job id and name does the merged job take?: The merged job takes the id image-build and the name Container Images. Neither image check is required: ADR 0014 records that main requires Static Analysis, Tests & Coverage and Semantic PR title only, so a new check name breaks no ruleset. (best practice) [sources: docs/adr/0014-required-checks-gate-the-merge-and-the-pre-push-hook-runs-the-fast-static-checks.md:18, tests/invariants/test_workflow_contracts.py:1758, .github/workflows/ci.yml:40]
    • Chosen: Id image-build, name Container Images. The job builds two images, and no rule of main reads the old check names, so the name can say what the job does.
    • Rejected: Keep the id runner-image and the name Runner Image. The name would say that the job builds the runner image only, while it also builds and checks the MCP Server image.
    • Rejected: Two jobs that share a needs. It keeps two hosted jobs per push, which is the cost this item removes.
  • Does the Service image job join the bake job?: No. The change merges the runner and mcp-server targets only, as the issue scopes it. The Service image job builds another target with its own no-cache filter (.github/workflows/ci.yml:473) and shares no stage with the two image targets. (best practice) [sources: .github/workflows/ci.yml:407, .github/workflows/ci.yml:473]
    • Chosen: Merge the runner and mcp-server targets only. The saving of this item comes from the runner stage that the two targets share.
    • Rejected: Merge the Service image job too. It changes a job that the issue does not name, and its final stage runs apt-get upgrade with its own no-cache filter.
  • What timeout does the merged job set?: The job sets timeout-minutes: 18, the bake step sets 12, and each smoke-test and scan step sets a shorter limit. The two jobs ran 297 s and 331 s; the merged job drops one runner build of about 140 s, so its run is about 8 minutes, and 18 is about two times that, as the workflow comment asks. (best practice) [sources: .github/workflows/ci.yml:36, tests/invariants/test_workflow_contracts.py:55, tests/invariants/test_workflow_contracts.py:61]
    • Rejected: Keep timeout-minutes: 12. The merged job does the work of both jobs one after another, so a run near the old limit would be cut.
    • Chosen: Set timeout-minutes: 18. It is about two times the expected run of about 8 minutes, and the bake, smoke-test and scan steps stay under it.
    • Rejected: Set timeout-minutes: 24. It holds a hosted runner too long when the build hangs.
  • Does this item still need perf(ci): stop the cache export of pull request image builds #4646?: No. The image jobs of a pull request read the Actions cache with cache-from: type=gha and write none (.github/workflows/ci.yml:474-478, :582, :680), which is the change of perf(ci): stop the cache export of pull request image builds #4646, and that change folder is archived. [sources: openspec/changes/archive/2026-11-12-4646-stop-the-cache-export-of-pull/proposal.md, .github/workflows/ci.yml:474, .github/workflows/ci.yml:582]
  • Does the MCP Server scan use a different ignore file?: Yes. Its scan sets trivyignores: .trivyignore,.trivyignore-mcp-server (.github/workflows/ci.yml:702), and the runner scan sets no trivyignores (.github/workflows/ci.yml:600-609). [sources: .github/workflows/ci.yml:702, .github/workflows/ci.yml:600]
  • Does the merged job keep the release-pull-request skip?: Yes. Both jobs carry the same condition (.github/workflows/ci.yml:515-518, :615-618): they run for a pull_request or a workflow_dispatch and skip a release-please-- branch of this repository. The merged job keeps it, so the release pull request still runs only the required checks (.github/workflows/ci.yml:40-43). [sources: .github/workflows/ci.yml:515, .github/workflows/ci.yml:615, .github/workflows/ci.yml:40]
  • Which invariant tests read the image jobs of .github/workflows/ci.yml?: tests/invariants/test_workflow_contracts.py:55-72 pins the timeout-minutes of the jobs runner-image and mcp-server-image; :581-599 lists the Trivy scan steps of both jobs. tests/invariants/test_runner_image.py:193-259 reads the runner-image job of ci.yml (build, smoke test, size bound). tests/invariants/test_mcp_server_image.py:79-96 and :149-164 read the mcp-server-image job (build, scan, smoke test). tests/invariants/test_architectural_invariants.py:671-699 parametrizes the job ids service-image, runner-image and mcp-server-image over the IMAGE_CONTENT_PATHS filter. tests/commands/test_ci.py:970-1000 requires the job id runner-image and no needs on it, and :2302-2321 allowlists the run steps of both jobs. Each of these reads the merged job after the change. [sources: tests/invariants/test_workflow_contracts.py:55, tests/invariants/test_workflow_contracts.py:581, tests/invariants/test_runner_image.py:193, tests/invariants/test_mcp_server_image.py:79, tests/invariants/test_architectural_invariants.py:671, tests/commands/test_ci.py:970, tests/commands/test_ci.py:2302]
  • How is docker/bake-action pinned?: To a full commit SHA with a version comment, as every action of the workflow is pinned, for example docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0. The project's actionlint guidance states the same rule, and Renovate updates the pinned digest. (best practice) [sources: .github/workflows/ci.yml:570, src/devops_cli/ai/knowledge_base/it_domains/tools/actionlint.md:61]
    • Chosen: Pin the action to a full commit SHA with a version comment. Every action of the workflow is pinned this way, and the project's actionlint guidance requires an immutable SHA rather than a tag.
    • Rejected: Use a version tag such as docker/bake-action@v6. A tag moves, and it breaks the pin rule that the workflow and the guidance hold.
    • Rejected: Run docker buildx bake in a run step. The issue names the official action, which keeps the build options and the image load in one place.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/infra
    scope/ci
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  2. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/infra. The perf prefix of the title gives the type.
    • Scope: scope/ci. The (ci) scope of the title gives the scope.
    • Priority: P2-Medium. It saves about 1.5 runner-min per push but does not block delivery or fix a failure.
    • Value: Medium. It shortens the PR queue for all contributors by removing one redundant build job.
    • Effort: Low. The body states the cost is about 30,000 tokens and 2 hours, with low risk.
    • Related: perf(ci): stop the cache export of pull request image builds #4646, which asks for a different change. Both target CI image build cost in ci.yml, but #4646 stops cache exports while this candidate merges two jobs into one bake.
  3. added
    priority/p2-medium
    on Nov 11, 2026
  4. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: perf. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-13. A person decides what this means for the item. The check changes no label and closes no issue.

  5. added
    status/ready
    and removed
    status/new
    on Nov 14, 2026
  6. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 0410772 (see proposed design in issue body).

  7. dan-petty commented on Nov 19, 2026

    @dan-petty
    OwnerAuthor

    Later measure. Owner decision of 2026-11-19: the MCP server image stays on python:3.14-slim-trixie, so after #4361 it no longer builds FROM runner, and the MCP job no longer repeats the runner build. After #4361 merges, measure the builds again. If one bake call saves less than about 20 s of runner time and the cache space is not short, close this item as not planned with the numbers. Today the build medians are Service 96 s, Runner 107 s and MCP 118 s.

  8. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    Measurement input from #6513 (#4361, the runner image FROM devtools). The runner image grows from 2.4 GB to 6.4 GB. Two cold CI runs of the Runner Image job took 4:15 and 6:27 (mean 5:21). Most of the time is in two steps whose time changes with the runner: the export of the image into Docker for load: true (69 s and 112 s) and the Trivy scan of the loaded image (67 s and 96 s). The venv steps take about 30 s, so a cache from main saves little. The MCP server image no longer builds on the runner, so its job does not repeat the runner build. The step table is in #6513 (comment).

  9. added
    owner/service
    on Nov 24, 2026
  10. 30 remaining items

  11. added
    status/planned
    on Nov 24, 2026
  12. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    Cleared the stop at job by the rule continue: the runner Job devops-cli-implement-devops-cli-4649-6b3347 ended without a result. The class ci_infra of the stop is one that a new attempt can fix. This is continuation 2 of 4 for this item. The item is Planned again. The Service takes it in the next round. The new Job takes the branch from origin, so it keeps the work that the run pushed there.

  13. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    Stopped at pull request.

    Failure class: ci_infra.
    Action taken: none.
    Action left: retry: run the item again.

    Reason:

    The check Runner Image of the draft pull request #7006 failed or was cancelled, and no fix-checks Job repairs it.

    The item is Blocked: the implement Job ended at the draft, and no fix-checks Job takes this case. Fix the cause. Then comment implement: retry.

  14. added
    status/blocked
    status/planned
    and removed
    status/planned
    status/blocked
    on Nov 24, 2026
  15. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    Cleared the stop at pull request by the rule digest: the runner image changed since the stop, from sha256:7492c2a9d21e71a7eaec25710fcae6dec3ba3e53f71ad091733233b1a0c9c981 to sha256:f4ad8b448fc37a88732fe8a0a43d5e6c33584ae7fd7136ab556fe1dbbf3eea23, and the class ci_infra of the stop is one that a new attempt can fix. The item is Planned again, and the Service takes it in the next round. The Service clears at most 2 for each class and 6 for each item by digest. A stop of another class, a new stop on this image, and a stop over a limit wait for a comment implement: retry.

  16. added
    status/in-review
    and removed
    status/planned
    on Nov 24, 2026
  17. removed
    status/in-review
    on Nov 24, 2026
  18. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor
  19. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-24 20:09 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/cisource/agenttype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions