314 Commits

Author SHA1 Message Date
Tonis Tiigi
64bbec89ca security: validate exec security modes
Reject unknown SecurityMode values before generating executor specs. Ensure
only SecurityMode_INSECURE takes the insecure path, while validated non-insecure
modes keep sandbox security options. Add gateway, raw LLB, and LLB marshal
regression coverage for invalid enum values.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 972895718f963c71388aeebb7cff423ef6963a92)
2026-06-24 10:56:46 -07:00
Tonis Tiigi
c15eb2679f llb: add passthrough op
Add a passthrough LLB op that builds all inputs and exposes selected
inputs as outputs. Add State.Requires as a client shortcut for requiring
dependencies without returning their snapshots.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-08 11:26:15 -07:00
Jiří Moravčík
f85c740c2b solver: add per-step CPU and memory resource limits
Add support for setting cgroup resource limits (memory, memory-swap,
cpu-shares, cpu-period, cpu-quota, cpuset-cpus, cpuset-mems) on
individual build steps.

Signed-off-by: Jiří Moravčík <jiri.moravcik@gmail.com>
2026-05-27 11:34:13 +02:00
Maya Chen
3786f4e24d chore: fix duplicated words in llb, executor and dockerfile_test comments
Signed-off-by: Maya Chen <275405107+otjdiepluong@users.noreply.github.com>
2026-05-14 06:42:49 +00:00
Tonis Tiigi
9a0c5cb021 git: add git bundle source support
Support importing git sources from OCI or registry-backed bundle blobs
and exporting resolved checkouts as single-file git bundles.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-04-27 14:30:11 +02:00
Tonis Tiigi
8100e1edab source/git: add fetch-by-commit support
Allow git sources to fetch a pinned commit without resolving the ref
against the remote tip, while preserving cache keys for canonical
branch refs and covering the behavior with tests.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-04-16 16:10:30 -07:00
Tõnis Tiigi
1fc2d12b71 Merge pull request #6600 from tonistiigi/git-mtime-commit
source: add git.mtime attr for commit-time mtimes
2026-03-25 12:23:22 -07:00
Tonis Tiigi
d19ecc730c git: normalize and validate subdir paths
Normalize Git subdir fragments and validate checkout subdir components
so each segment must be a real directory, preventing traversal and symlink escapes.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 8c994eb561a2646b35352e5663afecd225306214)
2026-03-25 08:14:30 -07:00
Tonis Tiigi
508dd62bf7 source: add git.mtime attr for commit-time mtimes
Add git.mtime=commit option that normalizes all file, symlink,
and directory mtimes in a git snapshot to the resolved commit
timestamp. This enables reproducible builds from git sources.

When SOURCE_DATE_EPOCH is set in the Dockerfile frontend, the
git context automatically uses commit-time mtimes. The URL
query parameter ?mtime=commit|checkout can override this.

New LLB attr (git.mtime) and capability (source.git.mtime) are
registered as experimental. Cache keys include the mtime policy
so that commit-time and checkout-time snapshots are distinct.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-03-23 11:58:24 -07:00
Tonis Tiigi
e38020cdaa refactor: add typed sync.Map wrapper to eliminate type assertions
Introduce util/bkmaps.SyncMap[K, V] as a generic typed
wrapper around sync.Map. Migrate usages in definition,
builder, solver, and contentutil packages, removing
unchecked type assertions at each call site.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-03-09 22:15:43 -07:00
Tonis Tiigi
b61489948c tests: use t.Context in unit tests
Replace context.TODO/background calls in targeted unit tests with
t.Context().

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-02-25 16:41:54 -08:00
Tonis Tiigi
8874679130 source: add support for oci-layout+blob schema
Matching the docker-image+blob implementation.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-02-24 08:05:42 -08:00
Tonis Tiigi
9d821a3c12 source: update imageblob to new docker-image+blob and ref_type naming
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-02-24 08:05:42 -08:00
Tonis Tiigi
e12905644d source: imageblob source implementation
Image blob source in LLB allows addressing a single blob
from a container image registry. The difference from the image
source is that image source needs to point to a manifest that
internally points to an array of layer blobs that are all extracted
on top of each other to form a root FS. Contrary, image blob
points to a single blob that is not extracted but downloaded
as a single file into an empty snapshot, similarily how
the HTTP source works.

The main use case for this source is to pin snapshots of
HTTP URLs, upload the downloaded blob into container registry,
and then use a source policy to map a HTTP URL (whose content
might be changed) to the copy of the source as image blob
to ensure immutability.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-02-24 08:05:38 -08:00
Tonis Tiigi
e3fba18b63 source/http: add PGP verification and shared pgpsign
Add detached PGP verification for HTTP sources during metadata resolution
and expose LLB options/caps/attrs for signature validation.

Extract shared OpenPGP verification/parsing logic into util/pgpsign and
reuse it from git signing, plus add integration and source-level tests.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-02-20 08:13:38 -08:00
Tonis Tiigi
7f2cbc61ba http: add support for checksum requests for http sources
These requests allow computing additional checksum algorithms
for the payload of HTTP sources.

