Repository navigation
Description
Problem or Motivation
Dockerfile:16-17 copies src/ before uv sync (Dockerfile:20), and the Service stage copies the whole venv in one layer (Dockerfile:154). So each release changes about 0.5 GB of layers, and each node pulls them again. About 15 releases a day.
Measured on 2026-11-11: 5 of 7 runner Jobs pulled the image for 51 to 56 s. The first uv child of an implement Job takes 30 to 101 s with an empty uv cache. The median from runner Job create to the first gateway call is 204 s. More short pods come with the move of the roadmap jobs, so the pull time grows in importance.
Proposed Solution & Architectural Design
- In the
builderstage:COPY pyproject.toml uv.lock, thenuv sync --locked --no-dev --no-install-project, thenCOPY src/, thenuv sync --locked --no-dev --no-editable(https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers). - In the
serviceandrunnerstages: copy the dependency site-packages and the project in separate layers, so a change ofsrc/changes only the project layer. - The runner image keeps the wheels of
uv.lockin a directory, andUV_FIND_LINKSnames it, so the firstuvchild of an implement Job reads local files. State the image growth in the pull request. - Coordinate with build(docker): build the runner image FROM devtools with no tool install #4361 (the root Dockerfile and CI install tools with native steps), which changes the same file.
Target Subsystem
Kubernetes & Minikube Automation (container image: Dockerfile).
Existing Tool Considered
uv's documented intermediate-layer pattern and --find-links. A pre-pull DaemonSet treats the symptom (about 50 GB a day from the registry for 2 images, 3 nodes and 15 releases); it comes only if a pull stays over 10 s after this item. Cost: about 40,000 tokens and 2 hours to build, about 2,000 tokens a month to keep, about 5,000 tokens to fix.
Acceptance Criteria
- Two image builds with a change in
src/only differ in layers of under 50 MB together (crane manifestlayer sizes, or the build output). - The image runs
devops --versionand the test suite as before; the entry points still work. - A live runner Job on a node that holds the previous release starts its container in 10 s or less.
- Measure after 7 days: runner Job create to container start, median, 10 s or less; first
uvchild of an implement Job under 30 s.
Dependencies
None.
Source: #4517
Proposed design
Problem statement
Dockerfile:16-17 copies pyproject.toml, uv.lock and src/ before uv sync at Dockerfile:20, and the service stage copies the whole virtual environment in one layer (Dockerfile:154). Each release therefore changes about 0.5 GB of layers, and each node pulls them again at about 15 releases a day. The first uv child of an implement Job also starts with an empty uv cache, because the Job's cache is on its home volume (Dockerfile:100). This change puts the dependencies and the project in separate layers, and keeps the locked wheels in the runner image, so a source-only release changes only a small project layer and the first uv child reads local files.
Acceptance criteria
Requirement: Builder dependency layer
The builder stage SHALL install the locked runtime dependencies in a layer before it copies src/, and SHALL install the project in a later layer.
Scenario: Builder instruction order
- WHEN a test reads the
builderstage ofDockerfile - THEN
uv sync --locked --no-dev --no-install-projectprecedesCOPY src/, anduv sync --locked --no-dev --no-editablefollows it.
Requirement: Service dependency layer
The service stage SHALL copy the dependency-only virtual environment from the deps stage in one layer.
Scenario: Service dependency source
- WHEN a test reads the
servicestage ofDockerfile - THEN the
COPYof/app/.venvnames--from=deps, and noCOPYof the whole/app/.venvnames--from=builder.
Requirement: Service project layer
The service stage SHALL copy the project's package, its distribution metadata and its console script from the builder stage in layers after the dependency layer.
Scenario: Service project files
- WHEN a test reads the
servicestage ofDockerfile - THEN a
COPYfrombuilderputsdevops_cli*under/app/.venv/lib/python3.14/site-packagesanddevopsunder/app/.venv/bin, after the/app/.venvcopy fromdeps.
Requirement: Runner project layer
The runner stage SHALL install the dev dependencies with --no-install-project in one layer and SHALL install the project with --no-editable in a later layer after COPY src/.
Scenario: Runner instruction order
- WHEN a test reads the
runnerstage ofDockerfile - THEN the
uv syncthat holds--no-install-projectprecedesCOPY src/, and theuv sync --locked --no-editablefollows it.
Requirement: Runner wheel directory
The runner stage SHALL keep the wheels of the locked runtime and dev dependencies in one directory and SHALL set UV_FIND_LINKS to that directory.
Scenario: Local wheel lookup
- WHEN a test reads the
runnerstage ofDockerfile - THEN the stage writes the wheels to a directory, and an
ENVinstruction setsUV_FIND_LINKSto it.
Requirement: Image checks
The change SHALL keep the image smoke tests, the tool check and the Service test suite in the image jobs of ci.yml, with the 3000000000-byte bound of the runner image.
Scenario: Image job steps
- WHEN a test reads
.github/workflows/ci.yml - THEN the
service-image,service-image-testandrunner-imagejobs still rundevops --version,devops_cli.roadmap.runner_toolsand the test suite, and the runner size check still fails above 3000000000 bytes.
Existing Tool Considered
No alternatives check has run. The open, maintained tool is uv's documented Docker integration: intermediate layers separate the dependency install from the project install, and UV_FIND_LINKS gives uv a local wheel directory. It lacks a pre-pull image cache. A pre-pull DaemonSet is out of this item and comes only if a live pull stays over 10 s; its written cost is about 40,000 tokens and 2 hours to build, about 2,000 tokens a month to keep, and about 5,000 tokens to fix. The wheel directory needs uv export plus pip's pip download, because pip is in the builder base image and the runner deletes it (Dockerfile:84-85).
Key questions
- Which Docker layer pattern should the builder stage use?: Use uv's documented intermediate-layer pattern (guide fetched 2026-11-11): copy
pyproject.tomlanduv.lock, runuv sync --locked --no-dev --no-install-project, copysrc/, then runuv sync --locked --no-dev --no-editable. (best practice) [sources: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers]- Chosen: uv intermediate layers. The documented pattern keeps the dependency layer stable when only
src/changes. - Rejected: One
uv syncafterCOPY src/. It invalidates the dependency layer on every source change, which is the currentDockerfile:17-20. - Rejected: Pre-pull DaemonSet. It treats the symptom and waits on a live pull over 10 s.
- Chosen: uv intermediate layers. The documented pattern keeps the dependency layer stable when only
- How should the service and runner stages split dependency and project layers?: Add a
depsstage that copiespyproject.tomlanduv.lockand runsuv sync --locked --no-dev --no-install-project; thebuilderstage builds on it and installs the project withuv sync --locked --no-dev --no-editable. The service stage copies/app/.venvfromdeps, then copiesdevops_cli*(package and dist-info) andbin/devopsfrombuilder; the project stays under/app/.venvbecause the Service test asserts thatdevops_cli.__file__starts with/app/.venv/(ci.yml:653) and the Service image holds no uv (ci.yml:516). The runner stage builds onbuilder(Dockerfile:65) and has no venvCOPY: it installs the dev dependencies withuv sync --locked --no-install-project, then copiessrc/and runsuv sync --locked --no-editablein a later layer, so a source change does not change the dev-dependency layer. The tiktoken cache stays with the dependency layer. (best practice) [sources: .github/workflows/ci.yml:516, .github/workflows/ci.yml:653, src/devops_cli/config/metadata.py:89, https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers]- Chosen: Deps stage and project copies. The dependency layer holds no project file, so a source change changes only the small project layer;
.devcontainer/Dockerfile:306-324already uses the same split for the devcontainer image. - Rejected: Whole virtual environment in one layer. It is the current layer of
Dockerfile:154, and it changes about 0.5 GB on each source change. - Rejected: Install the project in each stage. The Service image must hold no uv (
ci.yml:516), so the service cannot install the project itself. - Rejected: Put the source tree on
PYTHONPATH. The Service test requires the package under/app/.venv/(ci.yml:653), and--versionreads the dist-info (src/devops_cli/config/metadata.py:89).
- Chosen: Deps stage and project copies. The dependency layer holds no project file, so a source change changes only the small project layer;
- Should the runner image keep wheels and set
UV_FIND_LINKS?: Yes. Keep the wheels of both dependency groups in one directory and setUV_FIND_LINKSto it, so the firstuvchild of an implement Job reads local files. The Job's uv cache is on its home volume (Dockerfile:100), so it starts empty. Build the directory withuv export --locked --no-emit-project --format requirements-txtandpip download --require-hashes -d <dir>before the stage deletes pip (Dockerfile:84). The image growth must stay under the 3000000000-byte bound: the measured runner image was 2.51 GB (k8s/README.md:716), and the pull request states the growth. (best practice) [sources: k8s/README.md:716, .github/workflows/ci.yml:738]- Chosen: Keep wheels and set
UV_FIND_LINKS. It removes a network fetch from the firstuvchild, and the directory comes from the same lock that the image installs. - Rejected: Fetch from the network on first use. It keeps the 30 to 101 s cold-cache delay that the issue measures.
- Rejected: Pre-pull DaemonSet. It is a later remedy only if a live pull stays over 10 s.
- Chosen: Keep wheels and set
- How should this issue coordinate with build(docker): build the runner image FROM devtools with no tool install #4361?: Do not wait. Implement on the current
Dockerfileand rebase on build(docker): build the runner image FROM devtools with no tool install #4361 if it merges first. The body records no dependency, and the parent issue lists this item as start-now. build(docker): build the runner image FROM devtools with no tool install #4361 removes the twodevops install-toolscalls (Dockerfile:52,Dockerfile:76) that need the project in the builder before the tool steps; after it, the project install can move after the tool steps in each stage. (best practice) [sources: openspec/changes/archive/2026-11-10-4359-the-image-holds-the-locked-tools/tasks.md:19]- Chosen: Rebase after build(docker): build the runner image FROM devtools with no tool install #4361. It avoids a conflict in
Dockerfilewithout blocking this item, and the layer split works with the current tool steps. - Rejected: Wait for build(docker): build the runner image FROM devtools with no tool install #4361 first. The body records Dependencies: None, and the parent issue lists the item as start-now.
- Rejected: Change the file with no coordination. Both changes edit the same instructions, so a conflict is certain.
- Chosen: Rebase after build(docker): build the runner image FROM devtools with no tool install #4361. It avoids a conflict in
- How should the changed layer sizes be measured?: Build the image twice, from
mainand with a source-only change, and sum the sizes of the layers whose IDs differ indocker history --no-trunc --format '{{.ID}} {{.Size}}'. Docker and Buildx are already in the image jobs (ci.yml:484-486).craneis not pinned in the repository: the archived perf(k8s): use tag_digest HEAD for image pins #2610 change rejected acranepin, and the project's registry client reads only a tag digest (src/devops_cli/docker/registry.py:5). (best practice) [sources: .github/workflows/ci.yml:484, openspec/changes/archive/2026-11-06-2610-devops-k8s-image-pins-resolves-with/design.md:5, src/devops_cli/docker/registry.py:5]- Chosen:
docker historyon two local builds. Docker and Buildx are in the image jobs, and the differing layer IDs are the layers that a node pulls again. - Rejected:
crane manifest.craneis not intools.lock, and the project rejected a new pin for it in perf(k8s): use tag_digest HEAD for image pins #2610. - Rejected:
docker buildx imagetools inspect. It reads a pushed manifest, and the pull-request build pushes nothing (ci.yml:495).
- Chosen:
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
perfprefix of the title gives the type.(k8s)scope of the title gives the scope.Fifteen releases a day each pull 0.5 GB of changed layers, but the system still functions today.Every CI run and every node pull benefits, and the impact grows as more runner pods are added.Reordering COPY and uv sync steps plus a separate site-packages layer is a contained Dockerfile change with a coordination dependency on #4361.Both modify the Dockerfile runner stage, but #2667 adds dev dependencies and pinned tools while the candidate reorders COPY and uv sync steps for layer caching.devops-cli-service commentedon Nov 11, 2026
Status set to Ready at 1db29f7 (see proposed design in issue body).
Moved to new items: #4616.
dan-petty commentedon Nov 11, 2026
Scope from the CI audit (2026-11-11)
Another workflow builds this issue now. This comment only adds the facts that the audit measured on the CI side.
builderstage copiessrc/beforeuv sync(Dockerfile:16-20), so eachsrc/change installs the dependencies again.pyproject.tomlanduv.lock(4-9 releases per day), so the dependency layer also builds again after each release.uv sync --locked --no-install-project, thenCOPY src/, thenuv sync --locked. The OpenSpec install stays afterCOPY src/, because it runs the installeddevops.main. After it, count the CACHED layers for one day.src/shows the dependency layer as CACHED.dan-petty commentedon Nov 11, 2026
Scope from the iteration lane plan (2026-11-11)
This issue stays a child of #4517. It is also child 8 of #4667, which gives its order in the iteration lane. The plan adds one criterion.
uv sync --locked --no-editablestep ofDockerfile).uv.lockin the image (UV_FIND_LINKS), so thatuv sync --locked --offlinebuilds the venv of a checkout.Acceptance added: in the runner image,
uv sync --locked --offlineof amaincheckout into an empty venv ends in at most 60 s with no network.dan-petty commentedon Nov 11, 2026
Scope check of the wheel directory (2026-11-11)
The pull request of this item puts the dependencies in their own image layers. It does not add the wheel directory with
UV_FIND_LINKS, because that part cannot work as written. Measured with uv 0.13.6 inpython:3.14-slim-trixie, withRUN --network=none:UV_FIND_LINKS=<wheel dir> uv sync --locked --offlinestops: "Network connectivity is disabled, but the requested data wasn't found in the cache: https://files.pythonhosted.org/...". uv installs a locked package from the URL inuv.lockand does not search the find-links for it. Auv runin a worktree runs the same sync, so the firstuvchild of a Job would not read the directory either.--no-index --find-links <wheel dir>resolves again for every platform and fails onpywin32.uv sync --locked --offline2 s, with no network. The cache is 852 MB.The two criteria for the offline venv (the first
uvchild under 30 s, anduv sync --locked --offlineof a checkout in at most 60 s) move to #4814 with this evidence. This item keeps the layer criteria.devops-cli-service commentedon Nov 12, 2026
Released in v0.116.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.116.0
devops-cli-service commentedon Nov 12, 2026
Live since 2026-11-12 05:27 UTC
fix(roadmap): Hold back only the clause of a reverse phrase (#6451)