119 Commits

Author SHA1 Message Date
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
3254832159 solver: add proxy network mode
Add a build request option that rewrites default exec networking to an
internal proxy network while preserving explicit none networking.

Route HTTP and HTTPS traffic through a BuildKit-owned proxy namespace, enforce
source policy checks for proxied requests, and inject a temporary CA into Linux
rootfs trust bundles for HTTPS interception.

Share namespace pooling between CNI and proxy providers, and cover proxy mode
with unit and integration tests.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:00 -07:00
Jiří Moravčík
d14a00065f client: add reset option for local cache exporter
Add `reset=true` attribute to the local cache exporter that removes
unreferenced blobs from the cache directory after export, preventing
unbounded growth.

Signed-off-by: Jiří Moravčík <jiri.moravcik@gmail.com>
2026-05-07 23:06:26 +02: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
Jonathan A. Sternberg
22ba88969e chore: remove deprecated client.SolveOpts.LocalDirs member
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2026-04-09 15:07:02 -05:00
Tonis Tiigi
95a18e5230 client: improve local cache import validation
Make sure that the cache importer doesn't fail the build
if there is issue with the source, only if there is issue
with parameters.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-03-04 23:39:41 -08:00
Silvin Lubecki
961bf277d4 client: use inactivity timeout for status stream shutdown
Instead of using a fixed 3-second timeout after solve completion,
use an inactivity-based timeout that waits 5 seconds since the last
received status message. This prevents premature stream closure when
status messages are still being delivered through slow connections
(e.g., proxied environments).

Also ignore context.Canceled errors in the status goroutine to avoid
failing builds when the inactivity timeout triggers - the build itself
succeeded, we just may have missed some final status messages.

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2025-12-05 17:01:13 +01:00
Tonis Tiigi
f79f1a98c4 policysession: dynamic source policy support
Add support for dynamic source policies via client session.

Client session can allow or deny specific source or
ask additional metadata information via sourcemetaresolver if
that is needed to make the decision.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-11-05 14:28:13 -08:00
Justin Chadwell
dce5cac210 client: allow configuring exporter content store
Signed-off-by: Justin Chadwell <me@jedevc.com>
2025-06-24 11:18:24 +01: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
c6a1dcd6b5 lint: correcting errorlint and some err113 cases
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:19:22 -07:00
Tonis Tiigi
58faf412f3 exporter: add session exporter capability
This allows client to defer exporter selection to
the the time where build has completed.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-04-10 22:15:19 -07:00
Jonathan A. Sternberg
03bab826e3 exporter: expose image.name constant for the exported image name
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-03-20 09:21:28 -05:00
Tonis Tiigi
910c4c3ec6 go.mod: update minimum go version to go1.23
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-03-18 17:58:45 -07:00
Tonis Tiigi
05a451e15b add autoallow and entitlements support to CDI devices
Devices can be marked as "automatically allowed" by TOML config
or by the CDI spec of specific file via annotation.

Device that is is not "automatically allowed" needs to be allowed
by the build request by passing entitlement. For example a Dockerfile
may not use a device without use invoking the build permitting it.

--allow device grants access to any device.
--allow device=kind|name grants access to specific device.
--allow device=kind|name,alias=kind|name allows mapping kind to
a specific device or one device to another. Alias is the name requested
by the build and device is the actual device that is being enabled.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-02-13 23:17:37 -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
Tonis Tiigi
01cf0c69fb ociindex: fix handling multiple names per descriptor
Previous implementation mixed tags and names and
added invalid comma-separated reference annotation.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-01-07 14:32:38 -08:00
Jonathan A. Sternberg
41a0a0c37d protobuf: add vtproto as a supplemental marshaler
vtproto is an extra protobuf compiler that generates special methods
suffixed with `VT` that create typed and unrolled marshal and unmarshal
functions similar to gogo that can be used for performance sensitive
code. These extensions are optional for code to use but buildkit uses
them.

A codec is also included to utilize vtproto for grpc code. If the
package `github.com/moby/buildkit/util/grpcutil/encoding/proto` is
imported then vtproto will be used if it exists and otherwise it will
use the standard marshaling and unmarshaling methods.

This codec has an important difference from the default codec. The
default codec will always reset messages before unmarshaling. In most
cases, this is unnecessary and is only relevant for `RecvMsg` on
streams. In most cases, if we are passing in an existing message to this
method, we want to reuse the buffers. This codec will always merge the
message when unmarshaling instead of resetting the input message.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-10-04 12:52:15 -05:00
Jonathan A. Sternberg
1a3fc0aa15 protobuf: remove gogoproto
Remove gogoproto in favor of the standard protobuf compiler. This
removes any nonstandard extensions that were part of gogoproto such as
the custom types.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-09-26 12:57:45 -05:00
Tonis Tiigi
ab2c224e72 session: remove session name property
This seems to be completely unused.

I believe it is remnant of pre-buildkit session implementation
and was used for either logging of some transfer reuse.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-19 17:22:04 -07:00
Tonis Tiigi
dfc35271ae simplify with maps pkg functions
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-12 18:33:30 -07:00
Justin Chadwell
1c1777b7c0 exporter: use implicit ids for exporters
We can derive exporter ids from their place in the exporter array in a
SolveRequest - this removes the need to manually generate and handle
multiple sets of IDs.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-05 12:04:28 +00:00
Justin Chadwell
7fb54984ea control: add multiple exporters
This patch adds support for multiple exporters at the control API, and
propogates the resulting required changes through the client and the
solver.

A few notable changes:
- Each exporter instance now has an associated identifier
- Build records in the build history now have multiple possible
  descriptors to built content
- Exporter responses are all merged together (like we currently do with
  multiple cache exporters). We likely will need to revisit this design
  later, since now cache exporters do not line up one-to-one with
  exporters.

For backwards compatability, new clients will continue to produce
requests that contain the now deprecated exporter fields, as well as the
new ones. New servers will attempt to use deprecated fields if they
are present.

Co-authored-by: a-palchikov <deemok@gmail.com>
Co-authored-by: fahed dorgaa <fahed.dorgaa@gmail.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-05 12:04:28 +00:00
Justin Chadwell
81b4762291 session: add file send multiplexing
This patch adds multi-plexing to the local file transfer protocol (from
server to client). This is implementation-wise similar to the
multiplexing from the containerd content store transfer protocol, using
a GRPC header to select the appropriate target.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-05 12:04:28 +00:00
Justin Chadwell
a80b48544c session: create helper type for exporter file output
Co-authored-by: a-palchikov <deemok@gmail.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-05 12:03:39 +00:00
Tonis Tiigi
8a2a3e83ec replace context.WithCancel with WithCancelCause
Keep stack traces for cancellation errors where possible.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-12-06 22:15:06 -08:00
Justin Chadwell
0f343f9e02 client: refactor to extract prepareMounts
Now we error out if there is any clash between LocalDirs and
LocalMounts.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-10-23 12:52:39 +01:00
Justin Chadwell
cef8b800a9 client: allow exposing fsutil.FS through SolveOpts
This completes propogating the fsutil.FS abstraction into the SolveOpt,
deprecating the old LocalDirs.

Since this is entirely a golang-level abstraction, we could potentially
investigate just removing the old LocalDirs directly.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-10-23 12:48:34 +01:00
Justin Chadwell
11b8c6e0b6 session: modify FSSync provider to take fsutil.FS objects
This patch modifies the function signature of the FSSync provider to
take an fsutil.FS instead of a simple raw path resolved to the client's
root filesystem.

Internally, we were already creating an fsutil.FS to Send to the
buildkit server, however, this abstraction didn't reach the session
attachable parameters, so we couldn't provide our own custom FS
implementation.

The rationale behind this change is to allow providing more abstract
custom filesystem implementations to a BuildKit client. This way, we can
start to build from filesystems that might not be on disk - for example,
we could use our Static filesystem implementation in tests to prevent
creating lots of temporary directories, or we could use our Merge
filesystem implementation to allow easily creating variants of a single
context.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-10-23 12:48:34 +01:00
Alex Couture-Beil
d32660a238 fix error message typo
Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
2023-02-28 09:50:30 -08:00
Tonis Tiigi
e7ff7eae83 client: make sure ref is configurable for the history API
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-01-24 18:25:55 -08:00
Justin Chadwell
49c2275f65 ociindex: refactor to hide implementation internally
This allows some of the client processing code to abstract more over the
details of how the ociindex package works, and how it loads tags - the
calling code only need to know that it's being pointed at a containerd
content store directory.

Importantly, this allows for reusability, so we can use this same code
more easily in buildx for oci-layouts.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-14 18:26:41 +00:00
Brian Goff
7526659ab0 Update source pinning to use proposed policy
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:01:54 -08:00
Akihiro Suda
0d3f71ee18 llbsolver: support pinning sources
Alternative to PR 2816 ("dockerfile: support Dockerfile.pin for pinning sources")

This version is implemented on the llbsolver side and agnostic to the LLB frontends.
See `solver/llbsolver/vertex.go:loadLLB()`.

See `docs/build-repro.md` for the usage.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-12-13 13:01:54 -08:00
Tonis Tiigi
fe0c8d352a history api: allow internal builds that are not tracked
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-12 22:15:40 -08:00
Tonis Tiigi
be6e1cf55e history api: support for logs of completed builds
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-12 22:15:40 -08:00
Justin Chadwell
1050795af1 client: solve method should not modify opt argument
Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-08 14:14:15 +00:00
Tonis Tiigi
dbee61670d add build history APIs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-11-22 23:59:33 -08:00
Justin Chadwell
2c3637fb26 named contexts: prefix oci named contexts with "oci:"
This mirrors the structure of the names for the local cache directory,
as well as the names for the oci exporter (when using a content store).
This ensures that we cannot encounter name collisions (intentionally or
unintentionally).

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-11-16 12:43:43 +00:00
Justin Chadwell
0b30cfa120 client: write index.json for unpacked oci
Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-11-16 12:43:43 +00:00
Justin Chadwell
2808b5b263 oci exporter: support unpack option
This feature adds support for specifying unpack=true to the oci exporter
options to unpack the resulting result for the client.

To do this, we setup a content store on the client, and forward it
through to the server, which can then copy the exported data into the
content store.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-11-16 12:43:43 +00:00
Alex Suraci
3548517cf2 allow dynamic LocalDir access
Changes the filesync attachable to accept an interface instead of a
static allowlist of dirs. This way a single session can support syncing
directories not known ahead of time.

Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
2022-10-26 21:04:57 -04:00
Justin Chadwell
da3357f81a cache: support tag field for local cache exporter
Allow overriding the tag field for the local cache, which enables
"scoping" cache exports, to allow multiple outputs to a single location.

This was previously enabled only for importing cache, but exporting
cache was never implemented.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-09-13 17:43:33 +01:00
Tõnis Tiigi
46c8b9ee45 Merge pull request #2982 from jonnystoten/remove-legacy-cache-options
Stop using legacy cache import/export in client
2022-08-25 18:29:47 -07:00
coryb
5674c2d470 do not close sessions after client solve if pre-initialized
This fixes what appears to be a bug from an old refactor to allow
shared sessions:
ef58b61d83

Without this, the session cannot really be shared effectively.

Signed-off-by: coryb <cbennett@netflix.com>
2022-08-01 23:07:15 -07:00
Jonny Stoten
c5242ba8fb Add simple validation for registry cache ref
Signed-off-by: Jonny Stoten <jonny.stoten@docker.com>
2022-07-26 12:55:16 +01:00
Jonny Stoten
3bf816164f Stop using legacy cache import/export in client
This also fixes the bug where registry cache options with a missing ref
would be silently discarded by the server-side component that turns the
legacy settings into the new settings.

Signed-off-by: Jonny Stoten <jonny.stoten@docker.com>
2022-07-26 12:50:40 +01:00