Repository navigation
Description
Problem
An audit of ghcr.io/dan-petty/devtools (20261120) on 2026-11-20 found clean-up items in the image build. Image size is not a goal now (owner, 2026-11-20); these items fix wrong state, unused tools and settings that each consumer must repeat.
Change
- apt state: the cache mount on all of
/var/lib/aptkeepsextended_statesout of the layer, so apt marks 687 of 764 packages as manual andapt-get autoremoveremoves nothing. Remove the apt cache mounts and the docker-clean / keep-cache steps (CI exports no BuildKit cache and the daily build uses--no-cache), and use oneapt-get update && apt-get install ... && rm -rf /var/lib/apt/lists/*. - One opt-out ENV block in the final stage for the tools that devtools ships:
DO_NOT_TRACK=1,OPENSPEC_TELEMETRY=0,OPENSPEC_NO_UPDATE_CHECK=1,GH_NO_UPDATE_NOTIFIER=1,npm_config_update_notifier=false,COPILOT_AUTO_UPDATE=false,DISABLE_AUTOUPDATER=1, the semgrep metrics and version-check switches,GOTELEMETRY=off. Copilot self-update is on today and keeps one 166-282 MB copy per version in the home cache (16 versions, 3.5 GB in the devcontainer home volume). - Unused in the final image: the
misebinary (156 MB; mise is a build-time tool here) andbanditfrom apt (devops-cli runs bandit from its own dev group). Keep pre-commit. - World-writable venv lock files under
/usr/local/lib/devtools/*/.lock: remove them afteruv pip sync. - Manifests are the source: each tool is listed in four places (apt list or mise.toml, the copy loop,
test/tools.sh, README) and no check finds a missing copy. Make the README point to the manifests, and add a CI check that the copy loop coversmise.toml.
Not in this item: a unique build tag and the version label (devtools#6), the lint step (devtools#6), moving the Podman and common-utils package set from the devcontainer Features into devtools, and reproducible layer digests (later, with size work).
Proof
apt-mark showautoin the new image lists the dependencies;apt-get -s autoremovebehaves normally.docker run --rm <image> envshows the opt-out block;copilot --versionas uid 1000 writes no~/.cache/copilot/pkg.test/tools.shpasses;miseandbanditare absent.
Alternatives check of 2026-11-20: not-applicable.
Class: chore, no search.
Tool: none found.
Proposed design
Problem statement
The devtools image keeps wrong apt state. It repeats opt-out settings in each consumer. It ships unused tools. It leaves world-writable lock files. It lets the copy loop drift from the manifests. This change cleans the image build and makes the manifests the source of the tool list.
Acceptance criteria
Requirement: apt state is not hidden by cache mounts
The image build SHALL remove the apt cache mounts and the docker-clean and keep-cache steps, and it MUST use one apt-get update && apt-get install ... && rm -rf /var/lib/apt/lists/* sequence.
Scenario: apt marks dependencies as automatic
- WHEN
docker run --rm devtools:test sh -c 'test "$(apt-mark showauto | wc -l)" -gt 100 && apt-get -s autoremove >/dev/null'runs - THEN The command exits 0.
Requirement: opt-out environment block
The final stage SHALL set one ENV block with DO_NOT_TRACK=1, OPENSPEC_TELEMETRY=0, OPENSPEC_NO_UPDATE_CHECK=1, GH_NO_UPDATE_NOTIFIER=1, npm_config_update_notifier=false, COPILOT_AUTO_UPDATE=false, DISABLE_AUTOUPDATER=1, SEMGREP_SEND_METRICS=off, SEMGREP_ENABLE_VERSION_CHECK=0, and GOTELEMETRY=off.
Scenario: opt-out variables are present
- WHEN
docker run --rm devtools:test sh -c 'for v in DO_NOT_TRACK=1 OPENSPEC_TELEMETRY=0 OPENSPEC_NO_UPDATE_CHECK=1 GH_NO_UPDATE_NOTIFIER=1 npm_config_update_notifier=false COPILOT_AUTO_UPDATE=false DISABLE_AUTOUPDATER=1 SEMGREP_SEND_METRICS=off SEMGREP_ENABLE_VERSION_CHECK=0 GOTELEMETRY=off; do env | grep -qx "$v" || exit 1; done'runs - THEN The command exits 0.
Requirement: Copilot writes no package cache
The final image MUST disable Copilot self-update so that copilot --version writes no package cache for uid 1000.
Scenario: copilot writes no package cache
- WHEN
docker run --rm --user 1000:1000 -e HOME=/tmp/copilot-home devtools:test sh -c 'mkdir -p "$HOME" && copilot --version >/dev/null && test ! -e "$HOME/.cache/copilot/pkg"'runs - THEN The command exits 0.
Requirement: unused tools are absent and pre-commit remains
The final image MUST NOT contain the mise binary or the apt bandit package, and it MUST keep pre-commit.
Scenario: removed tools are absent
- WHEN
docker run --rm devtools:test sh -c '! command -v mise && ! command -v bandit && pre-commit --version'runs - THEN The command exits 0.
Requirement: tool test drops removed tools
The tool test MUST NOT run mise --version or bandit --version.
Scenario: tool test has no removed tools
- WHEN
! grep -Eq '^run (mise|bandit) ' test/tools.shruns - THEN The command exits 0.
Requirement: venv lock files are not world-writable
The image build SHALL remove world-writable .lock files under /usr/local/lib/devtools after uv pip sync.
Scenario: no world-writable venv lock file remains
- WHEN
docker run --rm devtools:test sh -c 'test -z "$(find /usr/local/lib/devtools -name .lock -perm -002 -print -quit)"'runs - THEN The command exits 0.
Requirement: manifest check passes on the checked-in files
The repository MUST make the manifests the source of the tool list by pointing the README to mise.toml and the Dockerfile apt list and by a CI check that the Dockerfile copy loop covers every mise.toml tool.
Scenario: manifest check passes
- WHEN
bash test/manifests.shruns in the image CI job against the checked-inDockerfile,mise.tomlandREADME.md - THEN The command exits 0.
Requirement: manifest check catches drift
The manifest check MUST fail when a mise.toml tool is missing from the Dockerfile copy loop.
Scenario: manifest check fails on drift
- WHEN
bash test/manifests.shruns in a temporary copy of the repository with onemise.tomltool removed - THEN The command exits 1.
Existing Tool Considered
The alternatives check in the issue body records not-applicable for this chore and names no tool. No open, maintained tool covers the whole clean-up. The clean-up uses direct edits to Dockerfile, README.md and test/tools.sh. hadolint checks Dockerfile rules but does not compare the copy loop with mise.toml. mise holds the tool list but does not generate the Dockerfile copy loop. The only new code is test/manifests.sh. Building it costs about 1,000 tokens and 30 minutes. Keeping it costs about 100 tokens per manifest change.
Key questions
- Does removing
misefrom the final image break a runtime caller?: No. The only repository caller istest/tools.sh:60, which runsmise --version; the issue records that mise is a build-time tool and the final image does not need it. Remove that line fromtest/tools.sh. [sources: test/tools.sh:60] - Does removing
banditfrom apt break a runtime caller?: No. The apt package is atDockerfile:55and the only caller in this repository istest/tools.sh:23; no other file invokes bandit. The issue states that devops-cli runs bandit from its own dev group. Remove the apt package and the test line. [sources: test/tools.sh:23] - Which tool test lines must change?: Remove
run mise --versionattest/tools.sh:60andrun bandit --versionattest/tools.sh:23. Keeprun pre-commit --versionattest/tools.sh:92. [sources: test/tools.sh:23, test/tools.sh:60, test/tools.sh:92] - How should apt state be cleaned?: Remove the apt cache mounts and the docker-clean and keep-cache steps, and use one
apt-get update && apt-get install ... && rm -rf /var/lib/apt/lists/*sequence. The scheduled build pulls the base image and uses no BuildKit cache, so the mounts hideextended_stateswithout saving a useful cache. (best practice) [sources: .github/workflows/image.yml:54-64]- Chosen: Remove cache mounts and use one apt sequence. CI exports no BuildKit cache and the daily build uses --no-cache; the mounts only hide extended_states.
- Rejected: Keep cache mounts and mark packages automatic. This adds a step and does not fix the hidden apt state.
- Rejected: Keep cache mounts and remove lists only. This keeps extended_states out of the layer and leaves the wrong manual marks.
- How should the opt-out settings reach the final image?: Set one ENV block in the final
devtoolsstage, so every consumer inherits it. The block sets the ten variables named in the issue body. (best practice) [sources: README.md:13-18]- Chosen: One ENV block in the final stage. The final stage is the image that consumers use as a base, so this gives one place to audit and stops each consumer from repeating the settings.
- Rejected: Per-tool wrapper scripts. This adds files and hides the settings from
docker run --rm devtools:test env. - Rejected: Leave the settings to consumers. This repeats work and lets the Copilot cache grow in each home volume.
- Which Semgrep environment variables disable metrics and the version check?: Set
SEMGREP_SEND_METRICS=offandSEMGREP_ENABLE_VERSION_CHECK=0in the final ENV block. The image test already runssemgrep --disable-version-checkbecause a version check with no network waits 98 s (test/tools.sh:93-94); the ENV variable applies the same setting to every consumer run. (best practice) [sources: test/tools.sh:93-94]- Chosen: Set both Semgrep variables in the ENV block. This applies to every Semgrep run in the image.
- Rejected: Pass CLI flags in
test/tools.shonly. This covers the test but not consumer runs.
- How should the Dockerfile copy loop stay aligned with
mise.toml?: Addtest/manifests.sh, a shell check that reads themise.tomltool names and the Dockerfile copy loop, and call it from the image workflow. The check fails when amise.tomltool is missing from the copy loop. (best practice) [sources: mise.toml:6-36, .github/workflows/image.yml:75-85]- Chosen: Add a shell check in
test/manifests.sh. It adds no dependency and fails CI on a missing copy. - Rejected: Generate the copy loop from
mise.tomlat build time. This is a larger build change than the issue asks for. - Rejected: Rely on README and review. No check finds a missing copy.
- Chosen: Add a shell check in
- How should the manifest check resolve a
mise.tomltool key to its command name?: Use the tool key as the command name, except for GitHub backend keys, where the command is the part after the slash, and the aliasesopentofutotofuandargo-rolloutstokubectl-argo-rollouts. The check fails when a resolved command is missing from the Dockerfile copy loop. (best practice) [sources: mise.toml:6-36, test/tools.sh:61-87]- Chosen: Use a small alias map in the check. It keeps the check self-contained and handles the known command names.
- Rejected: Run
mise whichfor each tool in CI. This adds mise to the CI job and a new action or stage. - Rejected: Generate the copy loop from
mise.toml. This is a larger build change than the issue asks for.
- Where should the README get the tool list?: Point the README to
mise.toml, the apt package list in theDockerfile,python/,npm/andtest/tools.sh, and remove the duplicated table. (best practice) [sources: README.md:43-55, mise.toml:6, test/tools.sh:20-101]- Chosen: Point to the manifests and remove the table. This keeps one source for each tool list.
- Rejected: Keep the table and add a check. This keeps a second list that can drift.
- Rejected: Remove the tool section. Users still need a pointer to the manifests.
- How should the world-writable venv lock files be removed?: Remove them in the
python-toolsstage after theuv pip syncloop, before the final stage copies/usr/local/lib/devtools/. The lock files are not needed after the sync. (best practice) [sources: README.md]- Chosen: Remove after
uv pip sync. The files are not needed after the sync and this clears the world-writable bit. - Rejected: Change the mode with
chmod. This keeps an unneeded lock file in the image. - Rejected: Leave the files. This keeps world-writable files in the final image.
- Chosen: Remove after
- Does the final image keep pre-commit?: Yes. The issue says keep pre-commit, and
test/tools.sh:92runspre-commit --version; the change removes only the aptbanditpackage and the mise binary. [sources: test/tools.sh:92]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 20, 2026
Item 1 built and published the devtools image; this candidate cleans up that image's apt state, env vars, and unused tools.devops-cli-service commentedon Nov 20, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
devops-cli-service commentedon Nov 20, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
dan-petty commentedon Nov 20, 2026
The Copilot proof of this item cannot pass as written. #14 delivers the other items and sets
COPILOT_AUTO_UPDATE=false, but it does not add the Copilot cache check.Evidence (
@github/copilot1.0.114, linux-x64, a new emptyHOME, noXDG_CACHE_HOME):copilot --versionwith noCOPILOT_AUTO_UPDATE: writes~/.cache/copilot/pkg/linux-x64/1.0.114, 282 MB.COPILOT_AUTO_UPDATE=false copilot --version: writes the same folder, 282 MB.The native binary is a launcher. At the first start of each version, it writes its bundled package to the first folder of this list:
$COPILOT_PKG_CACHE_HOME/pkg,$COPILOT_CACHE_HOME/pkg,${XDG_CACHE_HOME:-~/.cache}/copilot/pkg,$COPILOT_HOME/pkg,~/.copilot/pkg.COPILOT_AUTO_UPDATE=false(and--no-auto-update) stops only the download of newer versions. Thus the home cache still gets one copy for each Copilot version of a new image.Options for the owner: accept one copy per image version and close this item when #14 merges, or file a separate item for the package folder (for example
COPILOT_PKG_CACHE_HOME). #14 adds neither.dan-petty commentedon Nov 20, 2026
Owner decision (2026-11-20), as recommended: accept one unpacked Copilot package per Copilot version in
~/.cache/copilot/pkg.COPILOT_AUTO_UPDATE=falsestops the downloads of newer versions, which made the 16 copies. So the requirement "Copilot writes no package cache" becomes "Copilot downloads no newer version by itself". No extra code moves the package folder. PR #14 closes this issue.docs(image): say that Copilot keeps one package copy per version
dan-petty commentedon Nov 20, 2026
Two corrections to the lists of this item. #14 applies them.
bandit stays in the image. The published devops-cli devcontainer image is
FROM devtools. Its lock stage exports the venv withuv export --locked --no-dev --extra review(devops-cli.devcontainer/Dockerfile:17). bandit is only in thedevdependency group of devops-cli (pyproject.toml), so the venv of that image has no bandit. The aptbanditof devtools is the only bandit onPATHthere. Without it,devops scanin a child repository reports bandit as unavailable and does not fail. Thus the item "devops-cli runs bandit from its own dev group" is wrong for the published image. The apt list keepsbandit, andtest/tools.shrunsbandit --versionagain.GOTELEMETRY=offis not in the ENV block. The Go toolchain does not readGOTELEMETRYfrom the environment:src/cmd/go/internal/help/helpdoc.go(golang/go, master) lists it under "Additional information available from 'go env' but not read from the environment".golang.org/x/telemetryreads its mode from a file thatgo telemetry offwrites. The image also has no Go toolchain. The ENV block has the other nine variables.chore(image): remove the local gh quota cache files (#13)
chore(image): clean up apt state, opt-out env and unused tools (#14)