feat: enable Docker image export to cache instead of direct push #248
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.
Description
This PR adds support for exporting Docker images to cache instead of pushing them directly to registries, enabling SLSA Level 3 compliance for Docker packages.
Problem
Currently, Docker images are pushed directly to registries during the build phase, bypassing Leeway's cache signing workflow. This prevents SLSA Level 3 compliance because:
Solution
Adds an optional
exportToCache
field to Docker package configuration:false
(default): Legacy behavior - push directly to registrytrue
: Export image to cache as.tar
file for signingKey Features
Changes
exportToCache
field toDockerPkgConfig
--docker-export-to-cache
with proper precedence handlingLEEWAY_DOCKER_EXPORT_TO_CACHE
for CI/CDUsage Examples
Package Configuration:
CLI Override:
Environment Variable:
Cache Artifact Structure
When
exportToCache: true
, the cache artifact contains:image.tar
- Full Docker image (fromdocker save
)imgnames.txt
- List of image tagsdocker-export-metadata.json
- Structured metadata (digest, build time, etc.)metadata.yaml
- Custom metadata (if configured)Related Issue(s)
Fixes https://linear.app/ona-team/issue/CLC-2009/docker-export-mode-for-slsa-l3-compliance-leeway
Depends on #242
Depends on #245
How to test
1. Test Default Behavior (Backward Compatibility)
2. Test Export Mode via Package Config
3. Test CLI Flag Override
4. Test Environment Variable
5. Test Metadata Extraction
6. Run Unit Tests
Documentation
leeway build --help
has been updatedexportToCache
field documentation in Docker packages sectionleeway build --help
/hold