578 Commits

Author SHA1 Message Date
ZRHann
b69e279bcd config: fix a default GC policy filter never matching any record
The first default GC policy is meant to prune the most easily
reproducible cache (local sources, cache mounts, git checkouts) once it
exceeds 512MB and has not been used for 48h. Its filter was written as a
single comma-joined string:

    "type==source.local,type==exec.cachemount,type==source.git.checkout"

Each element of the Filters slice is passed to
containerd/filters.ParseAll, where commas within one string are ANDed
together. A record only ever has a single type, so the AND can never be
satisfied: this policy matched nothing and was effectively a no-op.

Split the filter into separate slice elements so they are ORed, matching
the documented intent and the array form already used in user
buildkitd.toml configs.

Signed-off-by: ZRHann <zrhann@foxmail.com>
2026-06-10 21:33:15 +08:00
CrazyMax
ef191af965 vendor: github.com/urfave/cli/v3 v3.9.0
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-10 10:12:36 +02:00
Tõnis Tiigi
c6626669bc Merge pull request #6740 from tonistiigi/exec-net-proxy
solver: add proxy network mode
2026-06-08 10:09:34 -07:00
CrazyMax
bd53b4191f bound telemetry shutdown when trace forwarding stalls
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-05 16:48:22 +02:00
Jonathan A. Sternberg
d4ac72d232 control: forward traces in a non-blocking goroutine
Traces are now forwarded in a non-blocking goroutine when sent through
the traces exporter. This prevents traces forwarded from the client from
being stalled while waiting for an upstream uploader to appear.

In addition, adds a shutdown context to `appcontext` that will only
cancel when an interrupt has been received twice. One interrupt will
signal the program should clean up and shut down, the second indicates
we should skip shutdown procedures (more forceful), and the third will
indicate that we should immediately terminate the program.

This gives a bit more of a degree of control to shutdown procedures like
the traces and metrics exporter so there's a difference between forcibly
calling exit and just waiting a long time for the shutdown to happen.

Includes a more aggressive shutdown timeout for `buildctl` that is
similar to the export timeout on `docker-buildx` for the tracing
shutdown as another preventative measure to ensure the CLI hangs up at
an appropriate time interval.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2026-06-05 15:55:22 +02:00
Tonis Tiigi
023022108c buildkitd: add daemon proxy network option
Add a proxyNetwork TOML setting and --proxy-network daemon flag to enable
exec proxy enforcement for every build. Wire the default through controller
and solver setup while preserving per-build enablement.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:02 -07: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
Tonis Tiigi
1ee85bf91f vendor: update fsutil with umask-aware MkdirAll
MkdirAll now chmods each created directory to the requested perm so a
non-zero process umask no longer leaves directories with the wrong mode.

buildkitd and buildctl set the umask to 0 at startup, so set the new
copy.UmaskIsZero flag in both to skip the now-redundant per-directory
chmod.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-03 16:02:47 -07:00
Ava Barron
f3f5f546eb solver/llbsolver: emit native build-completion metrics
Threads the existing OTEL MeterProvider through llbsolver.Opt and emits
three build-event instruments from the recordBuildHistory finalizer:

  - buildkit.builds (counter; labels: status, error_code)
  - buildkit.builds.steps (counter; labels: kind)
  - buildkit.build.duration (Base2 exponential histogram; labels: status)

The duration histogram uses an exponential aggregation, rendered as a
Prometheus native histogram by the existing exporter, to avoid the
"tens of millions of series" cardinality blow-up reported in #5777.

