Skip to content

Resolve sandbox base digests without registry reads and force amd64 base builds - #30

Merged
ReganBell merged 3 commits into
mainfrom
fix/sandbox-publish-robustness
Jul 30, 2026
Merged

Resolve sandbox base digests without registry reads and force amd64 base builds#30
ReganBell merged 3 commits into
mainfrom
fix/sandbox-publish-robustness

Conversation

@ReganBell

@ReganBell ReganBell commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Fixes two verified incidents hit on real deployments (one Fly, one AWS).

1. sandbox publish --from <tag> fails with the mandated app-scoped Fly token

qm sandbox publish pinned a mutable --from base by running docker buildx imagetools inspect against the registry. Fly's registry rejects reads from app-scoped deploy tokens (only org tokens can read it), so publish failed exactly on the token the docs tell operators to use — while the build's own docker pull/push with that token works fine.

  • Publish now resolves mutable base tags via docker pull --platform linux/amd64 + the recorded RepoDigests entry (new pinnedByPull), the same pull path the layer build already depends on. The pulled digest is the tag's top-level manifest/index digest — identical to what imagetools inspect returned — so recorded sandbox.baseImage pins are unchanged in form and remain pullable by machines. Publish no longer touches the registry read API at all.
  • pinnedByDigest (inspect) remains only for fly rollback --to <tag>, where there is no build to piggyback on; its failure message now prints the exact workaround — pass the digest form <repository>@sha256:…, which skips the lookup entirely.

2. arm64 hosts build a base image the deploy rejects

Building the sandbox base on an Apple Silicon Mac defaulted to linux/arm64 (rejected at deploy time, since sandbox machines are amd64-only), and retrying with --platform linux/amd64 under qemu is slow and crashes in apt.

  • scripts/local-sandbox-build.sh now targets linux/amd64 explicitly for both stages, and when FLY_SANDBOX_APP_NAME is set and flyctl is installed it builds on Fly's remote amd64 builder (flyctl deploy --build-only --push --remote-only --dockerfile fly/Dockerfile) and pulls the result instead of emulating locally. No new flags — better defaults only. (npm run deploy:fly-image already used the remote builder.)
  • fly/README.md documents the amd64 requirement and the remote-builder behavior.

Tests

  • New test: --from a Fly-registry tag pins by pull, never invokes imagetools inspect, flattens the layer Dockerfile onto the pinned ref, and records the pin.
  • Updated the custom-Dockerfile re-resolution test and the pinnedByDigest workaround-message assertion; test docker fake now models pull and image inspect.
  • Verified: cli/test/sandbox-publish.test.ts, sandbox-build, fly-sandbox, fly-up, package, root sandbox-base-image/local-sandbox tests all green; tsc --noEmit and eslint/oxlint clean.

An independent fresh-context review pass was run on the diff; its two findings (docker auth before the registry pull in the script, and a workaround message that also covers the custom-Dockerfile path) are addressed.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

ReganBell and others added 3 commits July 30, 2026 13:54
…ase builds

Two verified incidents on Fly and AWS deployments:

qm sandbox publish --from <tag> resolved the base digest with docker buildx
imagetools inspect against the Fly registry, which fails with the app-scoped
deploy token the docs mandate (only org tokens can read the registry).
Publish now resolves mutable base tags with docker pull + RepoDigests, the
same pull path the layer build itself uses, so a push-capable token
suffices and publish never reads the registry API. pinnedByDigest remains
only for fly rollback --to <tag>, where no build exists to piggyback on;
its failure message now prints the workaround of passing a digest-form ref,
which skips the lookup entirely.

Building the sandbox base on an arm64 Mac defaulted to arm64, which deploy
rejects, and qemu-emulated amd64 builds are slow and crash in apt.
scripts/local-sandbox-build.sh now targets linux/amd64 explicitly and, when
FLY_SANDBOX_APP_NAME is set and flyctl is installed, builds on Fly's remote
amd64 builder and pulls the result instead of emulating locally.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ReganBell
ReganBell merged commit a44e2dd into main Jul 30, 2026
15 checks passed
@ReganBell
ReganBell deleted the fix/sandbox-publish-robustness branch July 30, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant