Commit Graph

554 Commits

Author SHA1 Message Date
Tõnis Tiigi a894a678f1
Merge pull request #3308 from jsternberg/dap-docs
docs: add docs related to dap
2025-07-15 09:18:29 -07:00
Jonathan A. Sternberg ac9050261e
docs: add docs related to dap
Adds some entry-level and developer-friendly docs for the debug adapter.
The one in `docs/dap.md` is meant for someone trying to use the debugger
while the one in `docs/reference/buildx_dap_build.md` is more focused on
documenting the command to be integrated in a debugger extension.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-07-15 10:58:01 -05:00
Jonathan A. Sternberg 3453f3b00a
dap: support evaluate request to invoke a container
Supports using the `evaluate` request in REPL mode to start a container
with the `exec` command. Presently doesn't support any arguments.

This improves the dap server so it is capable of sending reverse
requests and receiving the response. It also adds a hidden command
`dap attach` that attaches to the socket created by `evaluate`.

This requires the client to support `runInTerminal`.

Likely needs some additional work to make sure resources are cleaned up
cleanly especially when the build is unpaused or terminated, but it
should work as a decent base.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-07-15 10:45:25 -05:00
Jonathan A. Sternberg e7b8de2b0c
dap: correctly set the target when provided by the launch config
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-07-14 14:51:05 -05:00
Tõnis Tiigi 39ee904262
Merge pull request #3298 from crazy-max/cmd-fix-duplicated-usage
cmd: fix duplicated commands description
2025-07-09 17:44:46 -07:00
Tõnis Tiigi e3eb64e73d
Merge pull request #3294 from jsternberg/dap-stop-on-entry
dap: support stopOnEntry to configure behavior when starting the debugger
2025-07-09 13:05:41 -07:00
CrazyMax af0090e434
history: bootstrap builder
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-08 11:11:37 +02:00
Jonathan A. Sternberg a291698eaf
dap: support stopOnEntry to configure behavior when starting the debugger
This will configure the default behavior when beginning to evaluate a
build target. When `stopOnEntry` is used, it will default to `stepNext`.
Otherwise, `stepContinue` will be used.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-07-07 09:39:23 -05:00
CrazyMax b6cd86e068
cmd: fix duplicated commands description
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-07 11:58:45 +02:00
Tõnis Tiigi 758ea75f60
Merge pull request #3235 from jsternberg/dap-handler
dap: add debug adapter implementation
2025-07-02 12:58:07 -07:00
Tõnis Tiigi 9a5cbaca15
Merge pull request #3278 from crazy-max/fix-exit-after-defer
cmd: fix possible skipped defers for build and bake
2025-07-01 09:32:05 -07:00
CrazyMax a711b8ff88
cmd: fix possible skipped defers for build and bake
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-01 09:45:27 +02:00
Jonathan A. Sternberg 42599a7d49
dap: add debug adapter implementation
Adds a simple implementation of the debug adapter that supports the very
basics of a debug adapter.

It supports the launch request, the configuration done request, the
creation of threads, stopping, resuming, and disconnecting from server.

It does not support custom breakpoints, stack traces, or variable
inspection yet. These are planned to be added in the future.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-06-30 10:51:20 -05:00
CrazyMax f1db389f07
bake: fix BUILDX_BAKE_FILE env behavior
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-06-30 15:17:21 +02:00
Tõnis Tiigi 0bed0b5653
Merge pull request #3242 from rrjjvv/new-bakefile-env-var
Allow bake files to be specified via environment variable
2025-06-25 08:54:04 -07:00
CrazyMax 179aad79b5
history: fix required args for inspect attachment command
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-06-24 16:06:54 +02:00
Roberto Villarreal d44ffb4bd4 Display source of bake definitions when read from environment
While it would make sense to add "from file" to complement "from env,"
 (in the common case of `--file` or using the default), it wouldn't
 provide any real value.

A simpler solution would have been looking for the existence of the
variable at the point where printing happens.  It felt wrong
duplicating the logic.  Executing the same logic (if it was extracted)
wouldn't be as bad, but still not ideal.

A 'correct' solution would be to explicitly track the source of each
definition, which would be clearer and more future-proof.  It didn't
seem like this feature warranted that amount of engineering (with no
known features that might make use of it).

This implementation seemed like a fair compromise; none of the functions
 are exported, and all have only one caller.

I also considered converting prefixing environment values with `env://`
so they could be thought of (and processed like) `cmd://` values.  I
didn't think it would be viewed as a good solution.

