Skip to content

fix: split the image into layers of at most 200 MB - #17

Merged
kalaspuff merged 4 commits into
mainfrom
fctl/1679-the-host-seems-to-have-failed-downloadin
Nov 26, 2026
Merged

kalaspuff merged 4 commits into
mainfrom
fctl/1679-the-host-seems-to-have-failed-downloadin

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An Apple runner couldn't pull ghcr.io/hyperstructure/sandbox:0.38.1: each of the host's three tries broke off after about 10 minutes with StreamClosed … ProtocolError. ghcr.io sends each layer's download to a signed link that expires within 5 to 10 minutes (the next 5-minute mark plus 5 minutes), and its CDN resets the HTTP/2 stream at that moment: a throttled curl of the layer from an fctl sandbox was cut 8 s after its link expired, with the same error. The image was a single 1.33 GB layer (1.40 GB on amd64), which takes longer than that at 2.4 MB/s, and Apple's container keeps nothing of a pull that broke off, so every retry started over and hit the same limit.

provision.sh now runs in named steps (STEPS), and the Dockerfile runs each in a RUN of its own, so the image comes in 17 layers instead of 4. Run without arguments, as fctl's Lima driver runs it, the script still does every step in order. apt's lists are fetched once per run and removed as it ends, so no layer keeps them. Rust's compiler and its standard library come in separate steps: together they made a 222 MB layer on amd64. The Lint workflow checks that the Dockerfile runs every step. On pull requests, the Image workflow lists each layer's size and what hosts download, and warns about a layer over 200 MB. AGENTS.md and the change-the-image skill say how to keep layers under that.

What hosts download barely changes; the only new bytes are the few files each apt step rewrites (dpkg's status, debconf's templates, logs). Measured from this pull request's Image run against the published 0.38.1 image:

Before After Largest layer
arm64 1.364 GB, one layer of 1.33 GB 1.366 GB 186 MB (Claude Code, one 385 MB file)
amd64 1.430 GB, one layer of 1.40 GB 1.432 GB 188 MB (Claude Code)

Both builds pass check.sh, and the Develop fctl workflow builds and tests fctl in each.

Worth confirming

  • Decision: layers stay under 200 MB compressed. With 3 downloads at a time (Apple's default), that is enough at about 2 MB/s even when a link lasts only 5 minutes. A slower connection can still fail; only resuming downloads with Range requests (Resume blob downloads after a dropped connection apple/containerization#949, not merged) fixes that.
  • Decision: the Image workflow only warns about a layer over 200 MB, rather than failing, so that a Claude Code release whose binary grows past it doesn't stop fctl's releases. Claude Code's layer is the largest already, and a single file can't be split.
  • Decision: the rust step removes the host's standard library that rustup's minimal profile installs, and rust-std adds it back with wasm32's. The Lima driver, which runs every step at once, downloads it twice.

fctl session


Note

Medium risk. It restructures how the image every fctl session runs in is built, splitting provision.sh into steps and the Dockerfile into one layer per step, so a missed install detail would break all sessions, though CI builds and checks the image.

What it does. Splits provision.sh into named step_ functions that run in order, or only those named as arguments, and makes the Dockerfile run each step in its own RUN, so that no layer is over about 200 MB compressed and downloads finish before ghcr.io's expiring links cut them off. The Rust install is split in two: rust installs the compiler, cargo, rustfmt and Clippy and removes the host standard library, and rust-std adds it back with wasm32's. The Image workflow lists each layer's size and warns about any over 200 MB, and Lint now checks that the Dockerfile runs every step of STEPS in order.

Steps listed in two places. A new step goes in STEPS in provision.sh and as a RUN in the Dockerfile; the Lima driver runs the script without arguments, so a step missing from the Dockerfile would be left out of the Docker image, which the new Lint check now catches.

fctl review's first look at 2cc0bd1 · 6 files, +263 −104 · Review agent settings

ghcr.io sends each layer's download to a signed link that expires within
5 to 10 minutes, and closes the connection then. The image was one 1.33 GB
layer, which an Apple runner pulling at 2.4 MB/s never finished: each try
broke off after about 10 minutes, and Apple's container keeps nothing of a
pull that broke off, so the host's retries started over each time.

provision.sh now runs in steps, which the Dockerfile runs in a RUN each;
without arguments it runs them all, as fctl's Lima driver does. apt's
lists are fetched once per run and removed as it ends. Pull requests'
Image runs list what hosts download and the largest layer, and warn about
layers over 200 MB.
@fctl-sh
fctl-sh Bot requested a review from kalaspuff as a code owner November 25, 2026 23:34
fctl-sh Bot added 3 commits November 25, 2026 23:34
On amd64 the compiler, cargo and the host's standard library made a 222 MB
layer. The Image workflow's warning now names each layer over 200 MB.
@kalaspuff
kalaspuff merged commit c877995 into main Nov 26, 2026
12 checks passed
@kalaspuff
kalaspuff deleted the fctl/1679-the-host-seems-to-have-failed-downloadin branch November 26, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant