feat(sandbox): cache the guest image at startup instead of on first command

Pull the configured guest image in the background when the Manager boots and
when sandbox enforcement is switched on, so a sandboxed command no longer
pays the multi-gigabyte download. msb pull is a no-op once cached, startup is
never blocked by it, and a command racing the pull joins the same in-flight
boot.
This commit is contained in:
Chris Scott committed 2026-08-28 13:05:56 -04:00
1 parent 5beb3432d4
commit 2eba81d524
8 files changed
+82 -12

No files matched your search

+2 -2
View File
@@ -191,7 +191,7 @@ The guest runs every command as a numeric host uid that has no `/etc/passwd` ent
Chromium launches headless as the non-root exec user without extra flags. If your host kernel restricts user namespaces so Chromium's own sandbox fails, pass `--no-sandbox` — the microVM is already the isolation boundary.
The image is over 3 GB against a 1.6 GB `node:24` baseline, almost entirely Chromium and its dependencies. The first pull is bounded by `SANDBOX_START_TIMEOUT_MS`; raise it on slow links.
The image is over 3 GB against a 1.6 GB `node:24` baseline, almost entirely Chromium and its dependencies. The Manager caches it ahead of first use: at startup, and whenever sandbox enforcement is switched on, it runs `msb pull` in the background (bounded by `SANDBOX_START_TIMEOUT_MS`; raise it on slow links). The pull is a no-op once the image is cached, and `docker-compose.sandbox.yml` persists the microsandbox store in the `microsandbox-data` volume so the download survives container replacement. Because it runs in the background, server startup is never blocked by it, and a sandboxed command issued while the pull is still running joins the same in-flight boot instead of starting a second download.
### Using your own image
@@ -210,7 +210,7 @@ Override the Playwright version at build time with `--build-arg PLAYWRIGHT_VERSI
## Caveats
- The first command pays image pull and microVM boot latency, bounded by `SANDBOX_START_TIMEOUT_MS`.
- The first command pays microVM boot latency, bounded by `SANDBOX_START_TIMEOUT_MS`. The guest image itself is pulled in the background at startup, so it only pays a download too if it runs before that pull finishes.
- `SANDBOX_IMAGE` must contain every tool the agent expects to run.
- `SANDBOX_EXEC_USER` must match the workspace owner so commands can write mounted files.
- A `shell` the user configured does not apply to slash-command shell templates while enforcement is on, and is bypassed for `!command` shell mode because that surface is routed into the microVM.