Co-authored-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
2025-06-24 00:32:37 -06:00
CrazyMax 2588b66fd9
build: fix buildx.build.provenance metadata
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-06-19 18:47:27 +02:00
Tõnis Tiigi 99f1c4b15c
Merge pull request #3245 from crazy-max/history-slsa-check
history: slsa v1 support
2025-06-16 10:53:26 -07:00
Jonathan A. Sternberg 7660acf9c7
progress: ensure bake waits for progress to finish printing on error conditions
Some minor fixes to the printer and how bake invokes it. Bake previously
had a race condition that could result in the display not updating on an
error condition, but it was much rarer because the channel communication
was much closer. The refactor added a proxy for the status channel so
there was more of an opportunity to surface the race condition.

When bake exits with an error when reading the bakefiles, it doesn't
wait for the printer to finish so it is possible for the printer to
update the display after an error is printed. This adds an extra `Wait`
in a defer to make sure the printer is finished.

`Wait` has also been fixed to allow it to be called multiple times and
have the same behavior. Previously, it only waited for the done channel
once so only the first wait would block.

The `onclose` method is now called every time the display is paused or
stopped. That was the previous behavior and it's been restored here.

The display only gets refreshed if we aren't exiting. There's no point
in initializing another display if we're about to exit.

The metric writer attached to the printer was erroneously removed. It is
now assigned properly.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-06-16 12:24:04 -05:00
CrazyMax 4a22b92775
history: slsa v1 support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-06-16 16:23:20 +02:00
Roberto Villarreal cb54ddb9fe Allow bake files to be specified via environment variable
The environment variable `BUILDX_BAKE_FILE` (and optional variable
`BUILDX_BAKE_FILE_SEPARATOR`) can be used to specify one or more bake
files (similar to `compose`).  This is mutually exclusive with`--file`
(which takes precedence).

This is done very early to ensure the values are treated just like
`--file`, e.g., participate in telemetry.  This includes leaving
relative paths as-is, which deviates from `compose` (which makes them
absolute).

Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
2025-06-16 00:08:54 -06:00
Jonathan A. Sternberg 7f5ff6b797
commands: remove debug package in commands
The package just causes the entire flow to be more complicated as build
has to pretend it doesn't know about debug options and the debugger has
to pretend it doesn't know about the build.

This abstraction has been difficult when integrating a DAP command into
this same workflow so I don't think this abstraction has much of a
value.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-06-13 09:32:35 -05:00
Jonathan A. Sternberg e1adeee898
vendor: github.com/moby/buildkit v0.23.0-rc1
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-06-11 16:29:31 -05:00
Jonathan A. Sternberg 38cf84346c
build: change build handler to evaluate instead of onresult
This changes the build handler to customize the behavior of evaluate
rather than onresult and also simplifies the `ResultHandle`. The
`ResultHandle` is now only valid within the gateway callback and can be
used to start containers from the handler.

`Evaluate` now executes inside of the gateway callback rather than
having a separate implementation that executes or re-invokes the build.
This keeps the gateway callback session open until the debugger has
returned.

The `ErrReload` for monitor has now been moved into the `build` package
and been renamed to `ErrRestart`. This is because it restarts the build
so the name makes a bit more sense. The actual use of this functionality
is still tied to the monitor reload.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-06-10 11:48:41 -05:00
Jonathan A. Sternberg 1d7cda1232
controller: remove remaining parts of the controller
Removes all references to the controller and moves the remaining
sections of code to other packages.

Processes has been moved to monitor where it is used and the data
structs have been removed so buildflags is used directly. The controller
build function has been moved to the commands package.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-06-05 11:57:03 -05:00
Jonathan A. Sternberg 8f2604b6b4
monitor: move remaining controller functionality into monitor
This creates a `Monitor` type that keeps the global state between
monitor invocations and allows the monitor to exist during the build so
it can be utilized for callbacks.

The result handler is now registered with the monitor during the build
and `Run` will use the result if it is present and the configuration
intends the monitor to be invoked with the given result.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-06-04 15:27:24 -05:00
Jonathan A. Sternberg 21ebf82c99
monitor: refactor how reload works
The build now happens in a loop and the monitor is run after every
build. The monitor can return `ErrReload` to signal to the main thread
that it should reload the build result.

