369 Commits
Author SHA1 Message Date
CrazyMax 37c5d2afe7 exporter: normalize annotation platforms
Normalize platform selectors in annotation keys to match exported image
platforms. Explicit linux/arm64/v8 selectors otherwise miss linux/arm64
images, silently dropping manifest and descriptor annotations.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-10-05 16:55:22 +02:00
Tõnis Tiigi ece70d28c1 Merge pull request #7226 from tonistiigi/local-exporter-src
exporter: add src option to local and tar exporters
2026-09-30 13:05:50 -07:00
Tonis Tiigi 71dc7cfbd6 errors: report build-facing paths on read failure
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 12bf293e5feee7393e971a1d22a191dff7f6e7f8)
(cherry picked from commit 5a01794b79c7af91a961b1236b0e0661975161d7)
2026-09-30 15:12:24 +02:00
Tonis Tiigi 1accd8ea20 openfile: reject special files in daemon reads
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 164c90a88ef0203f7160d212e54fdbdc97f6f355)
(cherry picked from commit 62c82f71f2e9f10ea3c014f2e21818f76b8649b8)
2026-09-30 15:12:24 +02:00
Tonis Tiigi 6e20be016d exporter: fix src error cleanup and resolution
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>
2026-09-29 18:28:54 -07:00
Tõnis Tiigi 9fc65986c4 Merge pull request #6939 from AkihiroSuda/fix-4230
exporter/containerimage: support unpack for rewrite-timestamp mode
2026-09-29 17:18:35 -07:00
Alex G. Wolff 836c3afef4 exporter: add src option to local and tar exporters
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>
2026-09-04 13:09:30 -03:00
Tonis Tiigi 2f96306a37 exporter: raise max attestation size to 80 MiB
Increase the shared attestation read limit and update its documentation.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-08-31 22:47:53 -07:00
Tõnis Tiigi 1dbcbf9f60 Merge pull request #7022 from crazy-max/platform-id-path-sanitize-followup
exporter: sanitize platform IDs in path components
2026-08-26 00:57:56 -07:00
CrazyMax 11c6b9c85c verifier: allow inferred Windows platform versions
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-08-25 15:01:29 +02:00
Tonis Tiigi 14ba4099c8 exporter: sanitize platform IDs in paths
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>
2026-08-24 16:01:46 +02:00
Akihiro SudaandClaude Fable 5 191ac2d199 exporter/containerimage: support unpack for rewrite-timestamp mode
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>
2026-08-24 19:06:15 +09:00
Matthieu MOREL 5a96f64d01 Refactor error handling to use errors.New for consistency
- 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>
2026-08-07 10:13:54 +02:00
Tonis Tiigi 56cf3cc0b5 Revert "exporter: sanitize platform IDs in paths"
This reverts commit 77b65abf49.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-07-07 09:09:47 -07:00
Tõnis Tiigi c130a532e6 Merge pull request #6910 from tonistiigi/platforms-id-sanitize
exporter: sanitize platform IDs in paths
2026-07-06 15:27:00 -07:00
Tonis Tiigi 77b65abf49 exporter: sanitize platform IDs in paths
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>
2026-07-02 17:24:55 -07:00
CrazyMax 9a16a73a42 exporter: default attestations to OCI artifacts
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-30 18:35:50 +02:00
Tonis Tiigi 9cdf642943 fs: reject special files for ref reads
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>
2026-06-26 00:02:39 -07:00
CrazyMax 86ddfea28e filesync: detect local export multi-platform transfer support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-11 18:53:07 +02:00
CrazyMax 73c67671d3 exporter: use root-backed fsutil receive instead of client-side staging
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-10 12:24:31 +02:00
CrazyMax 00764d4f69 exporter: add local exporter mode=delete
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-10 12:13:15 +02:00
Tonis Tiigi e9ed800105 exporter: default docker tar to OCI types
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>
2026-06-08 22:20:08 -07:00
Tõnis Tiigi 2ff20da8b4 Merge pull request #6824 from tonistiigi/oci-mediatypes
exporter/containerimage: default to oci-mediatypes=true
2026-06-04 08:45:50 -07:00
Tonis Tiigi 6147354ae5 exporter: add compatibility version 30
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>
2026-06-03 08:52:37 -07:00
Tonis Tiigi c4ce866e0f exporter: fix OCI media type test coverage
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>
2026-06-03 08:52:31 -07:00
Bjorn Neergaard 7e5cf25bde exporter/containerimage: document "oci-artifact=" values
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2026-06-02 23:11:12 -07:00
Bjorn Neergaard 54547ec0b1 exporter/containerimage: parse oci-mediatypes=bool strictly
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>
2026-06-02 23:11:12 -07:00
Bjorn Neergaard d4ebc6d55b exporter/containerimage: remove unnecessary errors.Errorf
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2026-06-02 23:11:12 -07:00
Bjorn Neergaard 9144af6feb exporter/containerimage: default to oci-mediatype=true
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>
2026-06-02 23:11:12 -07:00
Bjorn Neergaard 4485d304c7 exporter/containerimage: remove unused EnableForceCompression
This helper has not been used for some time.

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2026-06-02 23:11:11 -07:00
Tonis Tiigi f21f35fad0 attestation: emit in-toto v1 statements directly
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>
2026-06-02 23:09:19 -07:00
CrazyMax 284e944657 attestation: switch exporter paths to in-toto v1 json wrapper
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-02 23:04:19 -07:00
CrazyMax faffd6c4df attestation: add in-toto v1 json compatibility wrapper
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-02 23:04:17 -07:00
Tonis Tiigi 23f04e103e exporter: close local export progress writer
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>
2026-05-29 18:20:54 -07:00
Tonis Tiigi 98e1113c6d lint: modernize Go lint findings
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>
2026-05-14 10:13:21 -07:00
Tõnis Tiigi c1b5264bfd Merge pull request #6681 from tonistiigi/compat-version
solver: add compatibility-version support
2026-04-27 14:21:38 +02:00
Tonis Tiigi 5fde446dee solver: add compatibility-version support
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>
2026-04-10 09:24:11 -07:00
Tonis Tiigi 4e1c8acd57 dockerfile: support SOURCE_DATE_EPOCH=context
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>
2026-04-08 15:27:20 -07:00
Tonis Tiigi 9b56be75f3 exporter: propagate Dockerfile default epoch
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>
2026-03-23 22:16:46 -07:00
Tonis Tiigi 7cb764d22f exporter: fix snapshot GC race during image unpack
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>
2026-03-05 16:22:20 -08:00
Tonis Tiigi 8349e9cd7c containerimage: fix possible race on parallel image create
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>
2026-02-05 15:39:13 -08:00
Amr Mahdi 88ef66c6b3 solver: run image and cache exports in parallel
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>
2026-02-04 18:21:35 -08:00
Tonis Tiigi 55ac82cb58 hack: update gopls to v0.38.0
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>
2026-01-13 22:09:25 -08:00
Tonis Tiigi 8d666d1872 exporter: expose build ref to the exporter as part of buildinfo
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-12-16 09:31:08 -08:00
CrazyMax d31230ea96 lint: gopls fixes
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-09-09 14:13:04 +02:00
CrazyMax 29deb6a492 fix subject for oci artifact of attestation manifest
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-09-06 17:50:23 +02:00
Alberto Garcia Hierro d84b119daf fix: display error details on unexpected response status code errors
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>
2025-07-14 19:37:50 +01:00
CrazyMax 3a4179cf42 local: fix attestation filename
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-06-25 18:14:01 +02:00
Anthony Nandaa 40ddcfca90 fix: wcow: privileges for local exporter
Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
2025-06-11 17:35:06 +02:00
Tonis Tiigi 41ee238815 local: fix platform-split=true option
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>
2025-06-11 11:33:14 +02:00