The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.
BoxLite image service
apps/image-service is the Go module for the services that speak the OCI
distribution protocol on BoxLite's behalf. It holds one binary today, the
registry proxy (cmd/registry-proxy/).
The registry proxy is how a runner pulls an image that BoxLite has credentials for and the runner does not. A runner authenticates to the proxy with its own credential; the proxy authenticates to the upstream registry with the organization's, and streams the answer straight back. Nothing else about the pull changes — the manifest bytes a runner receives are the bytes the upstream served, so the digest a client verifies still holds.
- Place in the platform: hosted platform
Private images. The proxy reads the organization's matching login from the credential store when a pull needs it. The proxy reads these passwords and the API writes them.
Endpoints
| Method | Path | Answers |
|---|---|---|
GET HEAD |
/v2/ |
The version check. Unauthenticated, 401 with a Basic challenge. |
GET HEAD |
/v2/<org>/<host>/<repo…>/manifests/<tag or digest> |
The upstream manifest, byte for byte. |
GET HEAD |
/v2/<org>/<host>/<repo…>/blobs/<digest> |
The upstream blob, streamed. |
GET |
/health |
Liveness, for the platform's probes. |
Everything else under /v2/ is a 404: this proxy pulls and does not push.
The host listener honors BOXLITE_LISTEN_HOST; the managed local stack uses
127.0.0.1, while an unset value retains the all-interface deployment default.
Listener tests check readiness on standard loopback and rejection of a malformed
configured host. They do not assume secondary loopback aliases such as
127.0.0.2, which are not configured by default on macOS.
Why the version check challenges
A client reads GET /v2/ to decide whether to send a credential at all.
BoxLite's own runtime does this in oci-client: it pings, reads
WWW-Authenticate, and sends nothing on every later request when the header
is absent. A 200 with no challenge therefore produces a puller that never
authenticates, and the failure surfaces as "the credentials are configured but
every pull is refused".
How a pull is addressed
One proxy serves every upstream registry, so the path says which one, and the organization beside it says who may reach it:
GET /v2/<org>/<upstream host>/<repository…>/manifests/<tag or digest>
GET /v2/<org>/<upstream host>/<repository…>/blobs/<digest>
/v2/acme/ghcr.io/acme/app/manifests/1.2
└──▶ org "acme" · ghcr.io · acme/app · tag 1.2
/v2/acme/docker.io/alpine/manifests/3.20
└──▶ org "acme" · registry-1.docker.io · library/alpine · tag 3.20
▲ ▲
docker.io serves the website, not the registry
Docker Hub implies library/
The organization comes from the path and only from the path. A caller's own credential says which runner is calling, never which organization: runners are shared and belong to none.
These refs are the API's and the runner's alone. The API writes
<proxy>/<org>/ghcr.io/acme/app:1.2 for a box whose image an organization's
login covers, and a tenant never reads it back: the box's image is
ghcr.io/acme/app:1.2, and a pull that fails is recorded with that name, in
both the ref and the /v2/ URL a registry client prints. A failure that names
only this proxy, such as its /v2/ being unreachable, reads as "the registry
proxy", without its address.
What a pull passes through
GET /v2/<org-id>/registry.example.com/acme/app/manifests/1.2 Authorization: Basic …
│
├─ route <org>/<host>/<repo> split out 400 if it carries no route
├─ authenticate runner API key → control plane, cached 401 · 503 if it cannot be asked
├─ meter this runner's and organization's rate 429 + Retry-After
│
├─ lookup scoped login from the control plane 403 if no hosted box · 503 if unavailable
├─ authorize matching login or anonymous host list 403 if neither applies
├─ token reuse only when the secret version matches
├─ forward GET https://registry.example.com/v2/acme/app/manifests/1.2
│ └─ 401 → read the challenge, fetch a token, retry once
│ the token is kept per (runner, org, endpoint, repository), with its secret version
│ ├─ secret Secret Manager, only on a token miss
│ └─ token bought with the login: kept ≤ 5 minutes 403 if the login is refused
│
└─ relay status, headers and body, unread and unmodified
The caller's own credential stops at authenticate: it identifies a runner to
this proxy and means nothing upstream, so it is never forwarded.
A runner is given an organization's login only while it hosts a box of that organization. Lookups and cached tokens are scoped per runner.
A path without a valid organization ID can use only the anonymous host list.
The credential finder calls the internal control-plane route
GET /api/runners/me/images/registry-credentials directly with the runner's bearer
token. This operation and its secret-version response model are excluded from
the customer OpenAPI document and generated SDKs. The proxy reuses its configured
control-plane HTTP client and base URL.
A credential lookup returning 404 can continue anonymously for hosts on the anonymous list. A 403 refuses the pull. Other failures report the credential as unavailable.
An organization's login travels to one place, the registry's token endpoint,
and only when that endpoint is the registry's own host or one it is known to
use (auth.docker.io for Docker Hub). The pull itself carries the token the
login bought, never the login. A token bought with a login is kept five
minutes at most, whatever the registry states — gcr.io states twelve hours —
as an additional lifetime bound; credential versions are checked before private bearer reuse.
A custom registry that requests Basic authentication for the image pull receives a denial that explains the same-host HTTPS Bearer token requirement.
Credential rotation commits the new username/secret pointer before retiring the old secret. Every private pull reads current metadata before selecting a bearer. A version mismatch forces a new token exchange with the replacement login.
This works across replicas and when old-secret retirement fails. Secret payloads are read only on token misses. Normally, each private manifest/blob request adds one API lookup and fails closed during control-plane lookup outages, even with a warm token.
Upstreams on the anonymous list can cache negative lookups. Upstreams outside that list query the current credential on each request, including after a miss. Upstream-issued tokens themselves are not revoked.
If a version is retired during an authentication challenge, the proxy refreshes authorized metadata and retries the secret read once. A failed refresh or second read fails the pull. In-flight requests may still need a caller retry.
Upgrade all proxy replicas before relying on this behavior. Older replicas retain the previous cache delay.
Unmodified takes one deliberate act. Go's HTTP transport offers gzip on any
request that did not ask for an encoding itself, then decodes the answer and
drops Content-Encoding and Content-Length on the way — a convenience when
reading a body, a defect when relaying one, since the caller would receive
different bytes under a digest that no longer covers them. Compression is
therefore disabled on the upstream transport, and what the caller asks for is
forwarded so the answer is the caller's own to decode.
The upstream list permits anonymous forwarding. To reach any other upstream, the authenticated Runner must have a matching organization credential for the requested repository. The proxy checks the resolved address before connecting, including on redirects and token requests.
For upstreams outside the anonymous list, every hop uses HTTPS. A cross-origin blob redirect drops the Authorization header. A credentialed token exchange stays on its original origin.
Layout
| Package | Holds | Must not know |
|---|---|---|
internal/oci/ |
The distribution protocol: how a pull spells itself in a URL, which endpoint serves a registry host, how to issue that pull upstream. | That anyone is authenticated, rate-limited, or proxied at all. |
internal/proxy/ |
What only the registry proxy needs: the <org>/<host>/<repository> convention, the HTTP surface, caller authentication, per-runner and per-organization rate limiting, finding an organization's login, upstream token exchange, and the address rule. |
— |
internal/secrets/ |
Reading a password from Secret Manager or a local directory. | Whose password it is, or what it is for. |
cmd/registry-proxy/ |
The binary: configuration, telemetry, signals. | — |
The line matters more than it looks. internal/oci is reusable by a second
caller exactly to the extent that it stays ignorant of this one; the moment it
learns about organizations or credentials, it is the registry proxy with extra
steps.
Configuration
| Variable | Default | Purpose |
|---|---|---|
REGISTRY_PROXY_PORT |
4100 |
Listen port. Not 5000, the registry convention, because macOS binds it for AirPlay. |
SHUTDOWN_TIMEOUT_SEC |
3600 |
How long a drain may take. A blob is one long response, so this has to outlast the longest pull in flight or a deploy truncates an image mid-layer. |
BOXLITE_API_URL |
— | Required. The control plane. A runner API key is an opaque column rather than a signed token, so a caller can only be checked by asking. |
REGISTRY_PROXY_UPSTREAM_HOSTS |
ghcr.io,docker.io,quay.io,gcr.io,us.gcr.io,eu.gcr.io,asia.gcr.io |
Registries eligible for anonymous forwarding. Use published registry names such as docker.io. |
REGISTRY_SECRET_STORE |
— | Credential store, either gcp (Secret Manager) or file. When unset, only anonymous hosts are eligible. |
REGISTRY_SECRET_DIR |
— | The directory the file store reads, on a local stack. |
REGISTRY_PROXY_CREDENTIAL_TTL |
60s |
How long a verified caller is taken on trust. Also the delay between revoking a runner and this proxy noticing. |
REGISTRY_PROXY_REJECTION_TTL |
30s |
How long a refused credential is remembered, so a caller with a bad key cannot turn this proxy into a load generator aimed at the control plane. |
REGISTRY_PROXY_PULLS_PER_SECOND / REGISTRY_PROXY_PULL_BURST |
50 / 200 |
The rate each runner and each organization may pull at. Requests, not bytes: the burst has to clear a whole image. |
REGISTRY_PROXY_TRACKED_METERS |
4096 |
How many runners and organizations are metered at once. Past it, callers share one meter rather than being refused. |
REGISTRY_PROXY_UPSTREAM_TIMEOUT |
30s |
Connect, TLS handshake, and the wait for response headers. Not the body: a blob legitimately takes minutes. |
ENVIRONMENT |
— | Reported to telemetry. |
OTEL_LOGGING_ENABLED / OTEL_TRACING_ENABLED |
false |
Export logs and traces over OTLP. |
OTEL_EXPORTER_OTLP_ENDPOINT |
— | Collector to export to. Both switches above are inert without it. |
OTEL_EXPORTER_OTLP_HEADERS |
— | Comma-separated key=value pairs. |
Build, test, run
Run these from apps/. The Go workspace is apps/go.work; commands outside it
will not resolve common-go.
yarn nx test image-service # go test ./...
yarn nx lint image-service # go vet ./...
yarn nx build image-service # dist/apps/registry-proxy
yarn nx serve image-service
Coverage is reported through make coverage:go from the repository root, which
is also what CI uploads.
Secret-reader tests use a local TLS server and temporary files. They verify malformed or oversized payload rejection, cancellation before a request, and missing-file errors without accessing real registry passwords.
Locally it is one of the native processes apps/infra-local supervises:
make up builds and starts it, and make restart COMPONENTS=registry-proxy
rebuilds it from source.
Deployment
mdeploy runs it as a Cloud Run service, declared in
providers/gcp/registry-proxy.ts.
AWS stages do not deploy one and report none. Three platform settings are not
defaults, and each is there because the default loses a pull:
| Setting | Why |
|---|---|
Ingress internal, invoker allUsers |
A caller's Authorization header already carries its runner credential for the registry protocol, so it has nowhere to put a Google identity token. Cloud Run's per-request IAM check is therefore off, the ingress is the restriction, and this process authenticates each caller itself. The two are one decision. |
HTTP/2 port (h2c) |
Cloud Run caps an HTTP/1 response at 32 MiB unless it is chunked. A blob relayed with the upstream's own Content-Length is not, so over HTTP/1 every layer past that size would fail in production and pass in every test. The binary serves HTTP/1 and HTTP/2 on one port. |
| Request timeout of an hour | A blob is one response and a large layer takes minutes. Cloud Run's default of five minutes cuts it off. |
A runner reaches it at its own run.app address, which the stack writes to both
the API, as the host of the refs it hands out for private images, and every
runner, as REGISTRY_PROXY_HOST. So the proxy is built before the API, and
reaches the API by api.<domain>, a name the domain fixes before either
exists. Runners are VMs on a subnet
with Google's private access, which is what lets them reach an internal-ingress
service without a load balancer — the same path they take to the telemetry
collector.
It runs as its own service account, not the control plane's, because it is
the one process that reads registry passwords. That account holds
secretmanager.secretAccessor on secrets named registry-credential-* and
nothing else in Secret Manager.
Known limits
- The rate limit is per process. Several instances multiply it, which is the trade for not putting a shared store on the pull path.
- Nothing caps how many relays run at once. The meter bounds how fast pulls arrive, and a blob is a single long response, so concurrent streams are governed by the instance count and its memory rather than by this service.
- The organization segment for an anonymous pull can be chosen by the runner, so the per-runner rate limit bounds anonymous forwarding. A credentialed pull checks that the runner hosts a box for the named organization.
- Addresses in
198.18.0.0/15are reachable, although that block is reserved for benchmarking. VPN and split-DNS resolvers hand it out for ordinary public hosts — on a machine running one,ghcr.ioresolves into it — and refusing it would refuse every pull there. The cost is that anything a network places in that range is reachable through this proxy as a public host would be. None of this stack's own ranges are in it (providers/gcp/network.ts), but the cloud permits it as a subnet range. There is no setting to refuse it: a deployment that must is a change tooffInternetininternal/proxy/guard.go. - An allowed registry names its own token endpoint. An anonymous exchange
accepts any HTTPS one, since it carries nothing. An exchange that carries a
login accepts only the registry's own host and the ones in
tokenHostsBeyond(internal/proxy/token.go); a registry that moves its token endpoint elsewhere fails private pulls until that table names it.