70 Commits
Author SHA1 Message Date
CrazyMax c08835d1ad git: add opt-in command tracing
Print executed Git commands in build logs to help diagnose source
resolution, fetch, and checkout behavior, including bundle staging.
Enable tracing with BUILDKIT_GIT_DEBUG_COMMANDS=1 or llb.GitDebugCommands().

Redact URL credentials and HTTP extra headers without changing command
execution or snapshot cache keys. Tracing is disabled by default.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-10-22 11:11:56 +02:00
Tonis Tiigi 2ed913ca29 dockerfile: limit epoch archive reads
Apply the frontend file-size limit when scanning HTTP archives for
SOURCE_DATE_EPOCH timestamps.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit f7eeece391b15b63a31074fdffc3b538fafc47b7)
2026-09-30 15:12:29 +02:00
Tonis Tiigi 0d557a9949 dockerfile: limit frontend file reads
Bound Dockerfile and ignore-file reads to the gateway message size.
Reject oversized files before parsing to avoid unbounded daemon memory use.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 2508d93d8a2ac621955f0355258f9a4ec79b02b7)
(cherry picked from commit 69d8a4527d8435c50c1bcce92d7e8f0e7851706c)
2026-09-30 15:12:26 +02:00
CrazyMax 3c362f9b29 move archive detection into util/archiveutil
Let frontend and external callers detect archives without importing image-layer compression
backends and their transitive dependencies.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-09-21 16:59:16 +02:00
CrazyMax f09ca6c8ed compression: expose shared archive detection
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-09-15 14:05:01 +02:00
CrazyMax ecf067f41e Merge pull request #7069 from crazy-max/add-zstd-archive-context-cap
dockerfile: detect zstd archive contexts
2026-08-26 11:45:14 +02:00
CrazyMax 4081fec283 dockerfile: detect zstd archive contexts
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-08-26 10:53:05 +02:00
CrazyMax e74f17fd27 source/git: suppress git advice by default
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-08-24 16:27:10 +02: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
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
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
Tonis Tiigi c126a86c17 dockerfile: support SOURCE_DATE_EPOCH=<stage>
Extend SOURCE_DATE_EPOCH resolution to accept a stage name
or named context in addition to numeric and "context" values.
A referenced stage must be FROM scratch with a single remote
ADD (HTTP or Git), from which the epoch timestamp is derived.

Refactor resolution logic from dockerui/context.go into a
dedicated epoch.go file. Remove buildContext fields that were
only needed for epoch resolution and expose GatewayClient()
on dockerui.Client for direct source metadata access.

Also align HTTP named context to use Filename("context"),
matching the existing DetectHTTPContext behavior.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-04-08 15:33:03 -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
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 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 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 1e3b332191 dockerui: allow sharedkey sent for local named contexts
Avoids the case where two projects that use the
named context with same name would share the destination
directory for the upload.

Assuming the client sets a different sharedkey
for them based on local dir basename.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-01-20 19:05:27 -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 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
Jonathan A. Sternberg 1cdfd7928f dockerfile: add subrequest for converting LLB contents for dockerfile
This subrequest is similar to `buildctl debug dump-llb` but works on a
running buildkit daemon with the dockerfile frontend. The
`--call=convertllb` option can be used to dump the raw LLB along with the
metadata and anything else in the definition to a JSON format.

This is useful for debugging purposes.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-10-21 09:56:53 -05: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 119c50f48c dockerfile: allow keep-git-dir in Git URLs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-08-28 22:31:10 -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
Tonis Tiigi c8ce372293 dfgitutil: add querystring style URLs to dfgitutil
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-08-28 15:33:19 -07:00
Akihiro Suda 2207a88aad mv util/gitutil/git_ref.go frontend/dockerfile/dfgitutil/git_ref.go
The `ParseGitRef` function was only used in `frontend/{dockerfile, dockerui}`,
expect a single occurrence in `solver/llbsolver/history.go`.

The occurrence in `solver/llbsolver/history.go` now uses
`util/gitutil/git_url.go:ParseURL()`.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-08-20 18:09:59 +09:00
Tonis Tiigi 9f484131ad dockerui: fix data race on dockerignore access
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-06-02 14:33:49 -07: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 7ed4640e02 dockerui: update platforms key calculation
Make sure key is always normalized and improve tests.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-04-29 23:50:11 +09:00
Akihiro Suda 57ab179e60 frontend/dockerui/build: fix "no scan targets for linux/arm64/v8"
Fix issue 5915

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-04-29 23:50:11 +09:00
Akihiro Suda c5d01bcf73 frontend/dockerui/build.go: split normalizePlatform()
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-04-29 23:50:09 +09:00
Tonis Tiigi 25bba3166c dockerfile: fix sbom attestation for windows targets
Because dockerui added osversion to original reference before
calling res.AddRef() that meant that the sbom was looked up by
wrong key in scanTargets.Load(id) .

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-03-12 18:55:15 -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
Anthony Nandaa cc0cb08936 refactor: avoid unnecessary calls to platforms.DefaultSpec()
I came across a number of calls to `platforms.DefaultSpec()`
that were not necessary. That prompted me to take a look
various other similar places.

At least on Windows, the call is a has some cost till
doing a sycall `RtlGetNtVersionNumbers()`.

Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
2025-02-19 07:36:36 +03:00
CrazyMax 88509a98ed dockerfile: remove device frontend attr support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-02-11 11:21:50 +01:00
CrazyMax 3cb3f686cd dockerfile: support optional cdi devices
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-02-11 11:21:48 +01:00
CrazyMax 0fe26ed106 dockerfile: device support with frontend attribute
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-02-11 11:21:44 +01:00
Tonis Tiigi d394e48a8d dockerfile: avoid too eager loading of unreachable named contextes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-02-06 18:13:41 -08: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
Laurent Goderre 2782f14746 Added way to configure SBOM scanner
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2024-09-30 16:11:32 -04: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
Talon Bowler 6e838fe731 Update rule check print to include path to dockerfile relative to context
Signed-off-by: Talon Bowler <talon.bowler@docker.com>
2024-08-29 16:20:58 -07:00
Talon Bowler 8a7ba6e66c implement experimental rule checks
Signed-off-by: Talon Bowler <talon.bowler@docker.com>
2024-08-04 23:36:32 -07:00
Tonis Tiigi cd90732c2d dockerui: allow passing sessionID for specific local source
This allows frontend to associate a specific local to specific
session when it is assembling LLB. It can be used to create builds
using files from multiple sessions or multiple builds to use
the same session that is different from default session for the
build request.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-21 20:06:05 -07:00
Talon Bowler 07fe32463a Adds a rule check for copying files which match the .dockerignore patterns
Signed-off-by: Talon Bowler <talon.bowler@docker.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-10 14:10:37 -07:00
Sebastiaan van Stijn 175973babc switch to github.com/containerd/platforms module
Switch to use github.com/containerd/platforms module, because containerd's
platforms package has moved to a separate module. This allows updating the
platforms parsing independent of the containerd module itself.

The package in containerd is deprecated, but kept as an alias to provide
compatibility between codebases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 22:59:12 +02:00
Akihiro Suda 2c425f45a6 Merge pull request #5067 from tonistiigi/dockerfile-mem-cleanup
dockerfile: cleanup of memory allocations
2024-06-25 11:55:41 +09:00
Talon Bowler 4ea1b2f20f Move parseLintOptions into linter package
Signed-off-by: Talon Bowler <talon.bowler@docker.com>
2024-06-23 23:25:29 -07:00
Tonis Tiigi 6737deb443 vendor: add go-csvvalue for more efficient CSV parsing
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-21 08:05:56 -07:00
Tonis Tiigi 9f66e2a345 dockerui: use CachedGroup in dockerui context resolve
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-11 19:20:31 -07:00