Optionally suffix can be passed that is added to payload. This
is needed to make validation of PGP signatures possible remotely.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-02-20 08:13:32 -08:00
Kevin L.
546a6d706a client/llb: add support for riscv64 architecture
Signed-off-by: Kevin L. <kevin.lecouvey@gmail.com>
2026-02-18 12:43:14 -05:00
Tonis Tiigi
b0ba823284 containerimage: add resolve attestation support
Allow ResolveSourceMetadata to resolve specific bytes
from the attestation manifest.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-02-09 15:27:33 -08:00
Tonis Tiigi
a13afb53c1 image: add attestationchain resolving to resolvesourcemeta
Attestation chain can be used by the client to verify
signature identity of the image.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-11-05 14:15:43 -08:00
Tonis Tiigi
b1118d8929 image: move image source resolver away from old interface
ResolveImageConfig was changed to ResolveSourceMetadata long time
ago for cross-source implementation but the worker implementation
was still using old method name with conversions.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-11-05 14:15:42 -08:00
Tõnis Tiigi
101d75400a Merge pull request #6229 from jsternberg/copy-parents
frontend: add required paths to LLB and use it with --parents
2025-10-22 11:18:02 -07:00
Tonis Tiigi
5f6a7ef751 source: add raw commit/tag object access to resolveMetadata
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-17 16:45:08 -07:00
Jonathan A. Sternberg
ac10b4193f frontend: add required paths to LLB and use it with --parents
This adds an additional `RequiredPaths` that is primarily intended for
use with `COPY --parents`. This parameter specifies expected directories
or files that should exist when performing the checksum. A not found
error will be produced if one of these paths is missing.

This fixes an issue with `COPY --parents` where a non existent directory
that was intended to be copied would be ignored.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-10-13 14:38:38 -05:00
Tonis Tiigi
b41ad2f121 http: add http support to ResolveSourceMeta
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-13 09:24:28 -07:00
Tonis Tiigi
70e5929715 git: add git commit support to ResolveSourceMeta
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-13 07:59:09 -07:00
Tonis Tiigi
aa003bef56 llb: add checksum option to llb.Image
This allows images to be pulled by tag and then
checked against the digest. If digest is added directly
to the image reference, then tag is ignored.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-09-19 17:40:40 -07: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
Tonis Tiigi
3765fe3587 dockerfile: add submodules controls to git URLs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-08-28 22:31:40 -07:00
Tonis Tiigi
8ef9b54fda llb: document fragment parameter in llb.Git
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-08-28 19:31:05 -07:00
Tonis Tiigi
81599425cb llb: update Git to allow normalized property passing
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-08-28 19:24:39 -07:00
Michael Dwan
21c35ed3d3 fix: corrected doc comment for llb.State.Env
The Env method returns the current environment variables for the state, not a new State with updated env variables.

Updated doc comment to reflect actual behavior.

Signed-off-by: Michael Dwan <m@dwan.io>
2025-07-17 08:27:18 -06:00
Akihiro Suda
6cbf02ae5b git source: add AttrGitChecksum
Not integrated to util/giturl, as PR 5974 is not merged yet.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-05-18 21:38:45 +09:00
Tõnis Tiigi
5666820e70 Merge pull request #5895 from profnandaa/fix-default-windows-path
windows: leave default PATH env to be set by the OS
2025-05-13 09:19:27 -07:00
Anthony Nandaa
14acf4c23d wcow: leave default PATH env to be set by the OS
The PATH is very critical during container runs on
Windows. Windows stores the PATH details in its
registry hive, while in unix, this is often
stored in the image's config. See further details
at #5445

Setting a default path like we do on Linux
(which is mostly not used since the PATH is
already set in the configs), works against
the expected build experience, especially when
it comes to installers and commands like `setx`.

Therefore, we skip setting the default PATH on
Windows, and leave it for the OS to load it
from its registry hive.

This also further supports backward compatibilitiy
with the current experience with docker classic
builder.

Users wishing to explicitly store this in the
configs can opt-in by using the ENV PATH= ..
in the Dockerfile, etc.

See also the same practices on Docker Engine
and Containerd:
- da3b31fb2c/oci/defaults.go (L24-L33)
- 041743e8af/pkg/oci/spec_opts_windows.go (L66-L69)

closes #5445

Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
2025-05-10 18:51:38 +03:00
Tonis Tiigi
9fcedf9807 update gopls to go1.24 compatible version
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-07 18:23:20 -07:00
Tonis Tiigi
69d3d44145 lint: add unconvert
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:44:01 -07:00
Tonis Tiigi
f1f56c2b77 golangci-lint: v2 upgrade
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:19:17 -07:00
CrazyMax
43fc7e8585 Merge pull request #5897 from tonistiigi/local-metadata-transfer
source: add metadata-only transfer option for local source
2025-04-11 17:50:29 +02:00
Tonis Tiigi
7ae0d6a903 source: add metadata-only transfer option for local source
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-04-11 07:38:29 -07:00
Tonis Tiigi
f6c142ec23 lint: update some sorting code to newer generics based libs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-03-20 10:32:02 -07:00
Tonis Tiigi
b5286f8dcb apply x/tools/modernize fixes
Autogenerated with couple of manual patches.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-03-07 08:18:45 -08:00
Dan Duvall
e19af64fe3 http: Support additional request headers
Support additional request header fields for HTTP sources, "Accept" and
"User-Agent" as a start.

