build(images): clean npm cache in client layers #72

Closed
motoko wants to merge 0 commits from build/npm-cache into master
Collaborator

Why

Each client runs from an image built from containers/Dockerfile: a
shared base, then one layer that installs the client. The Codex and
OpenCode layers install with npm install -g, which leaves the
tarballs it downloaded in ~/.npm. Every host that installs or
launches those clients stored them in the image for nothing, since no
launch reads that cache. The base already removes it after installing
Prettier; the client layers did not.

What changed

Before, the codex and opencode images held npm's download cache.
Now each removes it in the same RUN that installs the client, so the
layer never stores it. The claude target installs without npm and
stays as it was.

The change is two lines of containers/Dockerfile and an assertion in
tests/unit/test_containerfile.sh that the clean follows the install
in its layer. An installed host takes it at its next ./install.sh
run, since a launch rebuilds from the installed release's Dockerfile.

How to verify

Have Git and Bash 4.4 or newer.

git clone https://git.unitoo.it/claudiomaradonna/azkaban.git
cd azkaban
grep -n -A1 'npm install -g @' containers/Dockerfile

On master the two install lines, 88 and 141, end their RUN. After
git switch build/npm-cache each continues into
&& npm cache clean --force, and bash tests/unit/test_containerfile.sh
prints 20 test(s), 0 failure(s).

Checks run on the tip: make lint && .agents/hooks/shellcheck.sh repo && make test
passes, 352 tests; the two extended stage tests fail on master's
Dockerfile. Not tried, for want of rootless Podman where the change was
made: a real build. To see the size, run ./install.sh --build codex
on each branch and compare
podman image inspect --format '{{.Size}}' codex-cli:latest; the gate
make test-e2e builds every target.

## Why Each client runs from an image built from `containers/Dockerfile`: a shared base, then one layer that installs the client. The Codex and OpenCode layers install with `npm install -g`, which leaves the tarballs it downloaded in `~/.npm`. Every host that installs or launches those clients stored them in the image for nothing, since no launch reads that cache. The base already removes it after installing Prettier; the client layers did not. ## What changed Before, the `codex` and `opencode` images held npm's download cache. Now each removes it in the same `RUN` that installs the client, so the layer never stores it. The `claude` target installs without npm and stays as it was. The change is two lines of `containers/Dockerfile` and an assertion in `tests/unit/test_containerfile.sh` that the clean follows the install in its layer. An installed host takes it at its next `./install.sh` run, since a launch rebuilds from the installed release's Dockerfile. ## How to verify Have Git and Bash 4.4 or newer. ```bash git clone https://git.unitoo.it/claudiomaradonna/azkaban.git cd azkaban grep -n -A1 'npm install -g @' containers/Dockerfile ``` On `master` the two install lines, 88 and 141, end their `RUN`. After `git switch build/npm-cache` each continues into `&& npm cache clean --force`, and `bash tests/unit/test_containerfile.sh` prints `20 test(s), 0 failure(s)`. Checks run on the tip: `make lint && .agents/hooks/shellcheck.sh repo && make test` passes, 352 tests; the two extended stage tests fail on `master`'s Dockerfile. Not tried, for want of rootless Podman where the change was made: a real build. To see the size, run `./install.sh --build codex` on each branch and compare `podman image inspect --format '{{.Size}}' codex-cli:latest`; the gate `make test-e2e` builds every target.
npm install -g leaves the tarballs it downloaded in ~/.npm, so the
Codex and OpenCode images carried them in the client layer for nothing;
the base already removes them after installing Prettier. The Claude
target installs without npm.
motoko force-pushed build/npm-cache from 0234fdadc1 to cad0aace6e 2026-11-11 14:47:21 +01:00 Compare
claudiomaradonna closed this pull request 2026-11-11 15:07:32 +01:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
claudiomaradonna/azkaban!72
No description provided.