MeterProvider is passed explicitly through the constructor — buildkit
policy (per the #4957 review) prohibits relying on the OTel global
provider in library packages.

error_code uses gRPC codes.Code.String() for a bounded set;
rec.Error.Message is intentionally never used as a label. The frontend
label is intentionally omitted — client.Build clears req.Frontend on
the wire, so the field is empty for every caller that goes through the
gateway-client API (buildctl, buildx). The metric is forward-compatible
with a future buildkit change that populates rec.Frontend on that path.

A follow-up PR will add observable gauges for worker count and cache
state, plus an operator guide at docs/metrics.md.

Refs #1544; addresses discussion #5777.

Signed-off-by: Ava Barron <abarron@coreweave.com>
2026-05-28 12:57:43 -04:00
Jonathan A. Sternberg
ac1f99224c util/resolver/limited: make registry concurrency configurable by the configuration file
Adds a new field to the system configuration that sets the maximum
concurrency for registry connections.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2026-05-21 13:08:27 -05:00
Tõnis Tiigi
4f42761308 Merge pull request #6705 from tonistiigi/provenance-dockerfile-version
provenance: add dockerfile frontend version
2026-05-06 17:57:13 -07:00
Jonathan A. Sternberg
937eaf88c8 feat: add log level option to buildkitd config
This adds a way to set the log level of buildkitd outside of using
`--debug` or `--trace` which allows increasing the log level rather than
only lowering it.

The `--debug` and `--trace` options are now deprecated along with the
configuration options. A warning will be printed to the log when they
are used.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2026-05-06 13:55:07 -05:00
Tonis Tiigi
1890989989 version: expose Dockerfile frontend version
Expose the builtin Dockerfile frontend version in BuildKit version
APIs and buildctl debug output.

Move Dockerfile version logic into frontend/dockerfile/version and
validate that the builtin version constant matches release tags.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-05-06 10:42:32 -07:00
Jonathan A. Sternberg
265c6e08ff otel: refactor tracing helpers for child processes
Merge the `tracing/env` and `tracing/exec` package into a single package
with some common types shared between the two.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2026-04-16 10:28:19 -05:00
Tonis Tiigi
b3335475ee exporter: fix reporting push progress under export vertex
Wrap finalize calls in inBuilderContext with the same vertex
ID used during export, so push status (layers and manifest)
appears under the "exporting to image" vertex in the progress
stream instead of being reported without a parent context.

This broke when pushing was moved to be parallel step after
main export phase.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-03-17 00:19:49 -07:00
Tõnis Tiigi
69dd137ab1 Merge pull request #6474 from rsteube/master
buildctl: enabled bash completion
2026-02-05 10:55:53 -08:00
Sebastiaan van Stijn
6f97c96ea6 migrate to github.com/pelletier/go-toml/v2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-02-02 22:08:25 +01:00
rsteube
9df8dbec60 buildctl: enabled bash completion
Signed-off-by: rsteube <rsteube@users.noreply.github.com>
2026-01-19 23:15:57 +01:00
Tõnis Tiigi
38a4ba9771 Merge pull request #6458 from tonistiigi/policy-deny-msg
policy: propagate deny messages from policy error
2026-01-14 07:32:55 -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
a8b83196f3 ci: update golangci to v2.8.0
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-01-13 22:09:20 -08:00
Tonis Tiigi
51376425c5 policy: propagate deny messages from policy error
If policy responds deny messages, make sure they
carry over to the build error.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-01-13 17:14:30 -08:00
Tõnis Tiigi
cc0fbe984f Merge pull request #6397 from tonistiigi/gha-signed-cache
gha: add signed cache support
2026-01-06 14:58:42 -08:00
CrazyMax
ed6dc749ce Merge pull request #6408 from tonistiigi/authprovider-callback
authprovider: make it possible to provide custom AuthConfig providers
2026-01-06 16:46:23 +01:00
Tonis Tiigi
c2027e194d gha: add signed cache support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-01-05 18:00:24 -08:00
Tonis Tiigi
339740431f authprovider: make it possible to provide custom AuthConfig providers
This enables client to provide their own functionality for
AuthConfig lookup, rather than just passing in dockercli.ConfigFile.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-12-10 18:22:37 -08:00
Tonis Tiigi
9a3333c4d2 resolver: auth refactor for better readability
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-12-10 18:08:59 -08:00
Tõnis Tiigi
af4612c2ed Merge pull request #6371 from useblacksmith/fix-history-db-corruption
Add corruption recovery to history.db
2025-11-25 08:28:13 -08:00
Claude
18f1ff0b9d Add corruption recovery to history.db
history.db currently lacks the automatic corruption recovery that
cache.db has, causing BuildKit to fail on startup if history.db is
corrupted. This is inconsistent since both databases are disposable
(losing history is inconvenient but not fatal).

This commit:
- Extracts the safe database opening logic to util/db/boltutil/SafeOpen
- Updates cache.db to use the shared SafeOpen function
- Applies the same recovery mechanism to history.db

The recovery mechanism backs up corrupted databases and creates fresh
ones, allowing BuildKit to start successfully even after abrupt
shutdowns or snapshot-related corruption (common with NoSync + network
block devices like Ceph RBD).

Fixes startup failures when history.db is corrupted, matching the
resilience already present for cache.db since commit ccc06b7ff.

Signed-off-by: Aditya Maru <aditya.maru@example.com>
Signed-off-by: Claude <adityamaru@gmail.com>
2025-11-18 16:27:49 -05:00
Dawei Wei
610dbfac5e Enable Windows support for BuildKit integration tests
This PR adds comprehensive Windows container support to BuildKit's integration test suite,
enabling cross-platform testing while maintaining full Linux compatibility.

- Updated 35+ integration tests to work on both Windows and Linux
- Uses integration.UnixOrWindows() pattern for platform-specific logic
- Windows: nanoserver images, cmd.exe commands, C:\ paths, CRLF handling
- Linux: preserves existing alpine/busybox images and bash/sh commands
- Added platform-specific adaptations for cache, export, frontend, and CLI tests

- Files: 12 modified (+454/-151 lines)
- Coverage: Major test categories now cross-platform compatible
- Compatibility: 100% backward compatible, no breaking changes
- CI: Enables Windows testing in BuildKit pipeline

- Cache import/export (local, registry, multiple backends)
- Image exporters (containerd, OCI, tar, metadata)
- Dockerfile frontend parsing and builds
- buildctl CLI functionality
- Multi-stage builds and named contexts

Tests requiring POSIX features (uid/gid, tmpfs, file modes) remain Linux-only.

Signed-off-by: Dawei Wei <davwei@microsoft.com>
2025-10-20 14:56:48 -07:00
Tonis Tiigi
8ecdc0ad3d provenance: add custom fields support
This allows buildkitd daemon to define additional fields
that are added to all the provenance attestations that
BuildKit creates (by default from /etc/buildkit/provenance.d/).

These custom fields can provide additional context about
the environment BuildKit itself is running (eg. Github workflow)
and are not allowed to collide with the trusted fields created
by BuildKit itself.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-09-10 16:56:59 -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
Sebastiaan van Stijn
8322c04df8 replace github.com/hashicorp/go-multierror with errors.Join
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-20 16:24:49 +02:00
Tonis Tiigi
854eace665 debug: combine links from parents intead of children
Grouping the link digests to parent side (links pointing
to current node) makes more sense than children side (links
pointing to next nodes). This also reduces the duplicates
in the output as previously same digest link could need
plaintext under multiple nodes.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-08-11 13:12:53 +03:00
Tonis Tiigi
4b822e9762 debug: allow debug from remote cache config
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-08-11 13:12:50 +03:00
CrazyMax
74008209ec buildkitd: add flag to set max parallelism
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-24 15:52:26 +02:00
CrazyMax
bc0c857973 buildkitd: handle device insecure entitlement
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-11 17:44:26 +02:00
Tonis Tiigi
044e09c28c buildkitd: add cache store debugging endpoints
These endpoints show the contents of current boltdb
cache database together with debug plaintexts if
they have been saved.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-07-08 00:05:53 -07:00
Tonis Tiigi
4c9d94f93c add cache key debuginfo lookup
This allows opt-in to cache key debug database on
daemon startup.

If enabled, all cache keys generated by builds are
saved into this database together with the plaintexts
of the original data so a reverse lookup can be performed
later to compare two checksums and find out their original
difference. If checksum contains other checksums internally
then these are saved as well. For storage constraints, the
plaintext of file content is not saved but the metadata
portion can be still looked up.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-06-30 23:29:36 -07:00
Brian Goff
96447a83e2 Add support for raw mode in the SSH agent provider.
In fraw mode it just does a raw proxy on the connection.
There's no internal SSH agent or anything.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2025-06-03 09:03:07 -07:00
Tõnis Tiigi
90196ef73b Merge pull request #5968 from fiam/alberto/omitempty-platforms-list
fix: omit empty list of platforms when serializing worker config
2025-05-13 14:21:51 -07:00
Alberto Garcia Hierro
50247f3baf fix: omit empty list of platforms when serializing worker config
Previously, when no platforms were explicitly defined in the config,
serialization would emit an empty array instead of omitting the field.
When loading this cofig, this prevented the worker from falling back
to default platform detection during initialization. By using `omitempty`,
we ensure the field is excluded when empty, allowing defaults to be
correctly applied.

Fixes #5740.

Signed-off-by: Alberto Garcia Hierro <damaso.hierro@docker.com>
2025-05-13 15:51:46 +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
1e512a15c3 lint: add fatcontext
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:19:22 -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
42b37d2a2c lint: enable durationcheck
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:19:22 -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
Gleb Nebolyubov
4077bb3c9f buildctl: fix tlsdir handling logic for cert-manager.io
`tldir` flag handling now properly handles the old logic and the new
logic for cert-manager.io without failing.

Improved error message when files are missing.

Co-authored-by: Gleb Nebolyubov <gleb.nebo@gmail.com>
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-04-28 13:28:05 -05:00
Tõnis Tiigi
37daea90eb Merge pull request #5863 from tonistiigi/sort-update
lint: update some sorting code to newer generics based libs
2025-04-09 09:38:30 -07:00
Tõnis Tiigi
7d13a98288 Merge pull request #5886 from GoodOwl/master
add support for cert-manager.io syntax for tls using tlsdir
2025-04-07 14:33:46 -07:00