fix: support container extraction with OCI layout export #290
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.
Problem
When
exportToCacheis enabled, Docker images are exported in OCI layout format (not loaded into Docker daemon). The container filesystem extraction code usescheckImageExists()which callsdocker image inspect, failing for OCI layout images with:This blocks packages that use
containerextraction (e.g., extracting files from a Docker image to use in subsequent builds) when SLSA L3 caching is enabled.Root Cause
The
PostProcessfunction in Docker package builds always validates the image exists usingcheckImageExists(), which assumes the image is in the Docker daemon. With OCI layout export, the image is written toimage.tarin the build directory and never loaded into the daemon.Solution
Add
checkOCILayoutExists()function to validate OCI layout images by checking forimage.tarin the build directory. UpdatePostProcessto use the appropriate validation based on theexportToCacheflag:exportToCache=false→ usecheckImageExists()(Docker daemon)exportToCache=true→ usecheckOCILayoutExists()(OCI layout)Changes
pkg/leeway/build.go:checkOCILayoutExists()function (lines 2040-2065)PostProcessto use appropriate check based onexportToCacheflag (lines 2793-2825)pkg/leeway/build_oci_test.go:TestCheckOCILayoutExistswith 4 test cases covering:pkg/leeway/build_integration_test.go:TestDockerPackage_ContainerExtraction_Integrationwith 2 subtests:with_docker_daemon: Docker daemon pathwith_oci_layout: OCI layout pathTestDockerPackage_ExportToCache_Integrationto create docker-container builderTestDockerPackage_CacheRoundTrip_Integrationto create docker-container builder.github/workflows/integration-tests.yaml:workflow_dispatchtrigger for manual test runsREADME.md:docker/setup-buildx-actionuses docker-container by defaultTest Results
✅ All integration tests passing:
TestDockerPackage_ExportToCache_Integration(3 subtests) - OCI layout export functionalityTestDockerPackage_CacheRoundTrip_Integration- Complete cache workflowTestDockerPackage_OCILayout_Determinism_Integration- Deterministic builds (critical for SLSA L3)TestDockerPackage_OCILayout_SLSA_Integration⭐ - PRIMARY SLSA L3 TEST - End-to-end provenance generationTestDockerPackage_ContainerExtraction_Integration(2 subtests) - Container extraction with both pathsBoth Docker daemon and OCI layout paths verified working correctly with no "image not found" errors.
Related Issues
Part of the OCI layout + SLSA L3 work:
How to Test
Run the integration tests:
All tests should pass, demonstrating container extraction works with both Docker daemon and OCI layout.
Documentation
Updated
README.mdwith OCI export requirements and docker-container builder setup instructions./hold