Release the mount or temp dir in CreateFS on every error path. An invalid
src could previously leak a mount for each failed export, and failing
attestation steps had the same leak.
Pass src to fs.RootPath unmodified so symlinks are resolved before "..",
and stop trimming whitespace from the value. Keep the underlying error
when reporting src failures so errors.Is still matches.
Add tests for mount release, mode=delete and platform-split=false with
src, and make the src error assertions work on Windows. Note in the
README that older daemons ignore src.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Adds a `src` option to the local and tar exporters, so a subdirectory of the
build result can be exported without a dedicated scratch stage.
buildctl build ... --output type=local,dest=./out,src=/usr/src/app/reports
The contents of `src` land at the root of the destination. Symlinks are resolved
within the build result via `fs.RootPath`, so an absolute symlink in the image
cannot escape to the daemon's filesystem.
`src` takes a single literal path, so the glob patterns raised in the issue are
not covered. Two further cases are deliberately left out and can follow up
depending on what you prefer: an empty `src=` combined with `mode=delete`, and
`src` pointing at a single file rather than a directory.
Updates https://github.com/moby/buildkit/issues/874
Signed-off-by: Alex G. Wolff <13754094+alexgwolff@users.noreply.github.com>
Replace Windows path separators and drive separators when platform IDs are
used as local and tar exporter path components. Add a regression test for tar
exporter output generated from frontend-controlled platform metadata.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
ImageWriter.Commit now returns the committed remotes (the rewritten
layers when rewrite-timestamp is set) as Result[Remote], and unpackImage
consumes them instead of re-fetching the original (non-rewritten) layers
from the source ref. The provider of a rewritten remote preserves the
Unlazier of the original provider, so that non-rewritten lazy layers can
still be fetched before unpacking.
Fixes issue 4230
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
- Updated multiple instances across various files to replace errors.Errorf with errors.New for error message creation.
- This change enhances consistency in error handling throughout the codebase.
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Replace Windows path separators and drive separators when platform IDs are
used as local and tar exporter path components. Add a regression test for tar
exporter output generated from frontend-controlled platform metadata.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Ref and rootfs helpers may read paths supplied by frontends or build outputs.
Reject non-regular files before reading them into memory so device and FIFO
paths cannot feed no-EOF streams into parsers or bundle injection logic.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Apply the oci-mediatypes default at export time so the Docker tar exporter
does not treat variant=docker as implicit oci-mediatypes=false.
Keep Docker tar manifest.json output for legacy compatibility, and preserve
explicit oci-mediatypes=false behavior with test coverage.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Add compatibility-version 30 for the new OCI media type default while keeping
version 20 pinned to the historical image exporter behavior through v0.31.x.
Track omitted oci-mediatypes separately from explicit false, add v30
compatibility goldens, and document the supported compatibility versions.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Allow annotation and attestation exports with OCI media types enabled, fix
the zstd media type map, and update integration tests for the new default.
Keep Docker media types explicit where legacy behavior is under test.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This matches the documentation, which never specified behavior for
empty/unknown (non-boolean) strings.
We can also remove the parseBoolWithDefault helper, as this was the last
consumer.
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
To facilitate this change, we now fail when there is an exporter option
conflict instead of implicitly setting oci-mediatypes=true.
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
Use the existing in-toto-golang JSON statement types for attestation export
and set the statement type URI to in-toto v1. Remove the local protojson
compatibility wrapper so this patch only changes the emitted statement type.
Update in-toto-golang to v0.11.0 and refresh vendored module metadata.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Ensure the local exporter closes the progress writer after copying files so
progress readers are released when the transfer exits before a final callback.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Update non-generated code for the newer lint recommendations by using typed
atomic values, strings.Cut, and slices.Backward where applicable.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Add solve-wide compatibility-version support for image and oci
exports, with historical goldens and release compatibility tests.
Backfill version 10 for v0.13-v0.14 git artifact behavior, keep
version 20 as current, and reject unsupported zstd on v10.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Resolve SOURCE_DATE_EPOCH=context in the Dockerfile frontend from the
main build context and pass the resolved numeric epoch through normal
ARG handling and exporter metadata.
Use git commit time for git contexts, HTTP Last-Modified when present,
and newest archive entry mtime for HTTP archives. Leave local contexts
unset.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Propagate Dockerfile-defined SOURCE_DATE_EPOCH through frontend result
metadata so exporters can consume it, including per-platform export
paths and rewrite-timestamp handling.
Refactor Dockerfile2LLB to return a structured result, preserve exporter
reset semantics, and cover the exporter-facing behavior with Dockerfile
integration tests.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Use ApplyLayers instead of per-layer ApplyLayer loop to
allow recursive parent rebuild when GC collects a parent
snapshot between Stat and Prepare calls.
Pre-lease the top chain ID snapshot before calling
ApplyLayers so that GC cannot collect it during the Stat
shortcut path which does not add snapshots to the lease.
Fixes#6521
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
When image was (externally or in parallel build request) created
in between Update and Create calls, Create can fail.
Handle this case by running Update again.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Split image export into two phases to enable parallel execution:
1. Export creates artifacts (layers, manifests) in the content store
2. FinalizeFunc pushes artifacts to the registry
This allows image push to run in parallel with cache export, reducing
overall build time when both image and cache exports are configured.
The cache exporters run after image Export completes, ensuring they can
see and reuse the layers in the content store.
Signed-off-by: Amr Mahdi <amrmahdi@meta.com>
Currently it is not possible to update to more
recent version as modernize causes errors in generated code.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
When receiving a remote error due to an unexpected status code, read the
body and try to decode either a docker.Error or a simpler {"details"...}
payload. If those succeed, decode and format them appropriately. Otherwise,
fallback to displaying the raw response body which might contain valuable
information to indicate why authentication failed.
Signed-off-by: Alberto Garcia Hierro <damaso.hierro@docker.com>
Currently the option only worked when platform-split=false was
set for multi-platform build but not for setting single platform
build to use platform-split=true.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>