This will be used in the future to move the monitor into a callback
rather than as a separate existence. It allows the monitor to not
control the build itself which now makes it possible to completely
remove the controller.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-06-04 15:06:31 -05:00
Jonathan A. Sternberg 65e46cc6af
commands: simplify passing stdin to the build when the monitor is configured
The monitor needs stdin to run and isn't compatible with loading a
context or dockerfile from stdin. We already disallow this combination
and, with the removal of the remote controller, there's no way to use
stdin during the build when invoke is configured.

This just removes the extra code to allow forwarding stdin to the build
when the monitor is configured to simplify that section of code.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-06-03 15:41:23 -05:00
Jonathan A. Sternberg 6a0f5610e3
controller: remove the controller interface
The controller interface is removed and the local controller is used for
only the initial build, invoke, and rebuilds.

Process control has been moved to the monitor.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-06-03 15:41:23 -05:00
Jonathan A. Sternberg 9bd1ba2f5c
commands: update deprecation notice for keep-storage
The `--keep-storage` flag was changed to `--reserved-space`. Before it was
changed to that name, it was changed to `--max-storage`. This flag never
made it into a release as the name was changed before release, but the
update to the flag in buildx forgot to update the deprecation notice.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-06-02 09:35:39 -05:00
Roberto Villarreal b40b2caf1a Show types during variable list operation
If a type was explicitly provided, it will be displayed in the variable
listing.  Inferred type names are not displayed, as they likely would
not match the user's intent.

Previously only `string` and `bool` default values were displayed in the
 listing.  All default values, regardless of type, are now displayed.

Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
2025-05-29 17:36:46 -06:00
Tonis Tiigi f41d5072fd
lint: fix linter after merge conflict
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-13 16:19:33 -07:00
Tõnis Tiigi 4feb05b0bf
Merge pull request #3179 from tonistiigi/ls-format-json-current
ls: make sure current builder is available in JSON output
2025-05-13 14:27:36 -07:00
Tõnis Tiigi 277548e91b
Merge pull request #3152 from crazy-max/history-export-finalize
history: make sure build record is finalized before exporting
2025-05-13 14:20:04 -07:00
CrazyMax 1383aa30c1
lint: modernize fix
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-05-13 20:44:57 +02:00
CrazyMax 78353f4e8e
history: make sure build record is finalized before exporting
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-05-13 17:17:47 +02:00
CrazyMax 03f9877429
Merge pull request #3181 from crazy-max/golangci-lint-v2
update golangci-lint to v2.1.5
2025-05-13 17:17:17 +02:00
CrazyMax b606e2f6bb
update golangci-lint to v2.1.5
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-05-13 16:54:43 +02:00
CrazyMax a9ab809d15
Merge pull request #3138 from crazy-max/history-copy
history: copy update
2025-05-13 13:06:05 +02:00
CrazyMax 72fde4c53a
history: copy update
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-05-13 12:20:00 +02:00
Tonis Tiigi a3180cbf3d
ls: make sure current builder is available in JSON output
While lsBuilder has a field called Current that gets lost
because the embedded struct implements custom MarshalJSON method.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-12 22:30:44 -07:00
Tonis Tiigi b00dd42037
bake: fix nil deference on empty call definition
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-05 11:07:54 -07:00
Jonathan A. Sternberg 384f0565f5
controller: remove controller/errdefs protobuf files
Remove the protobuf files associated with controller/errdefs.

This doesn't completely remove the type as the monitor still uses it as
a signal to start the monitor.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-05-01 12:14:36 -05:00
Jonathan A. Sternberg 2f1be25b8f
controller: remove controller grpc service
Remove the controller grpc service along with associated code related to
sessions or remote controllers.

Data types that are still used with complicated dependency chains have
been kept in the same package for a future refactor.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-04-30 13:46:58 -05:00
CrazyMax 86eb3be1c4
Merge pull request #3103 from thaJeztah/use_atomicwriter
migrate to use github.com/moby/sys/atomicwriter
2025-04-11 12:05:00 +02:00
CrazyMax 5bac0b1197
build: print frontend inline message
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-04-11 09:45:25 +02:00
Sebastiaan van Stijn b7b5a3a1cc
migrate to use github.com/moby/sys/atomicwriter
The github.com/docker/docker/pkg/atomicwriter package was moved
to a separate module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:13:01 +02:00
Tõnis Tiigi d80ece5bb3
Merge pull request #3091 from tonistiigi/history-filters
history: add filters to ls
2025-04-08 09:19:05 -07:00
Tonis Tiigi f1b895196c
history: add local filters for older buildkit versions
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-04-07 22:20:32 -07:00