feat: add --cache-ref flag for registry-based BuildKit layer cache#518
Open
ccc-uglydawg wants to merge 3 commits intorailwayapp:mainfrom
Open
feat: add --cache-ref flag for registry-based BuildKit layer cache#518ccc-uglydawg wants to merge 3 commits intorailwayapp:mainfrom
ccc-uglydawg wants to merge 3 commits intorailwayapp:mainfrom
Conversation
Adds a --cache-ref CLI flag that configures BuildKit to use a remote container registry for layer cache import/export (type=registry). This enables stateless CI/CD workers to share build cache across deploys by storing layers in the customer's own container registry, rather than relying on local disk cache that is lost on pod restart. Usage: railpack build . --cache-ref registry.example.com/cache:latest
Collaborator
|
@ccc-uglydawg seems like a great improvement! Do you know if builtkit will throw an error if a bad cache registry is provided or should we do some sort of validation there? |
BuildKit needs Docker credentials to push/pull cache from private registries when using --cache-ref. Attach authprovider to the session so it reads ~/.docker/config.json (populated by crane auth login or docker login) for registry authentication.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
--cache-refCLI flag that configures BuildKit to use a remote container registry for layer cache import/export (type=registry).This enables stateless CI/CD workers to share build cache across deploys by storing layers in a container registry, rather than relying on local disk cache that is lost on pod restart.
Usage
railpack build . --cache-ref registry.example.com/cache:latestChanges
cli/build.go: Add--cache-refstring flag, pass toBuildWithBuildkitClientOptionsbuildkit/build.go: AddCacheReffield, configureCacheImports/CacheExportswithtype=registryandmode=maxContext
BuildKit natively supports registry-based cache via
CacheImports/CacheExportswithtype=registry. Railpack already supports GHA cache (ImportCache/ExportCachefields withtype=gha) but doesn't expose registry cache. This is a small addition that unlocks stateless build workers for multi-tenant platforms where each customer has their own registry.