Commit Graph

1317 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
74a4ccdd85 fix various linting issues
Got these when running locally on a more recent version of golangci-lint:

    pkg/compose/build_bake.go:187:3: importShadow: shadow of imported from 'github.com/docker/cli/cli/command/image/build' package 'build' (gocritic)
                    build := *service.Build
                    ^
    pkg/compose/build_bake.go:526:19: importShadow: shadow of imported from 'github.com/docker/cli/cli/command/image/build' package 'build' (gocritic)
    func toBakeAttest(build types.BuildConfig) []string {
                      ^
    pkg/compose/create.go:1453:2: importShadow: shadow of imported from 'github.com/docker/docker/api/types/network' package 'network' (gocritic)
            network string,
            ^
    pkg/compose/create.go:1468:2: importShadow: shadow of imported from 'github.com/docker/docker/api/types/network' package 'network' (gocritic)
            network string,
            ^
    pkg/compose/monitor.go:42:17: importShadow: shadow of imported from 'github.com/docker/compose/v2/pkg/api' package 'api' (gocritic)
    func newMonitor(api client.APIClient, project string) *monitor {
                    ^
    cmd/compose/config.go:337:1: File is not properly formatted (gofumpt)
            return
    ^
    pkg/compose/convergence.go:608:1: File is not properly formatted (gofumpt)
                    return
    ^
    pkg/compose/cp.go:335:1: File is not properly formatted (gofumpt)
                    return
    ^
    pkg/e2e/compose_up_test.go:35:10: go-require: c.RunDockerComposeCmd contains assertions that must only be used in the goroutine running the test function (testifylint)
                    res := c.RunDockerComposeCmd(t, "-f", "fixtures/dependencies/deps-completed-successfully.yaml", "--project-name", projectName, "up", "--wait", "-d")
                           ^
    pkg/e2e/healthcheck_test.go:42:10: go-require: c.RunDockerComposeCmd contains assertions that must only be used in the goroutine running the test function (testifylint)
                    res := c.RunDockerComposeCmd(t, "-f", "fixtures/start_interval/compose.yaml", "--project-name", projectName, "up", "--wait", "-d", "test")
                           ^
    10 issues:
    * gocritic: 5
    * gofumpt: 3
    * testifylint: 2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-31 17:44:38 +01:00
Guillaume Lours
6719f47bd4 test checking bake internal load build definition
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-10-30 21:25:32 +01:00
Suleiman Dibirov
c416ea7036 fix compose_run_build_once_test.go
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2025-10-30 10:08:29 +01:00
Suleiman Dibirov
0d396bbacb fix(git): Add validation for Git subdirectory paths to prevent traversal
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2025-10-30 10:08:29 +01:00
Suleiman Dibirov
fc74c78963 Update e2e tests in compose_run_build_once_test.go to use project names for Docker Compose commands.
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2025-10-29 10:47:18 +01:00
Suleiman Dibirov
658bff335f Revert "no parallel in compose_run_build_once_test.go"
This reverts commit e4f4a5aa86.

Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2025-10-29 10:47:18 +01:00
Suleiman Dibirov
80030e1390 no parallel in compose_run_build_once_test.go
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2025-10-29 10:47:18 +01:00
Suleiman Dibirov
6a35be5112 lint fix
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2025-10-29 10:47:18 +01:00
Suleiman Dibirov
0c854a6ab7 add e2e tests
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2025-10-29 10:47:18 +01:00
Suleiman Dibirov
557e0b6ec7 fix(run): Ensure images exist only for the target service in run command
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2025-10-29 10:47:18 +01:00
Nicolas De Loof
a8933c91e7 stop progress UI during build to prevent interference with buildkit Display
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-29 10:11:30 +01:00
Nicolas De Loof
7e3993bcac skip Start[ed|ing] events to avpd mix with container logs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-29 10:11:30 +01:00
Nicolas De Loof
fd4f2f99cf register TTYWritter as an Event Processor
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-29 10:11:30 +01:00
Nicolas De Loof
ae25d27e5a remove unused RunWithStatus, always pass operation as title
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-29 10:11:30 +01:00
Nicolas De Loof
394466683a use eventBus to collect tasks progress
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-29 10:11:30 +01:00
Nicolas De Loof
e5c8b68642 decouple Event from tty progress writer
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-29 10:11:30 +01:00
Nicolas De Loof
bf50c99193 pretend cli.Out is a containerd console.File
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-28 14:39:50 +01:00
Guillaume Lours
8274be8d08 configure Compose service with io.Reader and io.Writer
remove usage of internal IO interfaces

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-10-27 18:54:10 +01:00
Guillaume Lours
86e91e010d Add streamOverrideWrapper to intercepts command.Cli stream methods and transparently returns custom streams when provided via options
Add new GetConfiguredStreams function to Compose API definition

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-10-27 16:17:50 +01:00
Guillaume Lours
e1678c5c43 Introduce abstractions to support SDK usage without requiring Docker CLI
This commit prepares the Compose service for SDK usage by abstracting away
the hard dependency on command.Cli. The Docker CLI remains the standard path
for the CLI tool, but SDK users can now provide custom implementations of
streams and context information.

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-10-27 16:17:50 +01:00
Nicolas De Loof
5924387e89 run hooks on restart
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-27 10:24:18 +01:00
Nicolas De Loof
7f668bd7fe Setup Compose service using functional parameters
This commit introduces WithMaxConcurrency and WithDryRun to replace direct mutators on composeService
commands and flags are translated into a set of functional parameters which are eventually applied
as a ComposeService is created just before being actually used by a command

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-24 18:24:21 +02:00
Nicolas De Loof
3ce52883cb prompt default implementation to prevent a panic
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-24 10:21:59 +02:00
Nicolas De Loof
ac3b8fd8a5 Code Cleanup
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-24 10:05:59 +02:00
Nicolas De Loof
e59150baa8 fix OCI compose override support
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-23 12:04:37 +02:00
Nicolas De Loof
6a90742ef2 Test to check writeComposeFile detects invalid OCI artifact
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-22 20:09:32 +02:00
Nicolas De Loof
6007d4c7e7 publish env_file references as opaque hash to prevent paths conflicts
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-22 19:32:16 +02:00
Guillaume Lours
69bcb962bf Enforce compose files from OCI artifact all get into the same target (cache) folder
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-22 19:32:16 +02:00
Nicolas De Loof
9b4fcce034 introduce WithPrompt to configure compose backend to use a plugable UI component for user interaction
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-22 16:14:55 +02:00
Guillaume Lours
da5c57c29d test digest or canonical reference, not only tag, when checking if an image is already present
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-10-20 18:42:24 +02:00
Nicolas De Loof
e25265dd55 remove unused code to only rely on api.Service
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-20 14:53:04 +02:00
Nicolas De Loof
e19e1278b5 fail build if minimal required version of buildx isn't installed
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-20 12:25:38 +02:00
Nicolas De Loof
585c4db4f9 Compose can't create a tar with adequate uid:gid ownership
as we can't get container UID/GID as int by ContainerInspect
revert https://github.com/docker/compose/pull/13288

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-20 09:51:58 +02:00
Nicolas De Loof
27f59d7f42 Detect failure to access os.TempDir
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-17 09:49:44 +02:00
Nicolas De Loof
2681ed17a7 mutualize code from injectSecrets / injectConfigs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-16 17:43:04 +02:00
Nicolas De Loof
ee75be342b Set secret/config uid:gid to match container's USER
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-16 17:43:04 +02:00
Guillaume Lours
7755302348 use fixed version of compose bridge transformer images
to avoid CI issue on Compose when a new version is released and change the outputs

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-10-14 09:21:59 +02:00
Olivier Goulpeau
289faae5fa fix(publish): in publish(), select all profiles in the project to publish.
This code is moved from `generateImageDigestsOverride()` as no more
needed at that point.

Signed-off-by: Olivier Goulpeau <olivier.goulpeau@ledger.fr>
2025-10-14 08:25:26 +02:00
Olivier Goulpeau
e7aa484b78 fix(publish): in processFile(), load the compose file passing the project.Profiles to the loader.Options.
Signed-off-by: Olivier Goulpeau <olivier.goulpeau@ledger.fr>
2025-10-14 08:25:26 +02:00
Sebastiaan van Stijn
ae3309afab pkg/compose: build with bake: drop support for buildx v0.16 and lower
[buildx v0.17][1] was released a Year ago, so any version this
conditional code was accounting for would be versions before that;
the latest of which being [buildx v0.16.2][2] (July 2024).

Given that those versions are long EOL and no longer supported, we
can probably remove the conditional code.

[1]: https://github.com/docker/buildx/releases/tag/v0.17.0
[2]: https://github.com/docker/buildx/releases/tag/v0.16.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-14 08:02:58 +02:00
Sebastiaan van Stijn
63920c4cc0 pkg/compose: align classic builder implementation with docker/cli
This aligns the implementation closer to the implementation in docker/cli,
with the refactor done in [cli@260f1db]; this removes some direct uses of
the github.com/docker/docker/builder/remotecontext/urlutil package, which
won't be included in the new Moby modules.

There's still some remaining uses in the `dockerFilePath` utility (which
may need to be updated to also account for remote contexts that are not
"git"), so possibly we can remove the use in that utility as well.

[cli@260f1db]: 260f1dbebb

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-13 16:53:00 +02:00
Nicolas De Loof
a03f2562df bake only interpolates ${*}
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-13 10:40:19 +02:00
Benedikt Radtke
fa7e85ed83 Write error to watcher error channel if Start() fails
Up's loop will notice globalCtx is done, and invoke watcher.Stop(). Stop() reads from the watcher error channel. If Start() does not write an error, Stop() will never finish.

Fixes https://github.com/docker/compose/issues/13262

Signed-off-by: Benedikt Radtke <benediktradtke@gmail.com>
2025-10-06 14:50:19 +02:00
Nicolas De Loof
07602f2070 publish Compose application as compose.yaml + images
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-03 10:59:57 +02:00
Nicolas De Loof
cf7e31f731 escape $ in bake.json as interpolation already has been managed by compose
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-10-03 09:25:35 +02:00
Nicolas De Loof
fa08127456 use containerd client for OCI operations
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-09-30 12:03:46 +02:00
Nicolas De Loof
4ee52ad168 pass bake secrets by env
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-09-30 09:07:22 +02:00
Sebastiaan van Stijn
713de5bb9e pkg/compose: explicitly map AuthConfig fields instead of a direct cast
Commit [cli@27b2797] forked the AuthConfig type from the API, and changed
existing code to do a direct cast / convert of the forked type to the API
type. This can cause issues if the API types diverges, such as the removal
of the Email field.

This patch explicitly maps each field to the corresponding API type, but
adds some TODOs, because various code-paths only included a subset of the
fields, which may be intentional for fields that were meant to be handled
on the daemon / registry-client only.

We should evaluate these conversions to make sure these fields should
be sent from the client or not (and possibly even removed from the API
type).

[cli@27b2797]: 27b2797f7d

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-29 15:24:42 +02:00
Guillaume Lours
8bc8593fd0 provider services: use '--project-name=' notation
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-09-29 12:38:10 +02:00
Nicolas De Loof
8978c1027d use containerd registry client
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-09-26 18:45:07 +02:00