The "Accept" header is required in some cases and some servers may vary
the response body based on the header value.

The "User-Agent" header may be useful in custom frontends and
potentially other cases.

 - llb: Add `llb.Header` and `HTTPInfo.Header` to allow `client/llb`
   users to set these header fields on HTTP sources. The argument to
   `llb.Header` is a struct to effectively limit header fields to a
   subset.
 - llb: Define and flag new `source.http.header` capability when
   `llb.Header` is used.
 - solver: Define new `http.header.` source attribute prefix. Giving
   each header field its own attribute (opposed to JSON encoding the
   header struct) will allow source policy to make assertions on
   individual header fields.
 - source/http: Parse `http.header.` attributes into a sorted slice and
   include them in cache key digest.
 - source/http: Set request headers accordingly.

Signed-off-by: Dan Duvall <dduvall@wikimedia.org>
2025-02-21 10:08:59 -08:00
Dan Duvall
ab1e99e19a http: Support authentication
Support authentication for HTTP sources.

 - llb: Define general `llb.AuthOption` interface composed of
   `HTTPOption` and `GitOption`.
 - llb: Refactor `llb.AuthHeaderSecret` to return an `llb.AuthOption` so
   it may be used with both `llb.Git` and `llb.HTTP`.
 - llb: Define `HTTPInfo.AuthHeaderSecret`.
 - llb: Define and flag new `source.http.auth` capability when
   `HTTPInfo.AuthHeaderSecret` is set.
 - solver: Define new `http.auth` source attribute.
 - source/http: If an `http.auth` attribute is specified, resolve a
   secret named by its value and set the "Authorization" request header.

Signed-off-by: Dan Duvall <dduvall@wikimedia.org>
2025-02-20 12:12:55 -08:00
CrazyMax
6667434ec4 cdi: support optional devices
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-02-11 11:21:47 +01:00
CrazyMax
319bf56d8d exec: cdi device support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-02-11 11:21:44 +01:00
Brian Goff
94ddeb7dbe Support OS version in platform string
This allows platforms following the new `platforms.FormatAll` function,
which allows for setting the `OSVersion` field of the platform with
`<os>(<ver>)/<arch>`.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2025-01-14 09:27:19 -08:00
Marat Radchenko
5be7edb69c Upgrade to containerd 2
Co-authored-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2025-01-13 16:42:48 -08:00
Peter Engelbert
20c2d03697 Implement llb.Symlink
* Add file.symlink.create capability and wire it up
* Run codegen for new FileActionSymlink Message
* Add Symlink test
* Add user/group ownership and timestamps to symlink
 ** Symlinks have user/group ownership that are independent of those of the
    target file; in linux, the ownership of the symlink itself is only
    checked when the link resides in a directory with the sticky bit set and
    the link is the subject of removal or renaming. The sticky bit prevents
    files in the directory from being deleted or renamed by non-owners
    (members of the group that owns the file may not delete the file; the
    user must own the file).

    In addition to user/group restrictions, linux symlinks have timestamps
    that are independent of the timestamps on the target file.
* Expose symlink options to `llb` package
* Add symlink integration test
* Use tar exporter for tests
 ** Using the local exporter causes the files to be exported with the
    permissions of the user who does the exporting, instead of retaining
    their file permissions from within the container.

    Using the tar exporter instead preserves the permissions until they can
    be checked.
* Change symlink fields to `oldpath` and `newpath`
 ** Also run `make generated-files`
* Fix typo
* Add doc strings to exported `llb` identifiers
* Remove `requiresLinux` from integration test
* Revert "Remove `requiresLinux` from integration test"
* Add fixes to please the linter

* testFileOpSymlink: check that symlink is created
* Address comments for FileOp llb test
* This commit also fixes a couple of linter complaints.
* Add check for symlink type in tar header
* Address PR review nit

Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
2025-01-03 17:10:02 -05:00
Tonis Tiigi
30413b5de7 llb: avoid concurrent map write on parallel marshal
Calling marshal changes the internal state of the op, for example
addCap() helper adds capability constraints. These can race with
same map being read by another Marshal call. Locking the Marshal
function itself also makes sure that the cache is not recomputed
in this case.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-12-06 17:53:59 -08:00
Anthony Nandaa
ca6e771245 tests: add testDockerfileFromHTTP for WCOW
Enables `testDockerfileFromHTTP` integration test
for Windows.

Also fixes a bug where paths were being joined wrongly,
for example:

```go
path.Join("/", "\\context") // would be "/\\context"
```

Addressing tests marked as Revisit for #4485

Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
2024-11-17 20:21:42 -08:00