Summary
Cache registry image manifest/config metadata in the engine content store after tag resolution so repeated container.from("tag") calls do not re-download the same metadata across canonical resolution, lazy pull, and later sessions.
The resolver still revalidates tag refs with registry HEAD requests. If the tag now points at a new digest, the new manifest/config metadata is fetched and stored, so this avoids repeated metadata GETs without over-caching mutable tags.
Details
Before this change, the current resolver path rebuilt short-lived containerd resolvers/fetchers for ResolveImageConfig and later pull work. Even when the tag digest had not changed, the same manifest and config could be fetched repeatedly instead of being reused from the engine-wide content store. On registries like Docker Hub, duplicate manifest GETs are the request class most likely to affect pull quotas.
This adds a metadata-only resolver path that:
- resolves tags remotely as before, preserving freshness;
- stores fetched manifest/config descriptors and bytes in the engine content store under a short lease;
- attaches distribution source labels so local reuse is scoped to the registry source;
- reuses local manifest/config metadata by digest when the tag still resolves to the same descriptor;
- fetches metadata again when the tag resolves to a new manifest digest.
This does not reintroduce BuildKit's shared resolver/auth pool. Auth/token behavior remains per current resolver/session behavior.
Tests
go test ./core/integration -run '^$'
dagger --progress=plain call go lint --include core/integration/container_registry_cache_test.go
dagger --progress=plain call engine-dev test --pkg ./core/integration --run='TestContainer/TestFromTagCachesManifestMetadataAcrossSessions'
The focused integration test uses a mutable counting OCI registry. It verifies:
- two sequential sessions against the same tag fetch manifest/config/layer data once;
- the tag is still revalidated with
HEAD;
- after pushing a new image to the same tag, Dagger reads the updated image;
- exactly one additional manifest/config/layer fetch occurs for the new digest.
Observed final local counts after the tag update:
{ManifestGETs:2 ManifestHEADs:5 ConfigGETs:2 LayerGETs:2}
CI test-split:test-container passes on the pushed head.