Compare commits

...

2118 Commits
v2.6.0 ... main

Author SHA1 Message Date
dependabot[bot]
6ca8663bda build(deps): bump github.com/spf13/pflag from 1.0.7 to 1.0.9
Bumps [github.com/spf13/pflag](https://github.com/spf13/pflag) from 1.0.7 to 1.0.9.
- [Release notes](https://github.com/spf13/pflag/releases)
- [Commits](https://github.com/spf13/pflag/compare/v1.0.7...v1.0.9)

---
updated-dependencies:
- dependency-name: github.com/spf13/pflag
  dependency-version: 1.0.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-02 15:46:14 +02:00
Sebastiaan van Stijn
b33ecf65e8 go.mod: bump buildx v0.28.0-rc2, buildkit v0.24.0-rc2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-02 07:28:06 +02:00
Roberto Villarreal
04b8ac5fe4 Unquote volume names in creation events
Volumes are the only resources that are quoted, and only on creation.

Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
2025-08-29 11:50:42 +02:00
dependabot[bot]
d09948da41 build(deps): bump github.com/stretchr/testify from 1.10.0 to 1.11.1
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.10.0 to 1.11.1.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.10.0...v1.11.1)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-version: 1.11.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-29 08:28:51 +02:00
Sebastiaan van Stijn
f1efbb8322 use enum-consts for State and Health
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-29 08:18:16 +02:00
Sebastiaan van Stijn
1d52012b82 go.mod: bump buildkit v0.24.0-rc1, buildx v0.28.0-rc1
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-29 08:16:23 +02:00
Sebastiaan van Stijn
1d69f4a68c pkg/compose: composeService.Up: rewrite without go-multierror
- Use a errgroup.Group and add a appendErr utility to not fail-fast,
  but collect errors.
- replace doneCh for a global context to cancel goroutines
- Commented out attachCtx code, as it didn't appear to be functional
  (as it wouldn't be cancelled).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-27 15:25:17 +02:00
Kian Eliasi
6078b4d99d Fix: use image created time when last tag time is not present
Signed-off-by: Kian Eliasi <kian.elbo@gmail.com>
2025-08-27 09:03:58 +02:00
Kian Eliasi
73e593e69a Fix: incorrect time when last tag time is not set
Signed-off-by: Kian Eliasi <kian.elbo@gmail.com>
2025-08-27 09:03:58 +02:00
Sebastiaan van Stijn
51499f645b pkg/compose: pull: use native multi-errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-25 11:22:25 +02:00
Sebastiaan van Stijn
5165b0f814 internal/tracing: replace go-multierror.Group with sync.WaitGroup
The go-multierror Group is just a shallow wrapper around sync.WaitGroup;
https://github.com/hashicorp/go-multierror/blob/v1.1.1/group.go#L5-L38

This patch replaces the go-multierror.Group for a sync.WaitGroup (we
probably don't need to limit concurrency for this one) and stdlib multi-
errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-25 11:22:25 +02:00
Sebastiaan van Stijn
93dd1a4558 internal/sync: replace go-multierror.Group with golang.org/x/sync/errgroup
The go-multierror Group is just a shallow wrapper around sync.WaitGroup;
https://github.com/hashicorp/go-multierror/blob/v1.1.1/group.go#L5-L38

It does not limit concurrency, but handles synchronisation to collect
all errors (if any) in a go-multierror.

This patch replaces the go-multierror.Group for a sync.ErrGroup (which
is slightly easier to use, and does allow for limiting concurrency if
wanted), and a basic slice with mutex to collect the errors and to produce
a stdlib multi-error through errors.Join

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-25 11:22:25 +02:00
Sebastiaan van Stijn
ba3f5664c0 cmd/formatter: remove unused SetMultiErrorFormat
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-25 11:22:25 +02:00
Guillaume Lours
c420bc44c4 check the assume yes publish flag command before the presence of bind mounts
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-08-25 10:29:52 +02:00
Max Proske
60681a824c Add e2e test to verify docker compose down works even when env file is missing
Signed-off-by: Max Proske <max@mproske.com>
2025-08-25 10:03:55 +02:00
Max Proske
19ad737ee7 Fix runtime ops with missing env file
Signed-off-by: Max Proske <max@mproske.com>
2025-08-25 10:03:55 +02:00
may
d3a260e533 add completions for the --progress flag
Signed-off-by: may <m4rch3n1ng@gmail.com>
2025-08-25 10:01:49 +02:00
dependabot[bot]
e75329dce2 build(deps): bump go.uber.org/mock from 0.5.2 to 0.6.0
Bumps [go.uber.org/mock](https://github.com/uber/mock) from 0.5.2 to 0.6.0.
- [Release notes](https://github.com/uber/mock/releases)
- [Changelog](https://github.com/uber-go/mock/blob/main/CHANGELOG.md)
- [Commits](https://github.com/uber/mock/compare/v0.5.2...v0.6.0)

---
updated-dependencies:
- dependency-name: go.uber.org/mock
  dependency-version: 0.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-25 09:50:16 +02:00
Sebastiaan van Stijn
1dc0be2c30 go.mod: github.com/docker/buildx v0.27.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-25 09:36:33 +02:00
cuiweixie
3bac9ffd08 Refactor to use maps.Copy
Signed-off-by: cuiweixie <cuiweixie@gmail.com>
2025-08-25 08:57:52 +02:00
Guillaume Lours
f266715dd0 add --provenance and --sbom flag to generated bake command line,
also add attestation per-service configuration to generated bake target

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-08-13 09:36:22 +02:00
Guillaume Lours
c2cb0aef6b only monitor attached services on up command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-08-08 17:27:08 +02:00
Austin Vazquez
fbc62d111e bump golang to 1.23.12
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-08-08 16:22:30 +02:00
dependabot[bot]
0d40064ce8 build(deps): bump golang.org/x/sys from 0.34.0 to 0.35.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.34.0 to 0.35.0.
- [Commits](https://github.com/golang/sys/compare/v0.34.0...v0.35.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.35.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-08 14:22:18 +02:00
dependabot[bot]
91a6eafa1d build(deps): bump github.com/docker/go-connections from 0.5.0 to 0.6.0
Bumps [github.com/docker/go-connections](https://github.com/docker/go-connections) from 0.5.0 to 0.6.0.
- [Commits](https://github.com/docker/go-connections/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: github.com/docker/go-connections
  dependency-version: 0.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-08 14:08:26 +02:00
Matthew Runyon
f36ee00f71 Add go as a prerequesite in build instructions
Signed-off-by: Matthew Runyon <matthewrunyon@deephaven.io>
2025-08-06 15:27:09 +02:00
dependabot[bot]
29ede3ba7d build(deps): bump github.com/containerd/containerd/v2
Bumps [github.com/containerd/containerd/v2](https://github.com/containerd/containerd) from 2.1.3 to 2.1.4.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v2.1.3...v2.1.4)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd/v2
  dependency-version: 2.1.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-06 13:55:31 +02:00
Guillaume Lours
bf6d7bf47e define pull and no_cache from either service or flags values when building with bake
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-08-05 13:52:43 +02:00
Sebastiaan van Stijn
fc66da06db pkg/compose: simplify getting auth-config key
Rewrite to remove the `github.com/docker/docker/registry` dependency,
which will not be included in the upcoming "api" and "client" modules,
and will not be a public package in the module used for the daemon itself.

1. don't call "/info" API endpoint to get default registry

The `IndexServerAddress` in the `/info` endpoint was added as part of the
initial Windows implementation of the engine. For legal reasons, Microsoft
Windows (and thus Docker images based on Windows) were not allowed to be
distributed through non-Microsoft infrastructure. As a temporary solution,
a dedicated "registry-win-tp3.docker.io" registry was created to serve
Windows images.

Using separate registries was not an ideal solution, and a more permanent
solution was created by introducing "foreign image layers" in the distribution
spec, after which the "registry-win-tp3.docker.io" ceased to exist, and
removed from the engine through docker/docker PR 21100.

However, the `ElectAuthServer` was left in place, quoting from that PR;

> make the client check which default registry the daemon uses is still
> more correct than leaving it up to the client, even if it won't technically
> matter after this PR. There may be some backward compatibility scenarios
> where `ElectAuthServer` [sic] is still helpful.

That comment was 10 Years ago, and the CLI stopped using this information,
as the default registry is not configurable, so in practice was a static
value. (see b4ca1c7368).

2. replace `ParseRepositoryInfo` and `GetAuthConfigKey` with local impl

The `ParseRepositoryInfo` function was originally implemented for use by
the daemon itself. It returns a `RepositoryInfo` struct that holds information
about the repository and the registry the repository can be found in.

As it was written for use by the daemon, it also was designed to be used
in combination with the daemon's configuration (such as mirrors, and
insecure registries). If no daemon configuration is present, which would
be the case when used in a CLI, it uses fallback logic as used in the daemon
to detect if the registry is running on a localhost / loopback address,
because such addresses are allowed to be "insecure" by default; this includes
resolving the IP-address of the host (if it's not an IP-address).

Unfortunately, these functions (and related types) were reused in the
CLI and many other places, which resulted in those types to be deeply
ingrained in interfaces and (external) code.

For compose; it was only used to get the "auth-config key" to use for
looking up auth information from the credentials store, which still
needs special handling for the "default" (docker hub) domain, which
unlike other image references doesn't use the hostname included in
the image reference for the actual registry (and key for storing
auth).

For those that want to follow along;

First, note that `GetAuthConfig` only requires a `registry.IndexInfo`, so not
the whole `RepositoryInfo` struct;
https://github.com/moby/moby/blob/v28.3.3/registry/types.go#L8-L24

From the `registry.IndexInfo` it only uses the `IsOfficial` and `Name` fields;
https://github.com/moby/moby/blob/v28.3.3/registry/config.go#L390-L395

But to get the `IndexInfo`, `ParseRepositoryInfo` is needed, which first
takes the image reference's "domain name" (e.g. `docker.io`);
https://github.com/moby/moby/blob/v28.3.3/registry/config.go#L421

This gets "normalized" for some cases where the `info.IndexServerAddress`
was incorrectly assumed to be the canonical domain for Docker Hub registry,
and which _does_ happen to also be accessible as a "v2" registry.
https://github.com/moby/moby/blob/v28.3.3/registry/config.go#L334-L341

After normalizing, it checks if it's a docker hub address ("docker.io"
after normalizing); Docker Hub is always required to use a secure
connection, so no detection happens, and the `Official` field is set
to indicate it's Docker Hub (this code path was already simplified
as historically it would try to find daemon configuration (or otherwise
use a default) for Mirror configuration;
https://github.com/moby/moby/blob/v28.3.3/registry/config.go#L420-L443

For non-Docker Hub registries, it also sets the name, and attempts
to detect if the registry is allowed to be "insecure";
https://github.com/moby/moby/blob/v28.3.3/registry/config.go#L435-L442

Which (as mentioned) involves parsing the address and, if needed, resolving
the hostname
https://github.com/moby/moby/blob/v28.3.3/registry/config.go#L445-L481

As `Insecure` is not used for looking up the auth-config key, all of the
above can be reduced to;

- Is the hostname obtained from the image reference "docker.io" (after normalizing)?
- If so, use the special `https://index.docker.io/v1/` as auth-config key (another horrible remnant)
- Otherwise use the hostname obtained from the image reference as-is

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-05 10:08:23 +02:00
Sebastiaan van Stijn
909211dd61 use cli-plugins/metadata package
The metadata types and consts where moved to a separate package,
so update the code to use the new location instead of the aliases
provided.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-05 10:01:53 +02:00
dependabot[bot]
0dc9852c67 build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 28.3.2+incompatible to 28.3.3+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v28.3.2...v28.3.3)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-version: 28.3.3+incompatible
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-30 11:39:57 +02:00
dependabot[bot]
a478702236 build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 28.3.2+incompatible to 28.3.3+incompatible.
- [Commits](https://github.com/docker/cli/compare/v28.3.2...v28.3.3)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-version: 28.3.3+incompatible
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-30 11:27:29 +02:00
Nicolas De Loof
2c12ad19db use log API for containers we didn't attached to
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-29 14:23:24 +02:00
Guillaume Lours
038ea8441a apply BUILDKIT_PROGRESS value when building with bake
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-29 11:45:33 +02:00
Guillaume Lours
9e98e6101e add missing _MODEL suffix to model variable pass to dependent services of a model
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-29 09:40:46 +02:00
keitosuwahara
52f04229c0 fixed lint error
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-28 10:07:03 +02:00
keitosuwahara
28895d0322 fix lint error
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-28 10:07:03 +02:00
keitosuwahara
a926f7d717 Elimneted magic string
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-28 10:07:03 +02:00
Nicolas De Loof
fe046915eb buildkit require os.Stdout to access the raw terminal
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-28 09:25:35 +02:00
keitosuwahara
adbd61e5d6 fixed lint error
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-27 19:36:40 +02:00
keitosuwahara
e37ac04329 deleted useless comment
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-27 19:36:40 +02:00
keitosuwahara
cab2c2a44e Refactoring of redundant condition checks
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-27 19:36:40 +02:00
keitosuwahara
1946de598d improved lint error
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-27 15:12:38 +02:00
keitosuwahara
8e29a138aa improved test
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-27 15:12:38 +02:00
keitosuwahara
3c8da0afee Add test of json.go
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-27 15:12:38 +02:00
keitosuwahara
1b12c867c5 add Streams Comment
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-27 14:57:43 +02:00
Guillaume Lours
1a4fc55fd7 bump compose-go to v2.8.1
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-24 18:10:41 +02:00
Guillaume Lours
efc939dcee add info about models usage to OpenTelemetry spans
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-24 16:01:28 +02:00
keitosuwahara
d6e9f79ba6 Integration of SetAttributes calls
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-24 09:05:30 +02:00
keitosuwahara
b4c44a431f Eliminate magic number in init functions
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-24 09:04:52 +02:00
keitosuwahara
fb5a8644c3 Efficiency of ansiColorCode function
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
2025-07-24 09:04:02 +02:00
Guillaume Lours
95660c5e5a bump buildx to v0.26.1
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-23 16:01:28 +02:00
Guillaume Lours
f6ddd6ae88 use output registry when push true and load to docker store if not
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-23 15:49:19 +02:00
dependabot[bot]
4ae7066955 build(deps): bump google.golang.org/grpc from 1.73.0 to 1.74.2
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.73.0 to 1.74.2.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.73.0...v1.74.2)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-version: 1.74.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-23 14:51:08 +02:00
Nicolas De Loof
fd954f266c show build progress during watch rebuild
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-23 13:57:46 +02:00
Nicolas De Loof
d62e21025c forward git command error to user
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-23 12:10:25 +02:00
Guillaume Lours
6a2d16bd10 bump compose-go to version v2.8.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-23 11:53:47 +02:00
Guillaume Lours
4d47da6dc2 do not pass user id on Windows system as engine is not able to handel it
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-22 12:07:58 +02:00
Nicolas De Loof
8f91793fb5 introduce build.provenance and sbom support
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-21 17:07:41 +02:00
Sebastiaan van Stijn
1d2223fb23 pkg/compose: use local copy of pkg/system.IsAbs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 16:02:52 +02:00
Sebastiaan van Stijn
d4f6000712 remove import aliases for containerd/errdefs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 15:51:39 +02:00
Sebastiaan van Stijn
c50d16cd78 pkg/compose: remove uses of moby/errdefs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 15:51:39 +02:00
Nicolas De Loof
3875e13fad simpler stop UI
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-21 10:31:50 +02:00
Nicolas De Loof
c89f30170d force plain displaymode if stdout isn't a terminal
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-21 10:19:58 +02:00
Nicolas De Loof
41a9b91887 warn user COMPOSE_BAKE=false is deprecated
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-21 10:18:08 +02:00
Nicolas De Loof
5fc2b2a71c
fix yaml indentation
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-18 11:59:56 +02:00
Nicolas De Loof
b1cd40c316 swarm
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-18 11:58:25 +02:00
dependabot[bot]
362ab0733f build(deps): bump github.com/spf13/pflag from 1.0.6 to 1.0.7
Bumps [github.com/spf13/pflag](https://github.com/spf13/pflag) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/spf13/pflag/releases)
- [Commits](https://github.com/spf13/pflag/compare/v1.0.6...v1.0.7)

---
updated-dependencies:
- dependency-name: github.com/spf13/pflag
  dependency-version: 1.0.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-17 15:35:38 +02:00
Nicolas De Loof
f35d2cfb3b monitor must watch events even when context is cancelled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-17 15:08:35 +02:00
Nicolas De Loof
17ba6c7188 abstract model-cli commands execution with a model (pseudo) API
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-16 17:34:59 +02:00
Nicolas De Loof
1c37f1abb6 use logs API with Since to collect the very first logs after restart
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-16 17:24:11 +02:00
Nicolas De Loof
485b6200ee (refactoring) introduce monitor to manage containers events and application termination
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-16 17:24:11 +02:00
Nicolas De Loof
8c17a35609 don't run navigation menu if stdin isn't a terminal
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-16 16:51:26 +02:00
Guillaume Lours
6b9667401a fix the helm bridge e2e tests after the latest update of the templates
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-16 16:04:52 +02:00
Arthur Bols
9a1e589ce8 Fix report image name in bake result
Signed-off-by: Arthur Bols <arthur@bols.dev>
2025-07-16 08:59:12 +02:00
Guillaume Lours
5e147e852e add default compose labels to images built from bake
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-16 07:35:07 +02:00
Nicolas De Loof
29308cb97e keep containers attached on stop to capture termination logs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-15 11:26:44 +02:00
Guillaume Lours
0b0242d0ac add dry-run support to bake build
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-15 10:52:03 +02:00
Cedric Staniewski
5a704004d3 Add a space character to separate the timestamp from the log message
Signed-off-by: Cedric Staniewski <cedric@gmx.ca>
2025-07-15 10:50:43 +02:00
MohammadHasan Akbari
cb95910018 chore: print model attribute instead of model name used in compose file
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2025-07-11 11:08:08 +02:00
MohammadHasan Akbari
f42226e352 feat: add --models flag to config command
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2025-07-11 11:08:08 +02:00
Nicolas De Loof
0cc3c7a550 bump dependencies
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-11 11:04:26 +02:00
atagtm
f7ee9c8a0c feat(os): add FreeBSD support
Signed-off-by: atagtm <donisos1146@gmail.com>
2025-07-11 10:44:45 +02:00
MohammadHasan Akbari
35efa97b7d feat: add since & until flags to events command
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
Co-authored-by: Amin Ehterami <A.Ehterami@proton.me>
2025-07-09 10:08:33 +02:00
dependabot[bot]
9e17a091be build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 28.3.0+incompatible to 28.3.1+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v28.3.0...v28.3.1)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-version: 28.3.1+incompatible
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-08 11:17:18 +02:00
Guillaume Lours
4bbc6c609f add USER_AGENT variable to cmd when shellouting
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-08 11:12:40 +02:00
Nicolas De Loof
69f1430a49 resolve Dockerfile symlink but file name
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-08 10:06:34 +02:00
Nicolas De Loof
7cf7c6414f build resolves enabled service after project has been loaded
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-07 16:43:42 +02:00
MohammadHasan Akbari
0e0ed91a39 fix: lint errors
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2025-07-07 10:37:20 +02:00
MohammadHasan Akbari
66524e7728 feat: add --networks flag to config command
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2025-07-07 10:37:20 +02:00
Guillaume Lours
c626befee1 fix the way we're checking if the provider metadata are empty or not
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-04 12:41:37 +02:00
Nicolas De Loof
60ee6adcd2 a single place for shell-out command setup
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-04 11:17:11 +02:00
dependabot[bot]
8faf1eb808 build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 28.3.0+incompatible to 28.3.1+incompatible.
- [Commits](https://github.com/docker/cli/compare/v28.3.0...v28.3.1)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-version: 28.3.1+incompatible
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-03 11:35:58 +02:00
dependabot[bot]
3b0601b671 build(deps): bump github.com/moby/buildkit from 0.23.1 to 0.23.2
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.23.1 to 0.23.2.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.23.1...v0.23.2)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-version: 0.23.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-02 11:49:11 +02:00
Guillaume Lours
f42374bb18 add a Done event to model progress display
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-02 11:25:07 +02:00
mountdisk
b046a5ef72 chore: fix some minor issues in the comments
Signed-off-by: mountdisk <mountdisk@icloud.com>
2025-07-02 07:31:00 +02:00
Guillaume Lours
1570c6c076 bump go-viper/mapstructure to version v2.3.0
Fix https://github.com/advisories/GHSA-fv92-fjc5-jj9h

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-01 14:56:57 +02:00
Guillaume Lours
674e13fb6d bump golang to v1.23.10
Fix Vulnerability Report: GO-2025-3751

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-01 14:52:43 +02:00
Nicolas De Loof
6fa173124a (reactoring) avoid a global variable by introducing logConsumer decorator
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-01 12:29:05 +02:00
Sebastiaan van Stijn
2c69fc3d4d pkg/compose: remove redundant uses of strslice.StrSlice
The strslice.StrSlice type is a string-slice with a custom JSON Unmarshal
function to provide backward-compatibility with older API requests (see
[moby@17d6f00] and [moby@ea4a067]).

Given that the type is assigned implicitly through the fields on HostConfig,
we can just use a regular []string instead.

[moby@17d6f00]: 17d6f00ec2
[moby@ea4a067]: ea4a06740b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-01 10:49:29 +02:00
Nicolas De Loof
317ebcd3b0 implement model_variable
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-30 21:50:39 +02:00
Guillaume Lours
5cf1f0e2a4 bump compose-go to version v2.7.1
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-30 21:22:56 +02:00
Leonardo Peregrino
6198ed5bd2 fix linting errors
Signed-off-by: Leonardo Peregrino <55335068+leoperegrino@users.noreply.github.com>
2025-06-30 19:38:27 +02:00
Leonardo Peregrino
00ccddbde8 add volumes command test cases
Signed-off-by: Leonardo Peregrino <55335068+leoperegrino@users.noreply.github.com>
2025-06-30 19:38:27 +02:00
Leonardo Peregrino
63b441401e add volumes docs/reference/
Signed-off-by: Leonardo Peregrino <55335068+leoperegrino@users.noreply.github.com>
2025-06-30 19:38:27 +02:00
Leonardo Peregrino
3a7982fe45 add service filter to volumes command
Signed-off-by: Leonardo Peregrino <55335068+leoperegrino@users.noreply.github.com>
2025-06-30 19:38:27 +02:00
Leonardo Peregrino
5430caa172 add volumes command
Signed-off-by: Leonardo Peregrino <55335068+leoperegrino@users.noreply.github.com>
2025-06-30 19:38:27 +02:00
Nicolas De Loof
ee1b1e0a93 run docker model configure
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-30 19:22:35 +02:00
Nicolas De Loof
26e46d7cc8 e2e tests in CI
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-30 19:22:35 +02:00
Nicolas De Loof
a9e76943f6 introduce support for models
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-30 19:22:35 +02:00
Nicolas De Loof
b6a0df8d3c e2e compose run --env
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-30 19:09:22 +02:00
Guillaume Lours
5a063b7510 fix provider concurrent environment map accesses
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-30 19:07:10 +02:00
dependabot[bot]
ae49bba9be build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 28.2.2+incompatible to 28.3.0+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v28.2.2...v28.3.0)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-version: 28.3.0+incompatible
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-30 18:49:27 +02:00
Nicolas De Loof
51acc58453 mount /var/run/docker.sock for --use-api-socket
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-30 18:45:39 +02:00
Guillaume Lours
7c999d7f93 improve publish bind mount warning message
Co-authored-by: Nicolas De loof <nicolas.deloof@gmail.com>
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-30 18:45:30 +02:00
Guillaume Lours
ad750d6143 remove publish limitation on bind mount
list all bind mounts and ask user validation before publishing

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-30 18:45:30 +02:00
dependabot[bot]
fe382df507 build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 28.2.2+incompatible to 28.3.0+incompatible.
- [Commits](https://github.com/docker/cli/compare/v28.2.2...v28.3.0)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-version: 28.3.0+incompatible
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-30 18:37:19 +02:00
Nicolas De Loof
6501d59efc pass project.environment to bake
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-30 15:39:55 +02:00
Zhizhen He
33a782572f fix: typos
Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2025-06-30 14:26:17 +02:00
Guillaume Lours
65803ea12e remove error message from exec outpout by default
Add the error as a log for verbose mode

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-30 12:50:03 +02:00
Guillaume Lours
f613379373 make sure the post_start hooks fails
before we were assuming the container will be close before the post_start will be executed

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-30 12:37:58 +02:00
Guillaume Lours
3553aa26a6 add a default statut messsage to exec error to avoid empty line display
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-27 20:44:49 +02:00
Nathan Scott
257ea7b75d Swap to Reader in bake to avoid hangs on output
Signed-off-by: Nathan Scott <natedscott@gmail.com>
2025-06-27 16:19:28 +02:00
Guillaume Lours
d219aa66f4 don't fail down cmd if services with pre_stop hook already stopped/removed
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-27 14:41:52 +02:00
Guillaume Lours
c9ebfad78e exclude provider services from the list of dependencies that Compose should wait for
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-26 21:26:33 +02:00
Guillaume Lours
8e57362a0f use errdefs.IsNotImplemented to check if the logging is not implemented
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-26 16:42:57 +02:00
Guillaume Lours
29630f184e check progress default value instead of empty string to use BUILDKIT_PROGRESS env variable value
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-26 16:42:57 +02:00
Nicolas De Loof
6514c680a5 only expose API socket to service asking for it
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-24 17:17:41 +02:00
Nicolas De Loof
3394bf031b propagate target docker host set by --host to Bake
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-24 15:51:45 +02:00
dependabot[bot]
832a08f579 build(deps): bump github.com/moby/buildkit from 0.23.0 to 0.23.1
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.23.0 to 0.23.1.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.23.0...v0.23.1)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-version: 0.23.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-24 15:39:44 +02:00
Nicolas De Loof
aadce87b16 inject secrets/config just before container is started
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-24 12:26:46 +02:00
Nicolas De Loof
b3207c455d setting buildOptions.Services triggers image to be always rebuilt
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-24 11:26:52 +02:00
Guillaume Lours
769b7391ba don't create from run command during dependencies creation process
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-24 11:26:52 +02:00
Guillaume Lours
149b882ebf don't create from run command during dependencies creation process
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-24 11:26:52 +02:00
Sebastiaan van Stijn
c97e40e2b8 pkg/compose: remove uses of ExecOptions.Detach
This field was added in [moby@5130fe5d38837302e], which
added it for use as intermediate struct when parsing CLI flags (through
`runconfig.ParseExec`) in [moby@c786a8ee5e9db8f5f].

Commit [moby@9d9dff3d0d9e92adf] rewrote the CLI to use
Cobra, and as part of this introduced a separate `execOptions` type in
`api/client/container`, however the ExecOptions.Detach field was still
used as intermediate field to store the flag's value.

Given that the client doesn't use this field, let's remove its use to
prevent giving the impression that it's used anywhere.

[moby@5130fe5d38837302e]: 5130fe5d38
[moby@c786a8ee5e9db8f5f]: c786a8ee5e
[moby@9d9dff3d0d9e92adf]: 9d9dff3d0d

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-23 21:05:38 +02:00
Nicolas De Loof
22e23bd4dc networkMode
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-22 20:50:35 +02:00
Nicolas De Loof
2dde5faeb8 add support for cache_to with bake
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-22 07:44:38 +02:00
Nicolas De Loof
f7825a56bf bump buildx to v0.25
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-20 15:16:51 +02:00
Nicolas De Loof
4cf075ea0a bump compose-go to v2.6.5
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-20 15:16:51 +02:00
Nicolas De Loof
4f491ffa98 fix panic using w shortcut on project without watch support
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-16 11:15:45 +02:00
Nicolas De Loof
ea1c26d22a restore ContainerName in images --json
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-16 09:42:07 +02:00
Nicolas De Loof
9a5fa05ad6 add (temporary) support for use_api_socket
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-13 14:43:16 +02:00
Nicolas De Loof
276c229458 move run logic inside backend
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-13 14:43:16 +02:00
dependabot[bot]
eef448dc64 build(deps): bump github.com/containerd/containerd/v2
Bumps [github.com/containerd/containerd/v2](https://github.com/containerd/containerd) from 2.1.1 to 2.1.2.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v2.1.1...v2.1.2)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd/v2
  dependency-version: 2.1.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-13 12:07:26 +02:00
dependabot[bot]
343117233b build(deps): bump google.golang.org/grpc from 1.72.2 to 1.73.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.72.2 to 1.73.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.72.2...v1.73.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-version: 1.73.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-12 10:18:57 +02:00
Nicolas De Loof
f599a8cdd2 add support for extra_hosts building with bake
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-12 09:52:20 +02:00
Nicolas De Loof
63b06f5563 fix panic on failure starting plugin server
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-12 09:48:07 +02:00
Nicolas De Loof
1d34661e91 fix support for additional_contexts with service sub-dependencies
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-12 09:47:19 +02:00
Jeff Carter
0f9e6ab832 Fix the generated manifest for compose artifacts so that the empty config is not added as a layer.
Signed-off-by: Jeff Carter <jeff.carter@docker.com>
2025-06-11 16:51:51 +02:00
Nicolas De Loof
15c9651a3a restore os.Remove(metadataFile)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-11 16:12:08 +02:00
Nicolas De Loof
4893a8b9ad don't create metadatafile, just generate a random name
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-11 15:56:26 +02:00
Nicolas De Loof
97530790fa only look for required image in bake metadata
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-11 13:46:57 +02:00
Nicolas De Loof
213c03f99a produce bake targets for all services, group for services to build
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-10 09:30:22 +02:00
Nicolas De Loof
ebd7b761f2 sanitize service name so they can be used as bake targets
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-10 09:30:22 +02:00
x0rw
ea48480d80 Restore images format list format behaviour
Signed-off-by: x0rw <mahdi.svt5@gmail.com>
2025-06-07 23:07:49 +02:00
Nicolas De Loof
8151b59288 bump golang.org/x/sync v0.15.0
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-06 16:21:29 +02:00
Guillaume Lours
ec49baca56 do not forgot to remove the bake metadata file
few DD e2e tests failed on Windows due to permission issues

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-06 14:56:40 +02:00
Nicolas De Loof
7b9ad96240 fix SIGSEGV on Enable Watch
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-06 10:07:20 +02:00
Nicolas De Loof
9b67a48c33 (refactoting) Move watch logic into a dedicated Watcher type
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-05 16:48:05 +02:00
Nicolas De Loof
0d0e12cc85 use Bake by default
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-05 16:20:44 +02:00
Guillaume Lours
92fafccfb2 add validation for required parameters of provider service when metadata are available
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-05 15:12:32 +02:00
Guillaume Lours
fee8aee8f0 save provider metadata for Docker LSP
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-05 15:12:32 +02:00
Guillaume Lours
40f5786e68 add support of metadata subcommand for provider services
This command will let Compose and external tooling know about which parameters should be passed to the Compose plugin

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-06-05 15:12:32 +02:00
Nicolas De Loof
61e44da936 debug message to help diagnose platform mismatch
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-05 11:43:13 +02:00
Nicolas De Loof
0bf7d1ea25 pull does not require env_file being resolved
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-05 11:42:35 +02:00
dependabot[bot]
80ace63dfb build(deps): bump google.golang.org/grpc from 1.72.1 to 1.72.2
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.72.1 to 1.72.2.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.72.1...v1.72.2)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-version: 1.72.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-05 11:38:21 +02:00
Nicolas De Loof
27e90a3fdf end-to-end test
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-02 18:57:07 +02:00
Andrii Telesh
3ca75bdf55 Fix the inability to restart the Compose stack after network configuration change
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-02 18:57:07 +02:00
Nicolas De Loof
eb3074bbda include platform and creation date listing image used by running compose application
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-02 16:07:24 +02:00
Nicolas De Loof
f4fc010d6b build dependent service images when required
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-02 12:28:43 +02:00
Nicolas De Loof
693b9ef078 fix support for BUILDKIT_PROGRESS
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-06-02 11:03:04 +02:00
Sebastiaan van Stijn
046879a4a2 replace uses of golang.org/x/exp/(maps|slices) for stdlib
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-02 10:43:17 +02:00
Sebastiaan van Stijn
7c79b23005 pkg/bridge: fix importShadow: shadow of imported package (gocritic)
pkg/bridge/convert.go:114:3: importShadow: shadow of imported package 'user' (gocritic)
            user, err := user.Current()
            ^
    pkg/bridge/convert.go:142:51: importShadow: shadow of imported from 'github.com/docker/cli/cli/command/container' package 'cli' (gocritic)
    func LoadAdditionalResources(ctx context.Context, cli command.Cli, project *types.Project) (*types.Project, error) {
                                                      ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-02 10:43:17 +02:00
Sebastiaan van Stijn
ad4cbee498 bump github.com/docker/docker, docker/cli v28.2.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-02 10:39:56 +02:00
Carlos Daniel Vilaseca
60256a875c fix typo in suggestion log
Signed-off-by: Carlos Daniel Vilaseca <carlosd.vilaseca@ai.yareytech.com>
2025-05-31 19:40:32 +02:00
Nicolas De Loof
45bd60c33a resolve symlinks while making dockerfile path absolute
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-28 12:12:16 +02:00
Nicolas De Loof
cf89fd1aa1 also (re)start dependent services after watch rebuilt image
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-27 16:14:36 +02:00
Nicolas De Loof
23fef850b9 prefer use of slices.DeleteFunc
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-27 15:16:50 +02:00
Nicolas De Loof
12b73bea73 remove utils.Contains to prefer slice.ContainsFunc
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-27 15:16:50 +02:00
tongjicoder
2e71440bee refactor: use slices.Contains to simplify code
Signed-off-by: tongjicoder <tongjicoder@icloud.com>
2025-05-27 11:45:26 +02:00
Guillaume Lours
d49a68ecbf bridge - run transformer container as current user
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-27 10:35:30 +02:00
Guillaume Lours
be83f63f26 add e2e tests for bridge convert and transformers ls commands
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-27 10:35:30 +02:00
Guillaume Lours
9a9227ce64 add new bridge commands documentation
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-27 10:35:30 +02:00
Guillaume Lours
024f8ebdc5 add convert subcommand to bridge command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-27 10:35:30 +02:00
Guillaume Lours
8c622da20b add bridge command and transformations subcommands
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-27 10:35:30 +02:00
Guillaume Lours
bbb2b76a14 bump cli-doc-tools to v0.10.0
and update the documentation to pass CI checks

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-26 16:37:45 +02:00
Guillaume Lours
e45e58b3ec bumpd buildkit v0.22.0 and buildx v0.24.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-23 15:03:36 +02:00
Guillaume Lours
f52af4c868 bump compose-go to v2.6.4
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-23 14:53:24 +02:00
Nicolas De Loof
a54814ff39 e2e test
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-22 14:58:53 +02:00
Nicolas De Loof
a2d7548ca9 fix up --build with additional_context dependency
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-22 14:26:34 +02:00
Nicolas De Loof
8a2cb90a39 example provider implementation
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-21 15:59:30 +02:00
Nicolas De Loof
cc50ada725 report error (re)creating container
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-21 15:40:10 +02:00
dependabot[bot]
5c74f07991 build(deps): bump github.com/containerd/containerd/v2
Bumps [github.com/containerd/containerd/v2](https://github.com/containerd/containerd) from 2.1.0 to 2.1.1.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v2.1.0...v2.1.1)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd/v2
  dependency-version: 2.1.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-21 12:03:59 +02:00
Guillaume Lours
7e198ee6a3 remove provenance build flag for now
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-20 18:21:05 +02:00
Guillaume Lours
0566431c64 only use attestation when building image outside the development inner loop
when building a image, by default attestation are generated and modify the image ID which trigger a container recreation on up, run command even if there isn't any changes on the image content itself

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-20 18:21:05 +02:00
Nicolas De Loof
4f6cc2a330 run ContainerStart sequentially
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-20 09:47:58 +02:00
Nicolas De Loof
2352a4a016 introduce config --lock-image-digests
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-19 13:53:01 +02:00
Guillaume Lours
1f076a3781 bump compose-go to v2.6.3
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-19 12:35:17 +02:00
Guillaume Lours
009a239510 remove convert alias from config command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-19 12:30:09 +02:00
dependabot[bot]
3059574288 build(deps): bump google.golang.org/grpc from 1.72.0 to 1.72.1
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.72.0 to 1.72.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.72.0...v1.72.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-version: 1.72.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-19 12:20:37 +02:00
dependabot[bot]
1229a69384 build(deps): bump github.com/containerd/containerd/v2
Bumps [github.com/containerd/containerd/v2](https://github.com/containerd/containerd) from 2.0.5 to 2.1.0.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v2.0.5...v2.1.0)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd/v2
  dependency-version: 2.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-19 12:07:46 +02:00
Nicolas De Loof
f2a88e02a0 ensure build dependencies are enabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-19 11:51:01 +02:00
Nicolas De Loof
7f9101845d report cancelled pull after another one failed
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-19 11:41:05 +02:00
Guillaume Lours
944e5e67a1 do not throw an error on build with provider services
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-16 17:47:09 +02:00
Anvar Umuraliev
23fc76a540 Fix quiet option when using COMPOSE_BAKE=1
Signed-off-by: Anvar Umuraliev <an.umuraliev@gmail.com>
2025-05-15 15:42:25 +02:00
Nicolas De Loof
053d225824 append .exe to provider name doing executable lookup on windows
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-14 17:19:35 +02:00
Nicolas De Loof
93b597ccec remove Docker EULA licensing which isn't relevant since Docker switched to a subscription model
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-14 15:02:13 +02:00
Guillaume Lours
4dcaf94c32 add support of 'debug' messages in the communication between Compose and provider binaries
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-13 18:32:03 +02:00
Nicolas De Loof
07e7619f4e set provider environment
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-13 11:31:38 +02:00
Nicolas De Loof
ed81185c5c fix provider info message
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-12 14:15:28 +02:00
Nicolas De Loof
22f8a7009f provider.options can be an array
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-12 11:49:49 +02:00
Guillaume Lours
91a0aa0265 skip push step for provider services
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-12 10:43:25 +02:00
Nicolas De Loof
7cea455c4d simplification
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-07 15:53:05 +02:00
dependabot[bot]
559a51e590 build(deps): bump golang.org/x/sys from 0.32.0 to 0.33.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.32.0 to 0.33.0.
- [Commits](https://github.com/golang/sys/compare/v0.32.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-07 12:31:41 +02:00
dependabot[bot]
480a556bf0 build(deps): bump golang.org/x/sync from 0.13.0 to 0.14.0
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.13.0 to 0.14.0.
- [Commits](https://github.com/golang/sync/compare/v0.13.0...v0.14.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-version: 0.14.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-07 12:19:47 +02:00
dependabot[bot]
6263361190 build(deps): bump github.com/moby/buildkit from 0.21.0 to 0.21.1
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.21.0 to 0.21.1.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.21.0...v0.21.1)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-version: 0.21.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-07 12:07:27 +02:00
Guillaume Lours
9ee03c3fec bump compose-go to v2.6.2
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-05-07 11:43:56 +02:00
Alessio Perugini
4bf18d2325 docs: regenerate
Signed-off-by: Alessio Perugini <alessio@perugini.xyz>
2025-05-06 22:33:52 +02:00
Alessio Perugini
f0f47a8aa8 e2e: add tests
Signed-off-by: Alessio Perugini <alessio@perugini.xyz>
2025-05-06 22:33:52 +02:00
Alessio Perugini
d6e3fa6d74 Fix config --variables not honoring the --format flag
When providing the --variables with --format flag, the current
implementation always printed in human readable form.
This patch correctly add the missing format in the formatter.Print
function, making the commands behave as an user would expect.

Example:
`config --variables --format json`

Signed-off-by: Alessio Perugini <alessio@perugini.xyz>
2025-05-06 22:33:52 +02:00
Nicolas De Loof
16e83f002d introduce build --check
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-06 07:54:30 +02:00
Nicolas De Loof
2dbef234dc document behavior on missing extension
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-05 14:33:35 +02:00
Nicolas De Loof
20f0ffec0b seach for provider binary in PATH
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-05 11:21:21 +02:00
Nicolas De Loof
cee6a3c660 document extensibility using service.provider
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-05 11:21:21 +02:00
Nicolas De Loof
fc8c56b407 select services implicitly declared by a service:xx build dependency
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-05 10:20:19 +02:00
Nicolas De Loof
9c998a934f fix collect image digests for service images built by bake
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-05-05 10:14:35 +02:00
Nicolas De Loof
0403f0d76d e2e test for start_interval
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-04-30 11:08:09 +02:00
dependabot[bot]
91d04a5ca9 build(deps): bump go.uber.org/mock from 0.5.1 to 0.5.2
Bumps [go.uber.org/mock](https://github.com/uber/mock) from 0.5.1 to 0.5.2.
- [Release notes](https://github.com/uber/mock/releases)
- [Changelog](https://github.com/uber-go/mock/blob/main/CHANGELOG.md)
- [Commits](https://github.com/uber/mock/compare/v0.5.1...v0.5.2)

---
updated-dependencies:
- dependency-name: go.uber.org/mock
  dependency-version: 0.5.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-29 11:56:08 +02:00
Guillaume Lours
d2274ebe6c display proper event message for provider services on up and down
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-04-28 14:48:26 +02:00
Nicolas De Loof
6e35652182 fix support for remote absolute path
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-04-28 11:05:06 +02:00
Anvar Umuraliev
5bb46035cf Set --progress flag default value from env if provided
Signed-off-by: Anvar Umuraliev <an.umuraliev@gmail.com>
2025-04-25 11:56:07 +02:00
Anvar Umuraliev
f8dae06df8 Add support for COMPOSE_PROGRESS env variable
COMPOSE_PROGRESS variable supports 5 values:
- "auto" - detect console capabilities
- "tty" - use terminal capability for advanced rendering
- "plain" - dump raw events to output
- "quiet" - don't display events
- "json" - outputs a machine-readable JSON stream

Signed-off-by: Anvar Umuraliev <an.umuraliev@gmail.com>
2025-04-25 11:56:07 +02:00
Nicolas De Loof
955e4ed94e introduce networks.interface_name
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-04-24 12:06:17 +02:00
Guillaume Lours
60385e6065 bump compose-go to v2.6.1
fixing parsing of npipe as volume type

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-04-22 17:17:34 +02:00
Guillaume Lours
f5491328bb remove support of Synchronize File Shares integration with Docker Desktop
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-04-22 15:29:23 +02:00
dependabot[bot]
f46689a75e build(deps): bump github.com/containerd/containerd/v2
Bumps [github.com/containerd/containerd/v2](https://github.com/containerd/containerd) from 2.0.4 to 2.0.5.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v2.0.4...v2.0.5)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd/v2
  dependency-version: 2.0.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-22 15:16:18 +02:00
dependabot[bot]
8fd0c297f5 build(deps): bump google.golang.org/grpc from 1.71.1 to 1.72.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.71.1 to 1.72.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.71.1...v1.72.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-version: 1.72.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-22 15:03:54 +02:00
dependabot[bot]
f3bbfdae58 build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 28.1.0+incompatible to 28.1.1+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v28.1.0...v28.1.1)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-version: 28.1.1+incompatible
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-22 14:52:31 +02:00
dependabot[bot]
322c531a8c build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 28.1.0+incompatible to 28.1.1+incompatible.
- [Commits](https://github.com/docker/cli/compare/v28.1.0...v28.1.1)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-version: 28.1.1+incompatible
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-22 14:40:27 +02:00
skanehira
bf6b447263 fix: concurrent map writes when pulling
Signed-off-by: skanehira <sho19921005@gmail.com>
2025-04-22 10:46:05 +02:00
Simon Ser
a96c305b25 build: write --print output to stdout
stdinfo should only be used for status/progress messages: it
defaults to stderr and makes piping the output trickier. bakex
always writes `docker buildx bake --print` always uses stdout.

Signed-off-by: Simon Ser <contact@emersion.fr>
2025-04-22 10:13:07 +02:00
Sebastiaan van Stijn
2d7cd2a999 go.mod: bump github.com/docker/cli v28.1.0
full diff: https://github.com/docker/cli/compare/v28.0.4...v28.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 16:17:55 +02:00
Sebastiaan van Stijn
cbb616ca0c go.mod: bump github.com/docker/docker v28.1.0
full diff: https://github.com/docker/docker/compare/v28.0.4...v28.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 16:17:55 +02:00
Sebastiaan van Stijn
640c7deae0 downgrade go-difflib and go-spew to tagged releases
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 14:47:36 +02:00
Sebastiaan van Stijn
75b48cfc88 go.mod: bump github.com/docker/buildx v0.23.0
full diff: https://github.com/docker/buildx/compare/v0.22.0...v0.23.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 13:49:16 +02:00
Sebastiaan van Stijn
047899c3e6 go.mod: bump github.com/moby/buildkit v0.21.0
full diff: https://github.com/moby/buildkit/compare/v0.20.2...v0.21.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 13:49:16 +02:00
Sebastiaan van Stijn
f91b41875e go.mod: bump github.com/docker/docker-credential-helpers v0.9.3
full diff: https://github.com/docker/docker-credential-helpers/compare/v0.8.2...v0.9.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 13:49:16 +02:00
Sebastiaan van Stijn
42cccb1fe8 go.mod: bump golang.org/x/net v0.39.0
full diff: https://github.com/golang/net/compare/v0.36.0...v0.39.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 13:49:16 +02:00
Sebastiaan van Stijn
674af0d66d go.mod: bump golang.org/x/crypto v0.37.0
full diff: https://github.com/golang/crypto/compare/v0.35.0...v0.37.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 13:49:16 +02:00
Sebastiaan van Stijn
877d232330 go.mod: bump golang.org/x/term v0.31.0
full diff: https://github.com/golang/term/compare/v0.29.0...v0.31.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 13:49:16 +02:00
Sebastiaan van Stijn
4bba13233b go.mod: bump golang.org/x/text v0.24.0
full diff: https://github.com/golang/text/compare/v0.22.0...v0.24.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 13:49:16 +02:00
Sebastiaan van Stijn
a786e70b0e go.mod: bump golang.org/x/time v0.11.0
full diff: https://github.com/golang/time/compare/v0.6.0...v0.11.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 13:49:16 +02:00
Sebastiaan van Stijn
13cd780f30 migrate to use github.com/moby/go-archive
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 13:28:49 +02:00
dufucun
8e2f799cd7 chore: make function comment match function name
Signed-off-by: dufucun <dufuchun@sohu.com>
2025-04-16 13:33:16 +02:00
dependabot[bot]
2a84dfecfd build(deps): bump golang.org/x/crypto from 0.32.0 to 0.35.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.32.0 to 0.35.0.
- [Commits](https://github.com/golang/crypto/compare/v0.32.0...v0.35.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.35.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-15 13:21:42 +02:00
dependabot[bot]
f6913b0866 build(deps): bump go.uber.org/mock from 0.5.0 to 0.5.1
Bumps [go.uber.org/mock](https://github.com/uber/mock) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/uber/mock/releases)
- [Changelog](https://github.com/uber-go/mock/blob/main/CHANGELOG.md)
- [Commits](https://github.com/uber/mock/compare/v0.5.0...v0.5.1)

---
updated-dependencies:
- dependency-name: go.uber.org/mock
  dependency-version: 0.5.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-15 12:16:54 +02:00
dependabot[bot]
d629fffa9e build(deps): bump google.golang.org/grpc from 1.71.0 to 1.71.1
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.71.0 to 1.71.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.71.0...v1.71.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-04-15 11:47:39 +02:00
dependabot[bot]
7471e16d85 build(deps): bump github.com/moby/buildkit from 0.20.1 to 0.20.2
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.20.1 to 0.20.2.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.20.1...v0.20.2)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-15 11:34:01 +02:00
Guillaume Lours
51907d9f72 fix zizmor security alerts on GHA workflows
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-04-11 16:45:19 +02:00
Nicolas De Loof
a3f88a0a1d test to cover preference for bind API
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-04-11 09:53:48 +02:00
Nicolas De Loof
c83f1285a8 use bind API for bind mounts
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-04-10 18:58:20 +02:00
CrazyMax
29e642e232 ci(bin-image): free disk space
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-04-10 17:01:52 +02:00
Nicolas De Loof
0c37c10964 mount API is not strictly equivalent to bind
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-04-10 11:52:35 +02:00
dependabot[bot]
43cc2be8ca build(deps): bump github.com/compose-spec/compose-go/v2
Bumps [github.com/compose-spec/compose-go/v2](https://github.com/compose-spec/compose-go) from 2.5.1-0.20250409070949-8e1a035095ca to 2.6.0.
- [Release notes](https://github.com/compose-spec/compose-go/releases)
- [Commits](https://github.com/compose-spec/compose-go/commits/v2.6.0)

---
updated-dependencies:
- dependency-name: github.com/compose-spec/compose-go/v2
  dependency-version: 2.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-10 11:52:19 +02:00
Nicolas De Loof
01e83defc2 introduce volume.type=image
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-04-09 16:59:42 +02:00
Adel Sevastianov
846161d447 Fix linting issue with resp.Body.Close()
Signed-off-by: Adel Sevastianov <102406080+Saracomethstein@users.noreply.github.com>
2025-04-09 15:25:53 +02:00
Adel Sevastianov
0bcc629fbe refactor: improve Desktop client structure
Signed-off-by: Adel Sevastianov <102406080+Saracomethstein@users.noreply.github.com>
2025-04-09 15:25:53 +02:00
Sebastiaan van Stijn
482b622282 pkg/compose: implement Export using atomicwriter
Replaces the use of cli/command.CopyToFile with an atomicwriter,
as cli/command.CopyToFile will be deprecated in the next release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 08:26:11 +02:00
Nicolas De Loof
ee33143026 capture git fetch output when debug output is enabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-04-08 12:03:41 +02:00
dependabot[bot]
cb0b5f6e27 build(deps): bump golang.org/x/sync from 0.12.0 to 0.13.0
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.12.0 to 0.13.0.
- [Commits](https://github.com/golang/sync/compare/v0.12.0...v0.13.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-version: 0.13.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-08 11:51:03 +02:00
dependabot[bot]
1384853538 build(deps): bump golang.org/x/sys from 0.31.0 to 0.32.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.31.0 to 0.32.0.
- [Commits](https://github.com/golang/sys/compare/v0.31.0...v0.32.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.32.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-08 11:39:33 +02:00
Guillaume Lours
096b1e32d3 plugin provider support: check docker model runner status
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-04-08 11:19:01 +02:00
Guillaume Lours
bf71138df6 cleanup runPluging function
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-04-08 11:19:01 +02:00
sigi-glovebox
a1f673dcf5 Update secret detector to fix vulnerability https://github.com/golang-jwt/jwt/security/advisories/GHSA-mh63-6h87-95cp
Signed-off-by: sigi-glovebox <sigi@gloveboxapp.com>
2025-04-03 21:06:26 +02:00
Guillaume Lours
02c747a7de bump compose-go to custom version of v2.5.0
should be replace by v2.5.1 it will be released

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-04-03 15:13:44 +02:00
Nicolas De Loof
88f4f265db communicate with plugin using json events
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-04-03 15:13:44 +02:00
Nicolas De Loof
e67348222f DRAFT external services plugin support
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-04-03 15:13:44 +02:00
Suleiman Dibirov
b543380708 feat(run): Add --quiet and --quiet-build options for the run command
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2025-04-03 14:50:38 +02:00
Guillaume Lours
2e75185a07 bump golang to 1.23.8
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-04-02 16:31:43 +02:00
Guillaume Lours
7bedb5a02c bump golangci-lint to version v2.0.2
and apply migration script

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-03-31 18:50:15 +02:00
Nicolas De Loof
f9cd4d0b1d bump docker,cli,buildx
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-31 11:05:19 +02:00
Nicolas De Loof
0badcf3c8d include implicit build dependencies in build command
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-28 10:25:41 +01:00
k-kbk
ec49db98d4 fix: replace docker-compose.yml with compose.yaml
Signed-off-by: k-kbk <kkbk0077@gmail.com>
2025-03-27 15:44:00 +01:00
k-kbk
e5a353b34d fix: replace docker-compose.yml with compose.yaml
Signed-off-by: k-kbk <kkbk0077@gmail.com>
2025-03-27 15:44:00 +01:00
Nicolas De Loof
43e456145c fix scale completion
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-26 17:44:54 +01:00
Nicolas De Loof
75368c7859 introduce build --print to dump equivalent bakefile
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-26 12:24:31 +01:00
Suleiman Dibirov
6e814eac35 fix(secrets): Reverted secrets file mode 440 -> 444
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2025-03-25 07:00:24 +01:00
Nicolas De Loof
a0d1c3f944 introduce config --no-env-resolution
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-24 15:46:04 +01:00
Nicolas De Loof
0c5bd16da1 bake parses "${}" in DockerfileInline as a variable
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-24 11:36:42 +01:00
Remco Kranenburg
b0badf1eb0 Set watch option --prune=true as default
Signed-off-by: Remco Kranenburg <remco.kranenburg@crunchr.com>
2025-03-19 17:48:05 +01:00
Nicolas De Loof
342a2a9e71 Fix support for depends_on.restart in up and restart commands
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-19 15:29:50 +01:00
dependabot[bot]
7814e5798c build(deps): bump github.com/containerd/containerd/v2
Bumps [github.com/containerd/containerd/v2](https://github.com/containerd/containerd) from 2.0.3 to 2.0.4.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v2.0.3...v2.0.4)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-18 11:02:40 +01:00
dependabot[bot]
42b2e11094 build(deps): bump github.com/docker/buildx from 0.21.2 to 0.21.3
Bumps [github.com/docker/buildx](https://github.com/docker/buildx) from 0.21.2 to 0.21.3.
- [Release notes](https://github.com/docker/buildx/releases)
- [Commits](https://github.com/docker/buildx/compare/v0.21.2...v0.21.3)

---
updated-dependencies:
- dependency-name: github.com/docker/buildx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-18 10:45:25 +01:00
Nicolas De Loof
6a8c0988cf run only loads required service env_file and ignores others
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-18 09:39:15 +01:00
Matiboux
9129abe516 Fix edge-case bug path prefix check for watch & bind mounts
Signed-off-by: Matiboux <matiboux@gmail.com>
2025-03-17 17:40:40 +01:00
Nicolas De Loof
f38f3f754c PWD
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-17 17:26:45 +01:00
Nicolas De Loof
ea07ba8e2a fix support for secret set by env inside included file
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-14 16:21:45 +01:00
Max Proske
432ae23b0e Test commandName subcommand order
Signed-off-by: Max Proske <max@mproske.com>
2025-03-14 10:00:45 +01:00
Guillaume Lours
b6f313b8a5 bump compose-go to version v2.4.9
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-03-13 16:54:22 +01:00
Guillaume Lours
13618756dc make publish a regular command of Compose
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-03-13 16:17:00 +01:00
Dominik Menke
6c1e21572a lint: address gofumpt issues
Signed-off-by: Dominik Menke <dom@digineo.de>
2025-03-13 14:23:51 +01:00
Dominik Menke
33e863ac6c fix linting issue
Signed-off-by: Dominik Menke <dom@digineo.de>
2025-03-13 14:23:51 +01:00
Dominik Menke
f70209cf15 review: move Summary/Replica collection from cmd/ to pkg/
Signed-off-by: Dominik Menke <dom@digineo.de>
2025-03-13 14:23:51 +01:00
Dominik Menke
62e832eb50 compose top: reduce tabwriter padding
Signed-off-by: Dominik Menke <dom@digineo.de>
2025-03-13 14:23:51 +01:00
Dominik Menke
80e8fda14f compose top: ensure CMD is right-most column
Signed-off-by: Dominik Menke <dom@digineo.de>
2025-03-13 14:23:51 +01:00
Dominik Menke
375a279785 top: expose container labels
Signed-off-by: Dominik Menke <dom@digineo.de>
2025-03-13 14:23:51 +01:00
Dominik Menke
a766e1669a condense output of compose top
This changes the output format of `compose top` and inlines the service
container name into the table.

Previously, `compose top` had printed something like:

  <service name>
  UID    PID   ...
  root   1     ...

Now, the output looks more like this:

  SERVICE   UID    PID   ...
  <name>    root   1     ...

Signed-off-by: Dominik Menke <dom@digineo.de>
2025-03-13 14:23:51 +01:00
Matt Landis
793c6f1715 add cli.isatty attribute to spans generated by compose
Signed-off-by: Matt Landis <matt.landis@docker.com>
2025-03-13 09:06:15 +01:00
dependabot[bot]
8e3e1f7f8b build(deps): bump tags.cncf.io/container-device-interface
Bumps [tags.cncf.io/container-device-interface](https://github.com/cncf-tags/container-device-interface) from 0.8.1 to 1.0.0.
- [Release notes](https://github.com/cncf-tags/container-device-interface/releases)
- [Changelog](https://github.com/cncf-tags/container-device-interface/blob/main/RELEASE.md)
- [Commits](https://github.com/cncf-tags/container-device-interface/compare/v0.8.1...v1.0.0)

---
updated-dependencies:
- dependency-name: tags.cncf.io/container-device-interface
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-12 15:50:14 +01:00
Nicolas De Loof
83cafe2838 Add support to pass env-from-file to docker compose run
Signed-off-by: Vedant Koditkar <vedant.koditkar@outlook.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-12 09:04:39 +01:00
Guillaume Lours
55b5f233c2 use Defang secret-detector to identify potential secret leaks before publishing OCI artifacts
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-03-11 15:02:37 +01:00
Nicolas De Loof
c3a0c35681 implement extends.file replace without yqlib
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-11 14:18:41 +01:00
Nicolas De Loof
8615e9a7c1 deprecate --y, prefer --yes
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-11 09:01:36 +01:00
Nicolas De Loof
b23728941d only load env_file after services have been selected
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-10 08:32:03 +01:00
dependabot[bot]
1a7343bc88 build(deps): bump github.com/moby/buildkit from 0.20.0 to 0.20.1
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.20.0 to 0.20.1.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.20.0...v0.20.1)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-07 16:44:02 +01:00
Guillaume Lours
41e6094041 add warning message when a remote configuration include an another remote config
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-03-07 16:30:32 +01:00
Nicolas De Loof
66a47169d5 Publish compose file with required siblings used by extends
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-07 13:58:10 +01:00
dependabot[bot]
4c72d3a0e3 build(deps): bump golang.org/x/sys from 0.30.0 to 0.31.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.30.0 to 0.31.0.
- [Commits](https://github.com/golang/sys/compare/v0.30.0...v0.31.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-06 19:07:25 +01:00
dependabot[bot]
59f39b9990 build(deps): bump google.golang.org/grpc from 1.70.0 to 1.71.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.70.0 to 1.71.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.70.0...v1.71.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-06 18:55:59 +01:00
dependabot[bot]
7ab65ba127 build(deps): bump golang.org/x/sync from 0.11.0 to 0.12.0
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.11.0 to 0.12.0.
- [Commits](https://github.com/golang/sync/compare/v0.11.0...v0.12.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-06 18:44:23 +01:00
Guillaume Lours
d9f05d72d2 improve message suggesting using bake
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-03-06 18:12:43 +01:00
Guillaume Lours
7b88c5b0ed display interpolation variables and their values when running a remote stack
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-03-06 09:46:37 +01:00
dependabot[bot]
eaf9800948 build(deps): bump github.com/opencontainers/image-spec
Bumps [github.com/opencontainers/image-spec](https://github.com/opencontainers/image-spec) from 1.1.0 to 1.1.1.
- [Release notes](https://github.com/opencontainers/image-spec/releases)
- [Changelog](https://github.com/opencontainers/image-spec/blob/main/RELEASES.md)
- [Commits](https://github.com/opencontainers/image-spec/compare/v1.1.0...v1.1.1)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/image-spec
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-05 10:19:45 +01:00
Nicolas De Loof
4c2ecb542f reject compose file with bind mounts
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-04 16:10:53 +01:00
Nicolas De Loof
bcd000ab40 refuse to publish compose file with local include
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-04 15:55:17 +01:00
dependabot[bot]
8092ce9414 build(deps): bump github.com/docker/buildx from 0.21.1 to 0.21.2
Bumps [github.com/docker/buildx](https://github.com/docker/buildx) from 0.21.1 to 0.21.2.
- [Release notes](https://github.com/docker/buildx/releases)
- [Commits](https://github.com/docker/buildx/compare/v0.21.1...v0.21.2)

---
updated-dependencies:
- dependency-name: github.com/docker/buildx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-04 10:44:04 +01:00
dependabot[bot]
97595066e3 build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 28.0.0+incompatible to 28.0.1+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v28.0.0...v28.0.1)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-04 07:52:24 +01:00
dependabot[bot]
508309414f build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 28.0.0+incompatible to 28.0.1+incompatible.
- [Commits](https://github.com/docker/cli/compare/v28.0.0...v28.0.1)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-04 07:52:00 +01:00
Guillaume Lours
b6c8a2b9fc display the location of OCI or GIT Compose stack download
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-03-03 22:09:06 +01:00
Nicolas De Loof
19571c2c81 e2e test for watch.include
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-03 21:59:26 +01:00
Nicolas De Loof
0ef7bbcddc introduce watch.include
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-03-03 21:59:26 +01:00
Guillaume Lours
66dfa7d181 block the publication of an OCI artifact if one or more services contain only a build section
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-03-03 16:23:21 +01:00
Max Proske
876ecc48be Test version command
Signed-off-by: Max Proske <max@mproske.com>
2025-02-26 16:35:08 +01:00
Nicolas De Loof
c7bf302c23 wrap builder execution within a project/build span
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-26 11:23:01 +01:00
Nicolas De Loof
7b3bdbe037 otel attribute to track builder implementation selected
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-26 11:23:01 +01:00
dependabot[bot]
094b48fd74 build(deps): bump github.com/google/go-cmp from 0.6.0 to 0.7.0
Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](https://github.com/google/go-cmp/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: github.com/google/go-cmp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-26 09:31:01 +01:00
dependabot[bot]
43c52e2a80 build(deps): bump tags.cncf.io/container-device-interface
Bumps [tags.cncf.io/container-device-interface](https://github.com/cncf-tags/container-device-interface) from 0.8.0 to 0.8.1.
- [Release notes](https://github.com/cncf-tags/container-device-interface/releases)
- [Commits](https://github.com/cncf-tags/container-device-interface/compare/v0.8.0...v0.8.1)

---
updated-dependencies:
- dependency-name: tags.cncf.io/container-device-interface
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-26 09:30:52 +01:00
Nicolas De Loof
6c1ee1069b support refresh pull policy
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-25 17:05:23 +01:00
Nicolas De Loof
e38b729a30 fix service: additional_contexts running internal buildkit client
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-25 09:47:02 +01:00
Andrew Kramer
145bb8466d Update yaml docs
Signed-off-by: Andrew Kramer <andrew.d.kramer.80@gmail.com>
2025-02-22 11:17:19 +01:00
Andrew Kramer
acac184135 Link to configuration file docs
Signed-off-by: Andrew Kramer <andrew.d.kramer.80@gmail.com>
2025-02-22 11:17:19 +01:00
Simon Ser
3292740c19 build: only print COMPOSE_BAKE recommendation when disabled
docker-compose now prints a recommendation to set COMPOSE_BAKE=true
when service deps are used. However, when the user opts-in to bake,
the recommendation is still printed.

Only print the recommendation when bake is disabled.

Signed-off-by: Simon Ser <contact@emersion.fr>
2025-02-22 11:14:36 +01:00
Nicolas De Loof
cae8e84636 require go 1.23|1.24 (stable)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-21 16:54:16 +01:00
Nicolas De Loof
da2eff4ba7 add support for gw_priority, enable_ipv4 (requires docker v28.0)
This adds support for the GwPriority API field in API v1.48 (docker v28.0).
It can be set on both docker container run and docker network connect.

This option is used by the Engine to determine which network provides
the default gateway for a container.

It also adds support for enable_ipv4, which allows enabling (default)
or disabling IPv4 address assignment for a network.

Co-authored-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-21 15:54:41 +01:00
Sebastiaan van Stijn
20f780e95a make the mocks generator happy
Seems like it resolves the alias, and uses that instead, instead of
the actual type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-21 15:23:25 +01:00
Sebastiaan van Stijn
cf2fc2005c go.mod: docker/docker, docker/cli v28.0.0, buildx v0.21.1
full diff:

- https://github.com/docker/docker/compare/v27.5.1...v28.0.0
- https://github.com/docker/cli/compare/v27.5.1...v28.0.0
- https://github.com/docker/buildx/compare/v0.20.1...v0.21.1

Co-authored-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-21 15:23:25 +01:00
Sebastiaan van Stijn
d0398a4681 go.mod: github.com/moby/buildkit v0.20.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-21 15:23:25 +01:00
Sebastiaan van Stijn
ac40aae4c3 go.mod: golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-21 15:23:25 +01:00
Sebastiaan van Stijn
f25fea5e6d pkg/compose: stopDependentContainers: rename var that shadowed
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-21 15:23:25 +01:00
Nicolas De Loof
b27f56eb19 fix error message when detach is implied by wait
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-21 09:48:56 +01:00
Max Proske
4e593ed074 Fix pull --parallel and --no-parallel deprecation warnings missing
Signed-off-by: Max Proske <max@mproske.com>
2025-02-20 14:09:58 +01:00
Guillaume Lours
d956ff13da don't display bake suggestion when using --progress with quiet or json option
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-02-18 18:45:52 +01:00
Nicolas De Loof
5f7c9a2b4b report error using non-file secret|config with read-only service
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-18 11:33:13 +01:00
dependabot[bot]
fd0c23a1c9 build(deps): bump google.golang.org/grpc from 1.68.1 to 1.70.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.68.1 to 1.70.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.68.1...v1.70.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-18 11:04:32 +01:00
Nicolas De Loof
7aa64ae9cb run watch standalone if menu fails to start
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-18 10:41:23 +01:00
dependabot[bot]
c23eea9341 build(deps): bump github.com/spf13/cobra from 1.8.1 to 1.9.1
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.8.1 to 1.9.1.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.8.1...v1.9.1)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-17 20:08:53 +01:00
Sebastiaan van Stijn
036da47950 go.mod: remove toolchain directive
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-12 08:19:25 +01:00
Nicolas De Loof
33172d5e4d let user know bake is now supported
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-12 08:18:20 +01:00
dependabot[bot]
3f1a6b72a5 build(deps): bump gotest.tools/v3 from 3.5.1 to 3.5.2
Bumps [gotest.tools/v3](https://github.com/gotestyourself/gotest.tools) from 3.5.1 to 3.5.2.
- [Release notes](https://github.com/gotestyourself/gotest.tools/releases)
- [Commits](https://github.com/gotestyourself/gotest.tools/compare/v3.5.1...v3.5.2)

---
updated-dependencies:
- dependency-name: gotest.tools/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-11 10:53:38 +01:00
dependabot[bot]
f9a6e6c414 build(deps): bump golang.org/x/sync from 0.10.0 to 0.11.0
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.10.0 to 0.11.0.
- [Commits](https://github.com/golang/sync/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-11 10:53:02 +01:00
dependabot[bot]
18ef6e592b build(deps): bump github.com/spf13/pflag from 1.0.5 to 1.0.6
Bumps [github.com/spf13/pflag](https://github.com/spf13/pflag) from 1.0.5 to 1.0.6.
- [Release notes](https://github.com/spf13/pflag/releases)
- [Commits](https://github.com/spf13/pflag/compare/v1.0.5...v1.0.6)

---
updated-dependencies:
- dependency-name: github.com/spf13/pflag
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-11 10:50:47 +01:00
Max Proske
2884d6df0d Fix ls --quiet help description
Signed-off-by: Max Proske <max@mproske.com>
2025-02-10 17:30:39 +01:00
Sebastiaan van Stijn
4459012a4f Dockerfile: update golangci-lint to v1.63.4
make sure it's compatible with go1.23

full diff: https://github.com/golangci/golangci-lint/compare/v1.60.2...v1.63.4
Changelog: https://golangci-lint.run/product/changelog/#v1634

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-10 17:03:36 +01:00
Sebastiaan van Stijn
6f1f76c0e6 pkg/e2e: fix contains: use assert.Contains (testifylint)
pkg/e2e/ps_test.go:50:5: contains: use assert.Contains (testifylint)
                    assert.True(t, strings.Contains(line, "127.0.0.1:8001->8000/tcp"))
                    ^
    pkg/e2e/ps_test.go:54:5: contains: use assert.Contains (testifylint)
                    assert.True(t, strings.Contains(line, "80/tcp, 443/tcp, 8080/tcp"))
                    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-10 17:03:36 +01:00
Nicolas De Loof
ed72c21871 use BlockUntilContext
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-10 15:24:46 +01:00
dependabot[bot]
fa4cfb652e build(deps): bump github.com/jonboulle/clockwork from 0.4.0 to 0.5.0
Bumps [github.com/jonboulle/clockwork](https://github.com/jonboulle/clockwork) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/jonboulle/clockwork/releases)
- [Commits](https://github.com/jonboulle/clockwork/compare/v0.4.0...v0.5.0)

---
updated-dependencies:
- dependency-name: github.com/jonboulle/clockwork
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-10 15:24:46 +01:00
dependabot[bot]
200638b024 build(deps): bump github.com/otiai10/copy from 1.14.0 to 1.14.1
Bumps [github.com/otiai10/copy](https://github.com/otiai10/copy) from 1.14.0 to 1.14.1.
- [Release notes](https://github.com/otiai10/copy/releases)
- [Commits](https://github.com/otiai10/copy/compare/v1.14.0...v1.14.1)

---
updated-dependencies:
- dependency-name: github.com/otiai10/copy
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-10 15:04:10 +01:00
dependabot[bot]
a0320f12ef build(deps): bump golang.org/x/sys from 0.28.0 to 0.30.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.28.0 to 0.30.0.
- [Commits](https://github.com/golang/sys/compare/v0.28.0...v0.30.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-10 15:03:31 +01:00
Nicolas De Loof
f8a912ab9a bump compose-go v2.4.8
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-10 15:02:01 +01:00
Sebastiaan van Stijn
c23a7e7281 golangci-lint: enable copyloopvar linter
capturing loop variables is no longer needed in go1.22 and higher;
https://go.dev/blog/loopvar-preview

This path enables the copyloopvar linter, which finds places where capturing
is no longer needed, and removes locations where they could be removed.

Also made some minor changes, and renamed some vars in places where
we could use a shorter name that's less likely to conflict with imports.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-10 13:46:41 +01:00
Sebastiaan van Stijn
49575ef499 gha: add docker engine v28.x to the test-matrix
currently v28.0.0-rc.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 17:38:01 +01:00
Sebastiaan van Stijn
faa46d374d go.mod: github.com/moby/term v0.5.2
- update github.com/Azure/go-ansiterm to v0.0.0-20250102033503-faa5f7b0171c
  to fix OSC string terminator parsing.
- add security policy
- update github actions and test against go1.22, go1.23

full diff: https://github.com/moby/term/compare/v0.5.0...v0.5.2

update github.com/Azure/go-ansiterm faa5f7b0171c

- fix OSC string terminator parsing

diff: d185dfc1b5...faa5f7b017

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 17:37:45 +01:00
Max Proske
6ecb8d40ae Full test coverage for convert compatibility cmd
Signed-off-by: Max Proske <max@mproske.com>
2025-02-05 18:08:54 +01:00
Nicolas De Loof
a6a39422e4 remove cli.args opentelemetry attribute
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-05 16:29:45 +01:00
Max Proske
40cd08f318 Update link in stats --help output
Signed-off-by: Max Proske <max@mproske.com>
2025-02-04 18:12:17 +01:00
Nicolas De Loof
5e2abb6c26 support additional_context reference to another service
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-02-03 17:23:35 +01:00
Nicolas De Loof
4db5fcd569 fix bake uses selected builder
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-31 17:05:11 +01:00
Nicolas De Loof
f14c15fa57 capture error message reported by bake and forward to compose
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-31 17:05:11 +01:00
Nicolas De Loof
8d68ef587f fix exporter to only load image for default platform
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-31 17:05:11 +01:00
Nicolas De Loof
cde9ae5952 pass --allow for filesystem read access
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-31 17:05:11 +01:00
Guillaume Lours
806ac91cf6 add warning when trying to publish env variables with OCI artifact
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-01-30 17:37:07 +01:00
Nicolas De Loof
1c073c0a04 watch should ony build selected services
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-30 13:47:21 +01:00
Guillaume Lours
840288895e add --with-env flag to publish command
this flag allow publishing env variables in the Compose OCI artifact

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-01-29 15:45:00 +01:00
Nicolas De Loof
4b70ff0ccd fix support for ssh key from CLI flags
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-29 11:28:41 +01:00
Nicolas De Loof
23351ece81 remove exit code per error type used by legacy metrics system
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-28 10:26:41 +01:00
Nicolas De Loof
7c7407672a bump docker to v27.5.1
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-23 15:31:01 +01:00
Nicolas De Loof
25cfa66a91 bump buildx v0.20.1 and docker v27.5.0
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-23 09:13:37 +01:00
CrazyMax
f160333e9e ci: use main branch for docs upstream validation workflow
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-01-22 19:27:02 +01:00
Nicolas De Loof
d04b3f48e4 e2e test covering multi-service rebuild with common resources
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-22 12:05:58 +01:00
Nicolas De Loof
ed10804e0f manage watch applied to mulitple services
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-22 12:05:58 +01:00
Rafael Buchbinder
52578c0998 Properly handle "builtin" seccomp profile
Like in CLI [1] the "builtin" seccomp profile should be handled the same
as "unconfined".

[1] f4a68da195/cli/command/container/opts.go (L929)

Signed-off-by: Rafael Buchbinder <rafi@rbk.io>
2025-01-20 15:06:09 +01:00
Guillaume Lours
bd2b49a1cf add codeowners file
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-01-20 14:09:53 +01:00
CrazyMax
433a60e122 ci: fix provenance for binaries and generate sbom
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-01-20 09:46:05 +01:00
Nicolas De Loof
489fe9cf02 add support for BUILDKIT_PROGRESS
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-16 12:06:09 +01:00
Guillaume Lours
ef1931c8de add missing tag for build during merge workflow
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-01-15 18:26:03 +01:00
Guillaume Lours
9be7a3c9a1 ci: re-use local source to build binary images
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-01-15 18:02:23 +01:00
CrazyMax
666996bee2 ci: use local source for binary builds
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-01-15 16:50:20 +01:00
CrazyMax
083f676214 ci: update bake-action to v6
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-01-13 12:41:14 +01:00
Nicolas De Loof
e81de103db simplification
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-10 12:21:13 +01:00
Nicolas De Loof
fa39503469 image can be set to a local ID, that isn't a valid docker ref
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-09 09:55:30 +01:00
Nicolas De Loof
a351585024 can't render progress concurrently with buildkit
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-08 16:12:54 +01:00
Nicolas De Loof
b6db1380ec exclude one-off container running convergence
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-08 10:57:46 +01:00
Florian Apolloner
2ebb475433 Only override service mac if set on the main network.
Signed-off-by: Florian Apolloner <florian@apolloner.eu>
2025-01-07 16:16:33 +01:00
Guillaume Lours
d474515d45 remove engine v25 from e2e test matrix
The 1st version available for Ubuntu 24.x is Docker Engine v26

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-01-07 14:59:47 +01:00
Nicolas De Loof
2b21c5df93 fix relative path in compose file
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-07 14:59:47 +01:00
Guillaume Lours
1f3c10eb4b bump compose-go to v2.4.7
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-01-07 14:59:47 +01:00
Guillaume Lours
68ad165a59 replace tibdex/github-app-token by official GitHub create-github-app-token
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-01-07 12:12:22 +01:00
Guillaume Lours
3060ed2795 bump golang.org/x/net to v0.33.0 to fix potential security issue
https://github.com/golang/go/issues/70906

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-01-07 12:11:44 +01:00
Nicolas De Loof
be09b2e8ce checkExpectedVolumes must ignore anonymous volumes
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-01-06 09:40:02 +01:00
Guillaume Tardif
571a1af013 When retrying to resolveOrCreateNetwork, retry with a valid network name
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
2025-01-06 08:28:05 +01:00
Nicolas De Loof
8f644eea73 only check bind mount conflict if sync action is involved
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-19 11:23:50 +01:00
Guillaume Lours
56e92e34b6 use the 3 latest major versions of the engine to run e2e step
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-12-18 16:29:41 +01:00
Guillaume Lours
a42a04dfe8 bump Golang version to v1.22.10 and update CI actions
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-12-18 16:09:48 +01:00
Guillaume Lours
34bcd03a76 add --pull to run command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-12-18 12:20:02 +01:00
Nicolas De Loof
ed61e42f93 CI to validate fmt
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-17 16:50:14 +01:00
Nicolas De Loof
65696bb1cb make fmt so any contributor can enforce formatting
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-17 16:50:14 +01:00
Sebastiaan van Stijn
446e00520c format code with gofumpt
Format the code  with gofumpt to prevent my IDE from reformatting
every time I open a file. gofumpt provides a superset of gofmt,
so should not impact users that are not using gofumpt.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-17 16:50:14 +01:00
Nicolas De Loof
c01c9c29f4 e2e test to prevent future regression
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-16 15:46:47 +01:00
Nicolas De Loof
038c81f34e only check volume mounts for updated config
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-16 10:26:24 +01:00
Nicolas De Loof
a20b69ac5b e2e test for recreate volume
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-13 09:52:22 +01:00
dependabot[bot]
977530c22a build(deps): bump google.golang.org/grpc from 1.68.0 to 1.68.1
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.68.0 to 1.68.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.68.0...v1.68.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-12 19:25:02 +01:00
dependabot[bot]
d4db8b6b12 build(deps): bump golang.org/x/crypto from 0.27.0 to 0.31.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.27.0 to 0.31.0.
- [Commits](https://github.com/golang/crypto/compare/v0.27.0...v0.31.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-12 19:12:27 +01:00
dependabot[bot]
f8ce0f04e6 build(deps): bump golang.org/x/sys from 0.27.0 to 0.28.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.27.0 to 0.28.0.
- [Commits](https://github.com/golang/sys/compare/v0.27.0...v0.28.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-12 19:11:45 +01:00
Nicolas De Loof
8e0520e71e prompt user to confirm volume recreation
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-12 19:11:00 +01:00
Joana Hrotko
332311358e Recreate container on volume configuration change
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-12 19:11:00 +01:00
Nicolas De Loof
df9e420ddd introduce watch restart action
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-12 09:56:23 +01:00
Guillaume Lours
142f5dba84 bump otel dependencies to v1.28.0 and v0.53.0 to align with buildx, buildkit and engine versions
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-12-11 15:57:53 +01:00
Nicolas De Loof
700c586bcf bump docker/buildx to latest release
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-11 15:33:58 +01:00
Nicolas De Loof
fc566509d5 fix support for service.mac_address
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-10 15:59:26 +01:00
Sebastiaan van Stijn
e73c2303fb update xx to v1.6.1 for compatibility with alpine 3.21 and file 5.46+
This fixes compatibility with alpine 3.21 and file 5.46+

- Fix additional possible `xx-cc`/`xx-cargo` compatibility issue with Alpine 3.21
- Support for Alpine 3.21
- Fix `xx-verify` with `file` 5.46+
- Fix possible error taking lock in `xx-apk` in latest Alpine without `coreutils`

full diff: https://github.com/tonistiigi/xx/compare/v1.2.1...v1.6.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-10 15:09:02 +01:00
dependabot[bot]
624303233a build(deps): bump golang.org/x/sync from 0.9.0 to 0.10.0
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.9.0 to 0.10.0.
- [Commits](https://github.com/golang/sync/compare/v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-09 12:05:24 +01:00
Nicolas De loof
a1729c52de Update pkg/e2e/watch_test.go
Co-authored-by: Guillaume Lours <705411+glours@users.noreply.github.com>
Signed-off-by: Nicolas De loof <nicolas.deloof@gmail.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-06 16:46:42 +01:00
Nicolas De Loof
254224c182 first watch action for a file event wins
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-06 16:46:42 +01:00
Nicolas De Loof
0861e68450 fix
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-06 16:46:42 +01:00
Nicolas De Loof
af5b748500 revisit TestDebounceBatching
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-06 16:46:42 +01:00
Nicolas De Loof
32a22c1f4f introduce sync+exec watch action
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-06 16:46:42 +01:00
Nicolas De Loof
e6ea8fb962 log configuration error as a watch log event
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-06 16:30:14 +01:00
Nicolas De Loof
043465448f do not require a build section but for rebuild action
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-06 16:12:05 +01:00
Nicolas De Loof
1d08390864 pull --quiet should not drop status message, only progress
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-06 12:24:29 +01:00
Nicolas De Loof
69a83d1303 use latest engine tags
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-05 14:53:24 +01:00
Nicolas De Loof
781b9f1cd5 Bump buildx to 0.19.1
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-05 14:53:24 +01:00
Guillaume Lours
cbff0e5559 be sure everything has been cleanup at the end of each tests
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-12-04 15:28:16 +01:00
Guillaume Lours
e4222bff53 add local config.json to test configuration dir if exists
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-12-04 15:28:16 +01:00
Nicolas De Loof
25197fe6dd disable failing TestBuildSSH test
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-04 15:14:56 +01:00
Nicolas De Loof
85cdaf9ddf fix build with bake
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-12-03 12:05:40 +01:00
Guillaume Lours
a8469db83f bump containerd to v1.7,24
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-11-27 15:23:27 +01:00
Guillaume Lours
08488dae59 bump google.golang.org/grpc to v1.68.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-11-27 15:23:27 +01:00
dependabot[bot]
cc3a216f2f build(deps): bump github.com/moby/buildkit from 0.17.1 to 0.17.2
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.17.1 to 0.17.2.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.17.1...v0.17.2)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-27 14:37:20 +01:00
dependabot[bot]
6e818b9ae0 build(deps): bump github.com/compose-spec/compose-go/v2
Bumps [github.com/compose-spec/compose-go/v2](https://github.com/compose-spec/compose-go) from 2.4.5-0.20241111154218-9d02caaf8465 to 2.4.5.
- [Release notes](https://github.com/compose-spec/compose-go/releases)
- [Commits](https://github.com/compose-spec/compose-go/commits/v2.4.5)

---
updated-dependencies:
- dependency-name: github.com/compose-spec/compose-go/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-27 14:21:24 +01:00
Nicolas De Loof
6b3e57503e only stop dependent containers ... if there's some
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-11-27 09:58:38 +01:00
Nicolas De Loof
8e497a1289 disable TestNetworkConfigChanged which is unstable on CI
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-11-27 09:51:07 +01:00
Nicolas De Loof
5aed704379 only check attached networks on running containers
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-11-27 09:51:07 +01:00
MohammadHasan Akbari
1ff9b758d2 fix: commit tests
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2024-11-27 07:39:46 +01:00
MohammadHasan Akbari
9eaba55973 feat: add commit command
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2024-11-27 07:39:46 +01:00
Nicolas De Loof
a85f8a40a9 run build tests against bake
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-11-26 15:20:50 +01:00
Nicolas De Loof
095f65cb42 delegate build to buildx bake
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-11-26 08:51:34 +01:00
dependabot[bot]
208e57ded8 build(deps): bump github.com/stretchr/testify from 1.9.0 to 1.10.0
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.9.0 to 1.10.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.9.0...v1.10.0)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-26 08:44:16 +01:00
Nicolas De Loof
2d148faedf use service.stop to stop dependent containers
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-11-25 11:56:22 +01:00
Trevor Foster
43ac1e31c6 Update wait-timeout flag usage to include the unit
Signed-off-by: Trevor Foster <trevorfoster19@gmail.com>
2024-11-25 11:22:18 +01:00
Sebastiaan van Stijn
5561a778c9 go.mod: github.com/docker/cli v27.4.0-rc.2
full diff: https://github.com/docker/cli/compare/8d1bacae3e49...v27.4.0-rc.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-20 09:55:29 +01:00
Sebastiaan van Stijn
ae48f488d1 go.mod: github.com/docker/docker v27.4.0-rc.2
full diff: https://github.com/docker/docker/compare/v27.4.0-rc.1...v27.4.0-rc.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-20 09:55:29 +01:00
Sebastiaan van Stijn
5e3a095380 go.mod: github.com/docker/cli 8d1bacae3e49 (v27.4.0-rc.2-dev)
full diff: https://github.com/docker/cli/compare/v27.4.0-rc.1...8d1bacae3e49ed1d096eede8eef4ae851d7f2eae

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-15 16:30:26 +01:00
Sebastiaan van Stijn
a2a3eb72e2 go.mod: github.com/docker/cli v27.4.0-rc.1
- full diff: https://github.com/docker/cli/compare/cb3048fbebb1...v27.4.0-rc.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-15 16:30:26 +01:00
Sebastiaan van Stijn
3513b42423 go.mod: github.com/docker/docker v27.4.0-rc.1
- full diff: https://github.com/docker/docker/compare/v27.3.1...v27.4.0-rc.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-15 16:30:26 +01:00
Nicolas De loof
d4fa63fdcb Update pkg/compose/convergence.go
Co-authored-by: Guillaume Lours <705411+glours@users.noreply.github.com>
Signed-off-by: Nicolas De loof <nicolas.deloof@gmail.com>
2024-11-15 15:35:49 +01:00
Nicolas De Loof
c21d4cfb40 detect network config changes and recreate if needed
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-11-15 15:35:49 +01:00
Sebastiaan van Stijn
61f1d4f69b go.mod: github.com/docker/buildx v0.18.0
full diff: https://github.com/docker/buildx/compare/v0.17.1..v0.18.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-15 11:57:00 +01:00
Sebastiaan van Stijn
f7cce281de go.mod: github.com/moby/buildkit v0.17.1
full diff: https://github.com/moby/buildkit/compare/v0.16.0..v0.17.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-15 11:57:00 +01:00
Sebastiaan van Stijn
bcaacc7f23 gha: test against docker engine v27.4.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-15 11:48:29 +01:00
Guillaume Lours
3f5898f8d0 push empty descriptor layer when using OCI version 1.1 for Compose artifact
it fixes a repository creation issue when pushing the 1st time a Compose OCI artifact on the Hub

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-11-13 13:36:31 +01:00
Guillaume Lours
2bb67f2700 remove ddev e2e tests
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-11-13 12:52:48 +01:00
Nicolas De Loof
bf521fe3ab implement remove-orphans on run
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-11-12 14:28:26 +01:00
Matthieu MOREL
11e9621da5 ci: enable testifylint linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-11-12 11:12:32 +01:00
Felix Fontein
a9de9abcfb Emit events for building images
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-11-12 10:59:41 +01:00
koooge
799ab842a0 Fix compose images that reutn a different image with the same ID
Signed-off-by: koooge <koooooge@gmail.com>
2024-11-12 09:51:33 +01:00
Nicolas De Loof
2f65ace2aa remove obsolete containers first on scale down
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-11-12 09:47:36 +01:00
Guillaume Lours
aa0a4189ee pass stal bot inactivity limit from 6 to 3 months
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-11-12 09:37:21 +01:00
Suleiman Dibirov
eba3ff8f37 fix(config): Print service names with --no-interpolate
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-11-11 16:42:55 +01:00
dependabot[bot]
6313365ba4 build(deps): bump golang.org/x/sys from 0.26.0 to 0.27.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.26.0 to 0.27.0.
- [Commits](https://github.com/golang/sys/compare/v0.26.0...v0.27.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-08 11:20:24 +01:00
dependabot[bot]
dbd51745c4 build(deps): bump golang.org/x/sync from 0.8.0 to 0.9.0
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.8.0 to 0.9.0.
- [Commits](https://github.com/golang/sync/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-08 10:49:59 +01:00
Guillaume Lours
a8bfbc147a bump compose-go v2.4.4
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-11-07 14:19:53 +01:00
Joana Hrotko
fbbd6f83d7 Avoid starting all services on rebuild
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-11-05 14:51:12 +00:00
Guillaume Lours
a000978980 remove ArtifactType from Config in OCI v1.1 definition of the artifact
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-11-05 15:10:56 +01:00
dependabot[bot]
361c0893a9 build(deps): bump github.com/compose-spec/compose-go/v2
Bumps [github.com/compose-spec/compose-go/v2](https://github.com/compose-spec/compose-go) from 2.4.2 to 2.4.3.
- [Release notes](https://github.com/compose-spec/compose-go/releases)
- [Commits](https://github.com/compose-spec/compose-go/compare/v2.4.2...v2.4.3)

---
updated-dependencies:
- dependency-name: github.com/compose-spec/compose-go/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-05 10:50:25 +01:00
Nicolas De Loof
513b6128c2 Service being declared in a profile must not trigger re-creation
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-11-05 10:49:08 +01:00
Joana Hrotko
eececb9add Add profile e2e test case to document in compose
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-10-30 16:00:41 +01:00
Laura Brehm
501b5acde6 Update MAINTAINERS file
Add `jhrotko` to Core Maintainers.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-10-30 13:33:46 +01:00
Guillaume Lours
f51bc4cd00 bump compose-go to version v2.4.2
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-10-30 11:30:53 +01:00
Guillaume Lours
517f87a372 bump google.golang.org/grpc to v1.67.1
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-10-29 12:07:34 +01:00
Guillaume Lours
718049cbd7 bump go.uber.org/mock to v0.5.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-10-29 12:07:34 +01:00
Guillaume Lours
02371f3127 bump golang minimal version to 1.22 in go.mod
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-10-29 11:45:02 +01:00
dependabot[bot]
a7c9de82b2 build(deps): bump github.com/containerd/containerd from 1.7.22 to 1.7.23
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.22 to 1.7.23.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.22...v1.7.23)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-29 09:47:38 +01:00
Guillaume Lours
51ebeb5441 introduce generate command as alpha command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-10-28 17:00:59 +01:00
Guillaume Lours
fafaa9c5b8 bump compose-go to version v2.4.1
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-10-28 14:24:07 +01:00
Suleiman Dibirov
fc9c3cde06 Add license header to dockerignore_test.go
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-10-28 12:26:45 +01:00
Suleiman Dibirov
73bfbab54b fix
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-10-28 12:26:45 +01:00
Suleiman Dibirov
2ac081b4c4 fix(dockerignore): Add wildcard support to dockerignore.go
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-10-28 12:26:45 +01:00
Chris Crone
eeea049f17 push: Fix error message typo
Signed-off-by: Chris Crone <christopher.crone@docker.com>
2024-10-28 10:08:44 +01:00
Guillaume Lours
26064d4b60 allow usage of -f flag with oci Compose artifact
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-10-25 17:36:04 +02:00
Nicolas De Loof
7c46beb8af resurrect --all flag for cp to target oneoff container
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-25 16:59:19 +02:00
Nicolas De Loof
aa1ec4524c connect to external networks by name
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-25 16:42:28 +02:00
Nicolas De Loof
a4ee6ca7a5 don't warn about uid/gid not being supported while ... they are
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-25 12:48:00 +02:00
Guillaume Lours
5617eff0c2 bump compose-go to v2.4.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-10-24 14:37:42 +02:00
Nicolas De Loof
fa24ab8e25 one-off container are not indexed, and must be ignored by exec --index command
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-22 15:29:12 +02:00
Nicolas De Loof
0aad9595a5 don't use progress to render restart, which hides logs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-22 15:28:55 +02:00
Nicolas De Loof
813900180e compose-go clean volume target to avoid ambiguous comparisons
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-22 11:40:35 +02:00
Nicolas De Loof
82417bd5bc add support for bind.recursive
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-16 22:19:58 +02:00
divinity76
0cbb73c024 Improve error message to include expected network label
Updated the error message when a network is found with an incorrect label to also display the expected label value. This provides more context for debugging.

Signed-off-by: divinity76 <hans@loltek.net>
2024-10-15 15:33:16 +02:00
David Scott
38e3d670a9 desktop: allow this client to be identified via user-agent
Previously the HTTP requests were sent with a generic Go-http-client
user-agent which made it hard to determine where the requests are
coming from. It's important that we can find clients so that they
can be updated if APIs change in future.

Signed-off-by: David Scott <dave@recoil.org>
2024-10-15 13:59:49 +02:00
Guillaume Lours
24c78728e0 bump compose-go to v2.3.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-10-10 11:18:25 +02:00
Nicolas De Loof
9eeb2d3154 convert gpus to DeviceRequests with implicit "gpu" capability
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-09 15:18:49 +02:00
Sebastiaan van Stijn
8da82c98ef gha: set default permissions to "contents: read"
make the OpenSSF scorecard slightly happier;
https://securityscorecards.dev/viewer/?uri=github.com/docker/compose

    Warn: jobLevel 'contents' permission set to 'write': .github/workflows/ci.yml:256: update your workflow using https://app.stepsecurity.io/secureworkflow/docker/compose/ci.yml/main?enable=permissions
    Warn: no topLevel permission defined: .github/workflows/docs-upstream.yml:1: update your workflow using https://app.stepsecurity.io/secureworkflow/docker/compose/docs-upstream.yml/main?enable=permissions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-09 15:02:57 +02:00
Sebastiaan van Stijn
1a8c855489 Add security policy
Add a security policy to inform users where to report security issues,
and to make the OpenSSF scorecard slightly happier;
https://securityscorecards.dev/viewer/?uri=github.com/docker/compose

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-09 11:05:29 +02:00
Nicolas De Loof
15bd0b0c5f add support for raw env_file format
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-08 18:33:54 +02:00
dependabot[bot]
39d0f6477e build(deps): bump golang.org/x/sys from 0.25.0 to 0.26.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.25.0 to 0.26.0.
- [Commits](https://github.com/golang/sys/compare/v0.25.0...v0.26.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-08 10:42:02 +01:00
Nicolas De Loof
3a95a0872d add support for CDI device request using devices
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-08 11:27:22 +02:00
Nicolas De Loof
f794c79eb3 Support Dockerfile-specific ignore-file with watch
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-08 11:19:02 +02:00
Joana Hrotko
407d825705 Remove feature flag integration with Docker Desktop for ComposeUI and ComposeNav
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-10-07 20:08:12 +02:00
Nicolas De Loof
82b41b9ebd introduce service hooks
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-07 16:06:41 +02:00
Nicolas De Loof
6c06170eb0 pass device.options to engine
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-04 14:55:53 +02:00
MohammadHasan Akbari
60c1311f67 chore: remove errors depricated pkg
Signed-off-by: MohammadHasan Akbari <116190942+jarqvi@users.noreply.github.com>
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2024-10-02 21:15:59 +02:00
MohammadHasan Akbari
17add87e4e fix: validate-go-mod
Signed-off-by: MohammadHasan Akbari <116190942+jarqvi@users.noreply.github.com>
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2024-10-02 21:15:59 +02:00
MohammadHasan Akbari
bf0418bac1 fix: lint
Signed-off-by: MohammadHasan Akbari <116190942+jarqvi@users.noreply.github.com>
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2024-10-02 21:15:59 +02:00
MohammadHasan Akbari
b9d0c77cde feat: add export command
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2024-10-02 21:15:59 +02:00
Ananta Dwi Prasetya Purna Yuda
bdb8545611 fix(convergence): Serialize access to observed state
Signed-off-by: Ananta Dwi Prasetya Purna Yuda <hi@anantadwi13.com>
2024-10-02 15:04:38 +02:00
Joana Hrotko
41df35c1f4 Remove bind options when creating a volume type
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-10-02 10:00:28 +02:00
Nicolas De Loof
3ef5045a08 Bump docker v27.3.1
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-02 08:32:14 +02:00
Suleiman Dibirov
d9df7aab6e fix(push): Fix unexpected EOF on alpha publish
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-09-30 10:38:18 +02:00
Guillaume Lours
c9d96b449b use compose-go version fixing extra_hosts unicity issue
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-09-26 17:08:18 +01:00
Joana Hrotko
1744b45765 Show watch error message and open DD only when w is pressed
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-09-26 10:19:34 +01:00
Suleiman Dibirov
87f457e7dc add tests to down.go
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-09-26 10:36:37 +02:00
Suleiman Dibirov
abcc91e2b9 fix(down): Fix down command if specified services are not running
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-09-26 10:36:37 +02:00
Joana Hrotko
8b9fe89842 After container restart register printer consumer
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-09-24 14:01:51 +02:00
Nicolas De Loof
34b18194f7 check secret source exists, as bind mount would create target as a folder otherwise
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-09-23 19:36:41 +02:00
Nicolas De Loof
ce27dba52e wait for dependent service up to delay set by --wait-timeout
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-09-23 18:25:02 +01:00
Nicolas De Loof
d2b9456137 append unix-style relative path when computing container target path
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-09-20 17:00:23 +02:00
Guillaume Lours
9c60fe67df revert commits link to mount API over bind changes
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-09-20 10:37:57 +02:00
Nicolas De Loof
c16df17e1f don't set propagation if target engine isn't linux
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-09-18 17:54:19 +02:00
Sebastiaan van Stijn
20404db12b build(deps): bump github.com/docker/docker v27.3.0-rc.2
full diff: https://github.com/docker/docker/compare/v27.3.0-rc.1...v27.3.0-rc.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-18 15:32:40 +02:00
Sebastiaan van Stijn
f2ff7fd75e build(deps): bump github.com/docker/cli v27.3.0-rc.2
full diff: https://github.com/docker/cli/compare/v27.3.0-rc.1...v27.3.0-rc.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-18 15:32:40 +02:00
Nicolas De Loof
cb00aaad28 set propagation default
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-09-17 10:50:16 +02:00
temenuzhka-thede
e885bc084d Remove custom codeql workflow
Signed-off-by: temenuzhka-thede <temenuzhka.thede@docker.com>
2024-09-17 07:59:52 +02:00
Suleiman Dibirov
73d3a25ebd fix import
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-09-16 11:21:43 +02:00
Suleiman Dibirov
3524bcfad0 chore(watch): Add debug log when skipping service without build context
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-09-16 11:21:43 +02:00
Nicolas De Loof
1076f1d9a5 stop dependent containers before recreating diverged service
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-09-16 10:14:54 +02:00
Alexandr Hacicheant
16652ed26a Fixed possible nil pointer dereference
Signed-off-by: Alexandr Hacicheant <a.hacicheant@gmail.com>
2024-09-13 22:10:35 +02:00
Sebastiaan van Stijn
c6a76b9bd7 bump github.com/docker/buildx v0.17.1
full diff: https://github.com/docker/buildx/compare/v0.17.0...v0.17.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-13 22:07:53 +02:00
Sebastiaan van Stijn
3a0e3ba7ee build(deps): bump docker, docker/cli to v27.3.0-rc.1
full diff:

- engine: https://github.com/docker/docker/compare/v27.2.1...v27.3.0-rc.1
- cli: https://github.com/docker/cli/compare/v27.2.1...v27.3.0-rc.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-13 22:07:53 +02:00
Sebastiaan van Stijn
86ef8e62c3 gha: test against docker engine v27.3.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-13 22:00:22 +02:00
Suleiman Dibirov
8bf0627ea9 show sync files only in debug level
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-09-12 14:38:02 +02:00
Suleiman Dibirov
2e14191682 chore(watch): Add changed files path/count to log
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-09-12 14:38:02 +02:00
dependabot[bot]
155f64182a build(deps): bump golang.org/x/sync from 0.7.0 to 0.8.0
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.7.0 to 0.8.0.
- [Commits](https://github.com/golang/sync/compare/v0.7.0...v0.8.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-12 10:54:56 +02:00
Guillaume Lours
8db0cba0af bump compose-go to version v2.2.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-09-12 09:36:18 +02:00
Nicolas De Loof
a7424435b3 Restore compose v1 behavior to recreate containers when ran with -V
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-09-11 15:16:28 +02:00
Sebastiaan van Stijn
d445ebba3f fix linting issues with golangci-lint 1.60.2
pkg/watch/watcher_darwin.go:96:16: Error return value of `d.stream.Start` is not checked (errcheck)
        d.stream.Start()
                      ^
    pkg/prompt/prompt.go:97:12: Error return value of `fmt.Fprint` is not checked (errcheck)
        fmt.Fprint(u.stdout, message)
                  ^
    pkg/prompt/prompt.go:99:12: Error return value of `fmt.Scanln` is not checked (errcheck)
        fmt.Scanln(&answer)
                  ^
    cmd/formatter/logs.go:118:15: Error return value of `fmt.Fprintf` is not checked (errcheck)
                fmt.Fprintf(w, "%s%s%s\n", p.prefix, timestamp, line)
                           ^
    cmd/formatter/logs.go:120:15: Error return value of `fmt.Fprintf` is not checked (errcheck)
                fmt.Fprintf(w, "%s%s\n", p.prefix, line)
                           ^
    pkg/progress/json.go:67:15: Error return value of `fmt.Fprintln` is not checked (errcheck)
            fmt.Fprintln(p.out, string(marshal))
                        ^
    pkg/progress/json.go:87:15: Error return value of `fmt.Fprintln` is not checked (errcheck)
            fmt.Fprintln(p.out, string(marshal))
                        ^
    pkg/progress/plain.go:47:14: Error return value of `fmt.Fprintln` is not checked (errcheck)
        fmt.Fprintln(p.out, prefix, e.ID, e.Text, e.StatusText)
                    ^
    pkg/progress/tty.go:162:12: Error return value of `fmt.Fprint` is not checked (errcheck)
        fmt.Fprint(w.out, b.Column(0).ANSI)
                  ^
    pkg/progress/tty.go:165:12: Error return value of `fmt.Fprint` is not checked (errcheck)
        fmt.Fprint(w.out, aec.Hide)
                  ^
    pkg/compose/attach.go:53:13: Error return value of `fmt.Fprintf` is not checked (errcheck)
        fmt.Fprintf(s.stdout(), "Attaching to %s\n", strings.Join(names, ", "))
                   ^
    pkg/compose/compose.go:194:6: emptyStringTest: replace `len(dependencies) > 0` with `dependencies != ""` (gocritic)
            if len(dependencies) > 0 {
               ^
    pkg/compose/convergence.go:461:2: builtinShadow: shadowing of predeclared identifier: max (gocritic)
        max := 0
        ^
    pkg/compose/run.go:127:5: emptyStringTest: replace `len(opts.User) > 0` with `opts.User != ""` (gocritic)
        if len(opts.User) > 0 {
           ^
    pkg/compose/run.go:139:5: emptyStringTest: replace `len(opts.WorkingDir) > 0` with `opts.WorkingDir != ""` (gocritic)
        if len(opts.WorkingDir) > 0 {
           ^
    pkg/compose/viz.go:91:8: emptyStringTest: replace `len(portConfig.HostIP) > 0` with `portConfig.HostIP != ""` (gocritic)
                    if len(portConfig.HostIP) > 0 {
                       ^
    cmd/compatibility/convert.go:66:6: emptyStringTest: replace `len(arg) > 0` with `arg != ""` (gocritic)
            if len(arg) > 0 && arg[0] != '-' {
               ^
    pkg/e2e/watch_test.go:208:25: printf: non-constant format string in call to gotest.tools/v3/poll.Continue (govet)
                return poll.Continue(res.Combined())
                                     ^
    pkg/e2e/watch_test.go:290:25: printf: non-constant format string in call to gotest.tools/v3/poll.Continue (govet)
                return poll.Continue(r.Combined())
                                     ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-11 13:56:25 +02:00
Guillaume Lours
f592aad10d bump golang to version 1.22.7
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-09-11 13:56:25 +02:00
Guillaume Lours
ef46445ed3 bump dependencies versions, engine and cli v27.2.1
containerd v1.7.22
buildx v0.17.0
buildkit v0.16.0

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-09-11 13:56:25 +02:00
dependabot[bot]
150593298e build(deps): bump golang.org/x/sys from 0.22.0 to 0.25.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.22.0 to 0.25.0.
- [Commits](https://github.com/golang/sys/compare/v0.22.0...v0.25.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-11 11:35:23 +02:00
Nathan Baulch
524a97e553 Fix typos
Signed-off-by: Nathan Baulch <nathan.baulch@gmail.com>
2024-09-11 11:21:24 +02:00
Felix Fontein
1d608e0338 Use logrus instead of direct output to stderr.
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-09-11 09:38:05 +02:00
Laura Brehm
329ad73922 attach: close streams when done
When Compose is watching a project/reattaching streams on container
start, it will make new API `ContainerAttach()` calls every time a
container it's watching is started. However, it only closes the stream
when the context used to start the attach is canceled.

This means that if a user has a project with multiple containers where
containers keep restarting, Compose will attach to the new containers
but never close the previous streams, causing fds to pile up and
goroutines on the engine to get stuck.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-09-10 14:55:48 +02:00
jonathan-dev
b633c5c3e1 Fix typo in pull.go
Signed-off-by: jonathan-dev <jonathan.drude@gmail.com>
2024-09-10 09:03:12 +02:00
Remco Kranenburg
e6ef8629a8 Allow combination of bind mounts and 'rebuild' watches
Signed-off-by: Remco Kranenburg <remco.kranenburg@crunchr.com>
2024-09-04 07:41:37 +02:00
Nicolas De Loof
d658fecc63 service hash must exlude depends_on
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-08-26 16:05:15 +01:00
Nicolas De Loof
f9c7a0cc08 prefer mount API over bind
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-08-26 16:05:04 +01:00
David Karlsson
6e172d6b89 docs: duplicate documentation for root cmd
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2024-08-22 15:12:30 +02:00
Suleiman Dibirov
98e261ba32 docs(wait): Fix wait command description
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-08-19 10:44:57 +02:00
Guillaume Lours
11c7a25ae9 allow to add empty line in the logs when nav menu activated
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-08-16 17:14:41 +02:00
Joana Hrotko
234036756b upgrade docker versions
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-08-14 13:57:41 +02:00
Joana Hrotko
9c03797f9d initial sync files that modified after image creation
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-08-09 12:11:16 +02:00
Joana Hrotko
485c0eba53 initial sync for root directory
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-08-09 12:11:16 +02:00
Mayank Kapur
69384a9a0f Removes redundant condition from toAPIBuildOptions in build.go
Signed-off-by: Mayank Kapur <kapurm17@gmail.com>
2024-08-05 08:08:41 +02:00
Jan Brasna
1601ead7bc docs: Update docker compose kill usage
Signed-off-by: Jan Brasna <1784648+janbrasna@users.noreply.github.com>
2024-08-05 07:41:53 +02:00
Joana Hrotko
ea4ccf639d Fix stop on file chane for sync-restart action
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-07-25 16:28:47 +02:00
Guillaume Lours
b1850ea4d4 bump engine and cli to v27.1.1, buildx to v0.16.1
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-07-25 16:24:08 +02:00
Guillaume Lours
adba639e88 remove all dependabot update PRs for OTel dependencies
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-07-25 16:23:54 +02:00
Sebastiaan van Stijn
d8518529c4 gp.mod: github.com/gofrs/flock v0.12.1
- fix: missing read-write flag in reopenFDOnError
  fixes a regression that could result in a `ERROR: bad file descriptor`.

b659e1e00a
introduced a regression where `f.flag` would not be in read-write mode
[1]  but read-only [2] which breaks people using NFS protocol.

[1]: b659e1e00a (diff-87c2c4fe0fb43f4b38b4bee45c1b54cfb694c61e311f93b369caa44f6c1323ffR192)
[2]: b659e1e00a (diff-22145325dded38eb5288ed3321a113d8260ccc70747ee04d4551bfd2fba975fdR69)

full diff: https://github.com/gofrs/flock/compare/v0.12.0...v0.12.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-25 10:59:33 +02:00
Sebastiaan van Stijn
c79f15da9e go.mod: golang.org/x/sys v0.22.0
full diff: https://github.com/golang/sys/compare/v0.21.0...v0.22.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-25 10:59:33 +02:00
Sebastiaan van Stijn
3f55382ff0 update to go1.21.12
go1.21.12 (released 2024-07-02) includes security fixes to the net/http package,
as well as bug fixes to the compiler, the go command, the runtime, and the
crypto/x509, net/http, net/netip, and os packages. See the Go 1.21.12 milestone
on our issue tracker for details:

- https://github.com/golang/go/issues?q=milestone%3AGo1.21.12+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.21.11...go1.21.12

From the security mailing:

> Hello gophers,
>
> We have just released Go versions 1.22.5 and 1.21.12, minor point releases.
>
> These minor releases include 1 security fixes following the security policy:
>
> * net/http: denial of service due to improper 100-continue handling
>
>   The net/http HTTP/1.1 client mishandled the case where a server responds
>   to a request with an “Expect: 100-continue” header with a non-informational
>   (200 or higher) status. This mishandling could leave a client connection
>   in an invalid state, where the next request sent on the connection will fail.
>
> An attacker sending a request to a net/http/httputil.ReverseProxy proxy can
> exploit this mishandling to cause a denial of service by sending
> “Expect: 100-continue” requests which elicit a non-informational response
> from the backend. Each such request leaves the proxy with an invalid connection,
> and causes one subsequent request using that connection to fail.
>
> Thanks to Geoff Franks for reporting this issue.
>
> This is CVE-2024-24791 and Go issue https://go.dev/issue/67555.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-25 10:43:39 +02:00
Cody Rigney
44337d2bbf Enhance JSON progress events with more fields.
Signed-off-by: Cody Rigney <cody.rigney@docker.com>
2024-07-23 16:20:27 +02:00
Nicolas De Loof
bc733508d6 bump compose-go v2.1.5
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-07-23 16:01:16 +02:00
Sebastiaan van Stijn
c422b5447c bump github.com/docker/cli v27.1.0
full diffs:

- https://github.com/docker/cli/compare/v27.0.3...v27.1.0
- https://github.com/grpc/grpc-go/compare/v1.59.0...v1.60.1
- https://github.com/open-telemetry/opentelemetry-go/compare/exporters/otlp/otlpmetric/otlpmetricgrpc/v0.42.0...exporters/otlp/otlpmetric/otlpmetricgrpc/v0.44.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-23 15:33:58 +02:00
Sebastiaan van Stijn
e74441c907 bump github.com/docker/docker v27.1.0
full diff: https://github.com/docker/docker/compare/v27.0.3...v27.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-23 15:33:58 +02:00
Sebastiaan van Stijn
2bac32a46e bump github.com/containerd/containerd v1.7.20
full diffs:

= containerd: https://github.com/containerd/containerd/compare/v1.7.19...v1.7.20
- google.golang.org/genproto/googleapis/rpc 49dd2c1f3d...995d672761
- google.golang.org/genproto: 49dd2c1f3d...989df2bf70
- google.golang.org/genproto/googleapis/api: 49dd2c1f3d...83a465c022

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-23 15:33:58 +02:00
Sebastiaan van Stijn
f278400fbc gha: add docker 27.1.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-23 15:21:34 +02:00
Suleiman Dibirov
4f9db4d3e6 fix(containers): fix sorting logic by adding secondary sorting for one-off containers
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-07-22 09:32:59 +02:00
guoguangwu
06bf339a42 fix: typos
Signed-off-by: guoguangwu <guoguangwug@gmail.com>
2024-07-17 13:48:13 +01:00
Guillaume Lours
231ea10058 update docs generation to avoid man pages generation
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-07-17 13:01:51 +02:00
Guillaume Lours
46679150d6 bump compose-go to v2.1.4, buildx to v0.16.0, containerd to v1.7.19 and buildx to v0.15.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-07-17 13:01:51 +02:00
Nicolas De Loof
d3d378b92a restore setEnvWithDotEnv
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-07-11 10:25:04 +02:00
Nicolas De Loof
163cdfd31d empty env variable with no value must be unset in container
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-07-10 14:23:34 +02:00
Nicolas De Loof
25f85938bb exclude unnecessary resources after services have been selected
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-07-09 15:12:27 +02:00
Joana Hrotko
cacbca859d change time for stale bot
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-07-09 12:06:54 +02:00
Joana Hrotko
ecac13f272 Remove debug mode and run twice a week
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-07-08 15:26:37 +02:00
Joana Hrotko
14793cc2e4 Add stale workflow
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-07-08 15:26:37 +02:00
Suleiman Dibirov
11d5ecdc75 update docs
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-07-02 08:16:09 +02:00
Suleiman Dibirov
9549a213ba feat(watch): Add --prune option to docker-compose watch command
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
2024-07-02 08:16:09 +02:00
Joana Hrotko
da434013e3 Remove COMPOSE_MENU env from e2e tests
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-07-01 16:31:12 +01:00
Felix Fontein
ace69c96a7 Use rawjson for the build backend.
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-07-01 15:32:51 +02:00
Felix Fontein
2db04c1e40 Set logging format to JSON.
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-07-01 15:32:51 +02:00
Felix Fontein
8f7cd00481 Format errors as JSON when in JSON progress mode.
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-07-01 15:32:51 +02:00
Felix Fontein
5a6e1a7e2e Pass 'plain' instead of 'json' to build backend
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-07-01 15:32:51 +02:00
Felix Fontein
06545d0668 Add JSON stream progress writer
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-07-01 15:32:51 +02:00
Sebastiaan van Stijn
075fd93452 go.mod: docker/cli, docker/docker v27.0.3
full diffs:

- https://github.com/docker/cli/compare/v27.0.2...v27.0.3
- https://github.com/docker/docker/compare/v27.0.2...v27.0.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 14:48:16 +02:00
Sebastiaan van Stijn
d062ad739a gha: test against docker v27.0.3
Switch to the test-channel, using the test.docker.com
script, which has both stable and pre-releases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 14:21:38 +02:00
Sebastiaan van Stijn
7cd5209cc2 go.mod: docker/cli, docker/docker v27.0.2
full diffs:

- https://github.com/docker/cli/compare/v27.0.1-rc.1...v27.0.2
- https://github.com/docker/docker/compare/v27.0.1-rc.1...v27.0.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 21:16:05 +02:00
Paweł Gronowski
f79c28168b Remove console.Terminal check and use IsTerminal from streams.Out
docker/cli v27 changed the return value of `Err()` to `streams.Out`
which made the typecheck for `console.File` fail.

The check is no longer needed due to the `IsTerminal` method present in
`streams.Out` which also has a special handling for Windows console.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-24 14:58:19 +02:00
Albin Kerouanton
6a000dcff1 go.mod: github.com/compose-spec/compose-go v2.1.3
full diff:

- https://github.com/compose-spec/compose-go/compare/v2.1.2...v2.1.3

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-21 14:04:40 +02:00
Albin Kerouanton
2636dcf064 go.mod: docker/docker and docker/cli v27.0.1-rc.1
diffs:

- https://github.com/docker/cli/compare/v26.1.4..v27.0.1-rc.1
- https://github.com/docker/docker/compare/v26.1.4..v27.0.1-rc.1

Co-authored-by: Albin Kerouanton <albinker@gmail.com
Signed-off-by: Albin Kerouanton <albinker@gmail.com
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-21 14:04:40 +02:00
dependabot[bot]
77377f2df6 build(deps): bump github.com/spf13/cobra from 1.8.0 to 1.8.1
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.8.0...v1.8.1)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-21 10:35:57 +02:00
dependabot[bot]
af1bc285a0 build(deps): bump github.com/docker/buildx from 0.15.0 to 0.15.1
Bumps [github.com/docker/buildx](https://github.com/docker/buildx) from 0.15.0 to 0.15.1.
- [Release notes](https://github.com/docker/buildx/releases)
- [Commits](https://github.com/docker/buildx/compare/v0.15.0...v0.15.1)

---
updated-dependencies:
- dependency-name: github.com/docker/buildx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-20 18:33:37 +02:00
Guillaume Lours
e1fd7a6567 using as flag of the up command, watch was blocking process shutdown
This happened when sunsetting the application from docker compose down command

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-06-20 10:50:01 +02:00
Joana Hrotko
de478f84b0 Add open watch docs in up menu
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-06-18 16:31:01 +01:00
Guillaume Lours
24a281fa5d bump buildkit to v0.14.0 and buildx to v0.15.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-06-18 10:52:41 +02:00
Guillaume Lours
54a5e7d4aa stop watch process when associated up process is stopped
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-06-17 22:59:09 +02:00
dependabot[bot]
36ef5b3881 build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 26.1.3+incompatible to 26.1.4+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v26.1.3...v26.1.4)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-17 21:56:36 +02:00
dependabot[bot]
5694a2b0f8 build(deps): bump github.com/containerd/containerd from 1.7.17 to 1.7.18
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.17 to 1.7.18.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.17...v1.7.18)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-17 15:04:40 +02:00
dependabot[bot]
695d3419cf build(deps): bump golang.org/x/sys from 0.20.0 to 0.21.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.20.0 to 0.21.0.
- [Commits](https://github.com/golang/sys/compare/v0.20.0...v0.21.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-17 14:29:32 +02:00
dependabot[bot]
981bcbbe7a build(deps): bump github.com/hashicorp/go-version from 1.6.0 to 1.7.0
Bumps [github.com/hashicorp/go-version](https://github.com/hashicorp/go-version) from 1.6.0 to 1.7.0.
- [Release notes](https://github.com/hashicorp/go-version/releases)
- [Changelog](https://github.com/hashicorp/go-version/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/go-version/compare/v1.6.0...v1.7.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-version
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-17 12:56:46 +02:00
Sebastiaan van Stijn
5ec37d08a5 build: replace uses of archive.CanonicalTarNameForPath
This function is an alias for filepath.IsAbs and we are considering deprecating
and/or removing this function in the archive package, so removing its uses
helps transitioning if we decide to deprecate and/or remove it.

[docker/cli@fb0788f] also added a normalize step in TrimBuildFilesFromExcludes,
so that callers are not _required_ to first normalize the path, so the
normalizeation may be redunant, but keeping the normalization as this variable
is used further down the code.

[docker/cli@fb0788f]: fb0788f18f

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 12:00:24 +02:00
Guillaume Lours
1a14fcb1e6 update gh actions versions, update engine matrix, bump golang to 1.21.11
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-06-12 18:16:29 +02:00
Nicolas De Loof
084a5ca312 enforce keyboard.Close is always executed to restore terminal
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-06-11 07:20:37 +02:00
Nicolas De Loof
d633c33a19 config --environment
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-06-11 06:59:19 +02:00
Alex Bedo
cc09f39f29 Readd event
Signed-off-by: Alex Bedo <alex98hun@gmail.com>
2024-06-10 12:06:30 +02:00
Alex Bedo
918b508bd5 remove unreachable code
if statement is preceded by another that has the same condition and ends with a return

Signed-off-by: Alex Bedo <alex98hun@gmail.com>
2024-06-10 12:06:30 +02:00
Nicolas De Loof
10531f6302 Fix dot env file to define COMPOSE_* variables
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-06-08 14:55:36 +02:00
Guillaume Lours
bf1bd3fc60 return an error when --detach and --watch are used together in up command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-06-07 14:02:45 +02:00
Casey Korver
02f40eea67 Correct 'cancellation' typo in comment
Signed-off-by: Casey Korver <casey@korver.dev>
2024-06-05 09:22:59 +02:00
IDOMATH
250c3112b9 Fix: change append to use slice index in ps.go
Signed-off-by: Blane Tschida <btdothemath@gmail.com>
2024-05-30 16:16:01 +02:00
Nicolas De Loof
495a087fb5 COMPOSE_PROFILES can be set by .env file
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-30 07:40:01 +02:00
Nicolas De Loof
fd1f73a5e7 prevent concurrent map write relying on project immutability
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-29 11:29:18 +02:00
dependabot[bot]
bf1dd0c267 build(deps): bump github.com/containerd/containerd from 1.7.16 to 1.7.17
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.16 to 1.7.17.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.16...v1.7.17)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-24 10:58:53 +02:00
dependabot[bot]
1cf6dea444 build(deps): bump github.com/docker/buildx from 0.14.0 to 0.14.1
Bumps [github.com/docker/buildx](https://github.com/docker/buildx) from 0.14.0 to 0.14.1.
- [Release notes](https://github.com/docker/buildx/releases)
- [Commits](https://github.com/docker/buildx/compare/v0.14.0...v0.14.1)

---
updated-dependencies:
- dependency-name: github.com/docker/buildx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-24 10:46:52 +02:00
Nicolas De Loof
1adc4cb16f drop COMPOSE_EXPERIMENTAL_OTEL as docker/cli has opentelemetry in
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-24 10:27:23 +02:00
Guillaume Lours
2ed40e8042 add gui/composeview as part of available commands
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-05-23 19:19:59 +02:00
Nicolas De Loof
7ad73c2899 fix opentelemetry
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-23 15:58:24 +02:00
Guillaume Lours
2593256985 bump compose-go to version v2.1.1
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-05-22 12:39:20 +02:00
Rob Murray
048fd136d2 Set endpoint-specific DriverOpts
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-22 12:39:20 +02:00
Rob Murray
663866cbe5 Bump compose-go version to latest main
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-22 12:39:20 +02:00
Kirill A. Korinsky
fb25e88a03 Backport OpenBSD patches
Here a trivial patch whcih I've used inside OpenBSD port to build it

Signed-off-by: Kirill A. Korinsky <kirill@korins.ky>
2024-05-22 11:35:37 +02:00
Guillaume Lours
3635303372 add new navigation menu to open Compose app configuration in Docker Desktop
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-05-22 11:34:10 +02:00
dependabot[bot]
2cee028e99 build(deps): bump github.com/fsnotify/fsevents from 0.1.1 to 0.2.0
Bumps [github.com/fsnotify/fsevents](https://github.com/fsnotify/fsevents) from 0.1.1 to 0.2.0.
- [Release notes](https://github.com/fsnotify/fsevents/releases)
- [Commits](https://github.com/fsnotify/fsevents/compare/v0.1.1...v0.2.0)

---
updated-dependencies:
- dependency-name: github.com/fsnotify/fsevents
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-22 11:26:41 +02:00
dependabot[bot]
c78f84aeb5 build(deps): bump golang.org/x/sys from 0.19.0 to 0.20.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.19.0 to 0.20.0.
- [Commits](https://github.com/golang/sys/compare/v0.19.0...v0.20.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-22 11:15:08 +02:00
Nicolas De Loof
5c6924ec6f fix --resolve-image-digests
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-22 10:54:55 +02:00
Nicolas De Loof
9e8c8caa2b allow a local .env file to override compose.yaml sibling .env
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-21 16:01:29 +02:00
Guillaume Lours
da8189cf22 Bump docker engine and cli to version 26.1.3
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-05-17 13:18:14 +02:00
Guillaume Lours
eb5e018698
Merge pull request #11811 from ndeloof/bump_docker_v26.1.2
Bump docker to v26.1.2
2024-05-13 11:51:30 +02:00
Nicolas De Loof
e64b96d0fa
Bump docker to v26.1.2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-13 08:54:56 +02:00
Joana Hrotko
b81624185f Add documentation for --menu up option and COMPOSE_MENU environemnt variable
Co-authored-by: Milas Bowman <devnull@milas.dev>
Signed-off-by: Joana H <joana.hrotko@gmail.com>
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-05-07 15:37:32 +02:00
Nicolas De loof
591d9eb3a2
chore(deps): bump docker to v26.1.1 (#11794)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-06 09:16:01 -04:00
Joana H
9c0b922597
fix: overlapping logs and menu navigation (#11765) 2024-04-24 14:59:42 -04:00
Guillaume Lours
c26d2fa7cf
Merge pull request #11762 from docker/dependabot/go_modules/github.com/moby/buildkit-0.13.1
build(deps): bump github.com/moby/buildkit from 0.13.0-rc3.0.20240417151852-71f99c52a669 to 0.13.1
2024-04-24 19:27:31 +02:00
dependabot[bot]
cfb110653f build(deps): bump github.com/moby/buildkit
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.13.0-rc3.0.20240417151852-71f99c52a669 to 0.13.1.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/commits/v0.13.1)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-24 17:32:50 +02:00
Guillaume Lours
b53b8b24f1
Merge pull request #11739 from milas/fix-e2e-cascade-flaky
chore(e2e): fix flaky cascade failure test
2024-04-24 16:29:51 +02:00
Milas Bowman
36bf0c458b chore(e2e): fix flaky cascade failure test
This was racy with the sleep, so the Compose file has been
tweaked to make it pass reliably.

Now, there's 3 services:
 * `running` - sleeps forever
 * `exit` - exits _successfully_ immediately
   * depends on `running` started
 * `fail` - exits _with error_ immediately
   * depends on `exit` succeeding

Now, the test can ensure that the containers are all run/
started in the expected order the assertions will be reliable.

Before, it was possible for `fail` to run & exit before `exit`,
for example. The `running` service also ensures there's always
at least one other "running" container when we do an abort.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-04-24 11:03:27 +02:00
Guillaume Lours
299fcd57fd use v2.26.1 tag for moby and Docker cli
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-04-24 10:57:11 +02:00
Milas Bowman
b90cb48a1d chore(deps): update to Moby v26.1 & buildx v0.14
* `moby/buildkit` commit comes from `docker/buildx`
* v26.1-dev from `moby/moby` & `docker/cli`

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-04-24 10:57:11 +02:00
Guillaume Lours
f8808d81c5 bump compose-go version to v2.1.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-04-23 10:35:16 +02:00
Guillaume Lours
2c9c60e007
Merge pull request #11752 from ndeloof/flag_equal
fix support for `--flag=value` syntax in compatibility mode
2024-04-22 10:52:59 +02:00
Nicolas De Loof
9970a84ae6
fix support for --context=foo
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-22 10:42:34 +02:00
Jaime Soriano Pastor
5682480726
Fix #11710: Avoid to try to close channel twice after hitting Ctrl-C on compose up (#11719)
Ensure done channel is closed only once

Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
2024-04-20 06:09:26 +00:00
Milas Bowman
fd532a37e7
fix(desktop): remove overly-aggressive feature flag check (#11748) 2024-04-19 16:06:57 -04:00
racequite
2aa568ceba chore: fix typo in comment
Signed-off-by: racequite <quiterace@gmail.com>
2024-04-19 09:54:08 +02:00
Nicolas De Loof
4ae2e0ec55 bump dependencies
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-18 10:58:56 +02:00
Milas Bowman
922422a539 fix: do not try to create file shares for non-directories
When creating automatic file shares, ignore any non-directory
bind mounts, e.g. for an individual (normal) file or a special
type like a Unix socket (`/var/run/docker.sock`).

Additionally, there's no need to create a directory if one
does not exist, the API will handle that. However, the check
for existence remains so that `create_host_path: false`
mounts can be ignored.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-04-17 17:12:03 +02:00
Nicolas De Loof
d239f0f318 check container_name is not in use by another service we will create
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-16 17:26:50 +02:00
Nicolas De Loof
ca734ce565 don't clear line when navigation is disabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-16 16:04:23 +02:00
Nicolas De loof
c9e070f0f6
fix: return correct exit code with --exit-code-from (#11715) 2024-04-16 09:44:23 -04:00
Nicolas De Loof
b3792dd258 progress for resource can be restarted after more Working event comes
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-15 22:05:46 +02:00
Nicolas De Loof
d8ee474e09 Revert "Stop the resource timer after last expected event"
This reverts commit a4ddbcb6b2caf12826926d164d47319ac01fa6d4.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-15 22:05:46 +02:00
Jaime Soriano Pastor
7d3616474d Revert change to allow trying to kill again if a kill fails
Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
2024-04-14 17:44:39 +02:00
Jaime Soriano Pastor
6a3501f901 Handle errors and allow to send multiple kills if one failed
Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
2024-04-14 17:44:39 +02:00
Jaime Soriano Pastor
5daed33c6a Ignore errors when killing on second Ctrl-C
Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
2024-04-14 17:44:39 +02:00
Jaime Soriano Pastor
5c1e5f3fc7 docker compose up always kills the containers on second Ctrl-C
Kill executed on the second Ctrl-C of docker compose up  was
filtering containers depending on its state. In some cases the
containers can reach an state for what these filters don't get
any container, and the command keeps reporting `no container to
kill`.

Remove this filtering, so it tries to kill any container it
finds, independently of its state.

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

Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
2024-04-14 17:44:39 +02:00
Nicolas De Loof
b032999f06 read COMPOSE_REMOVE_ORPHANS from .env
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-11 16:24:15 +02:00
koooge
5059a1d7bf Set Required false to depends_on containers for compose -p stop/down
Signed-off-by: koooge <koooooge@gmail.com>
2024-04-11 10:48:09 +02:00
koooge
54a525bbe6 Ignore missing containers when compose stop -p
Signed-off-by: koooge <koooooge@gmail.com>
2024-04-11 10:48:09 +02:00
koooge
8ceaf49296 Ignore missing containers when compose down -p
Signed-off-by: koooge <koooooge@gmail.com>
2024-04-11 10:48:09 +02:00
Guillaume Lours
bfee07e1eb
Merge pull request #11708 from ndeloof/entitlements
Introduce support for build.entitlements
2024-04-10 14:16:30 +02:00
Nicolas De Loof
1d32592056
Introduce support for build.entitlements
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-10 12:27:49 +02:00
Delath
85567ae092 Remove dead url reference.
Signed-off-by: Delath <62723360+delath@users.noreply.github.com>
2024-04-09 17:50:24 +02:00
Nicolas De Loof
b4280fb561 e2e test for --all-resources
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-09 15:30:42 +02:00
Nicolas De Loof
865a64afea introduce --all-resources to _not_ exclude resources not used by services
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-09 15:30:42 +02:00
Nicolas De Loof
29692b5921 Introduce --abort-on-container-failure
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-08 15:40:54 +02:00
Guillaume Lours
2658c372a7 bump golang version to 1.21.9
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-04-04 13:36:48 +02:00
Nicolas De Loof
d71d8bce24 don't use ansi espace sequence when disabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-03 15:43:16 +02:00
Joana Hrotko
ff20b641c7 Does not start keyboard manager if there is no tty
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-03-28 17:57:26 +00:00
Joana Hrotko
339b331a86 Change menu information text to dim
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-03-28 12:18:00 +00:00
Guillaume Lours
6fe69b2575
Merge pull request #11664 from jhrotko/fix-no-build-watch
Handle --no-build and --watch args
2024-03-27 11:37:38 +01:00
Joana Hrotko
dd5614ec3b Handle --no-build and --watch args
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-03-26 18:22:26 +00:00
dependabot[bot]
4b7b6adc76 build(deps): bump github.com/opencontainers/image-spec
Bumps [github.com/opencontainers/image-spec](https://github.com/opencontainers/image-spec) from 1.1.0-rc6 to 1.1.0.
- [Release notes](https://github.com/opencontainers/image-spec/releases)
- [Changelog](https://github.com/opencontainers/image-spec/blob/main/RELEASES.md)
- [Commits](https://github.com/opencontainers/image-spec/compare/v1.1.0-rc6...v1.1.0)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/image-spec
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-26 15:24:39 +01:00
Felix Fontein
466374bdd0 Unwrap error message.
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-03-25 07:37:34 +01:00
Felix Fontein
2e85b3c265 Include error message in pull warning/errors
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-03-25 07:37:34 +01:00
Milas Bowman
3371227794 chore(desktop): revised feature detection for file shares
Unfortunately, the feature flag mechanism for experimental features
isn't adequate. To avoid some edge cases where Compose might try to
use Synchronized file shares with Desktop when the feature isn't
available, we need to query a new endpoint.

Before we move any of this out of experimental, we need to improve
the integration here with Desktop & Compose so that we get all the
necessary feature/experiment state up-front to reduce the quantity
of IPC calls needed up-front.

For now, there's some intentional redundancy to avoid making this
extra call if we can avoid it. The actual endpoint is very cheap/
fast, but every IPC call is a potential point of of failure, so
it's worth it.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-03-22 18:16:27 +01:00
Joana Hrotko
e9dc82011f Add Navigation Menu to compose up
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-03-22 17:48:25 +01:00
Nicolas De Loof
3950460703 Add support for volume Subpath option
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-22 14:33:56 +01:00
Nicolas De Loof
3b541b071c Bump docker v26.0.0
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-22 14:33:56 +01:00
Nicolas De Loof
25671ae622 introduce config --variables to list compose model variables
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-22 13:51:30 +01:00
Sebastian Correa
0191e69d5b Fix docs on default build image name
150fd4b8cfa39726e68c12fc0fd45ac4e0f20c5f changed the default separator from _ to -, but the docker compose build docs still mention _.

Signed-off-by: Sebastian Correa <43179146+sebastian-correa@users.noreply.github.com>
2024-03-22 13:42:13 +01:00
Nicolas De Loof
897d239fcb Bump compose-go to v2.0.2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-22 11:21:14 +01:00
Nicolas De Loof
c5a760ce43 add support for annotations
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-22 10:45:44 +01:00
Joana H
759d3bc9f9
Merge pull request #11647 from milas/revert-compose-go-201
chore(deps): revert "Bump compose-go to v2.0.1"
2024-03-21 18:00:34 +00:00
Milas Bowman
26f687a12b Revert "Bump compose-go to v2.0.1"
This reverts commit ad414613090d031583181d34cf93f15024d0524c.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-03-21 13:43:44 -04:00
Nicolas De Loof
ad41461309
Bump compose-go to v2.0.1
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-21 15:54:41 +01:00
Milas Bowman
db4ed89528
feat(desktop): synchronized file share integration (#11614) 2024-03-20 14:41:24 -04:00
Milas Bowman
1b5fa3b93f
feat(experiments): add experimental feature state (#11633)
Use environment variable for global opt-out and Docker Desktop (if
available) to determine specific experiment states.

In the future, we'll allow per-feature opt-in/opt-out via env vars
as well, but currently there is a single `COMPOSE_EXPERIMENTAL` env
var that can be used to opt-out of all experimental features
independently of Docker Desktop configuration.
2024-03-20 13:44:27 +00:00
Guillaume Lours
86cd52370a
Merge pull request #11630 from ndeloof/config_json
fix `compose config --format json`
2024-03-18 16:11:18 +01:00
Guillaume Lours
4f97edf355 reduce timeout of the Otel tracing command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-03-18 08:40:36 +01:00
Nicolas De Loof
bc5fc6ba7e
fix compose config --format json
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-18 08:09:54 +01:00
Nicolas De Loof
f937e42aaf Bump compose-go v2.0.0
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-15 13:02:46 +01:00
Andrew Onyshchuk
f46ca459d2 services shell completion bugfix
Signed-off-by: Andrew Onyshchuk <andryk.rv@gmail.com>
2024-03-15 10:47:30 +01:00
Nicolas De Loof
b2d4c1b865 fix TestBuildPlatformsWithCorrectBuildxConfig
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-15 10:38:03 +01:00
Nicolas De Loof
5a1ba0efcf only use ToModel when --no-interpolate is set
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-13 06:48:24 +01:00
Milas Bowman
17d4229e57
feat(desktop): add Docker Desktop detection and client skeleton (#11593) 2024-03-12 09:47:41 -04:00
Milas Bowman
4efb89709c
chore(deps): upgrade go to 1.21.8 (#11578) 2024-03-05 22:23:52 +01:00
Milas Bowman
f35449a603
ci(deps): bump moby/moby & docker/cli to v25.0.4 (#11566) 2024-03-05 20:39:18 +00:00
Joana Hrotko
34b11c4f4f Add test summary for test jobs in ci
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-03-01 13:32:04 +01:00
Guillaume Lours
a7acf5fa67
Merge pull request #11535 from ndeloof/simpler
make code simpler
2024-03-01 10:02:12 +01:00
Nicolas De Loof
c525373acb
make code simpler
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-01 09:55:03 +01:00
Nicolas De Loof
e99b8acea7 avoid duplicated "xx exited with code 0" message
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-29 13:57:17 +01:00
Nicolas De Loof
8ab8df86e0 introduce --watch
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-28 19:04:58 +01:00
Nicolas De Loof
de178267df move code into small functions for better readability
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-28 18:54:43 +01:00
Nicolas De Loof
1680f9a874 restore support for config --no-interpolate
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-28 18:54:43 +01:00
Joana Hrotko
5c4f33702e remove docker cli step in ci.yml
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-02-27 12:50:44 +01:00
Joana H
e2762b144e
Merge pull request #11542 from ndeloof/log_attach
get log to manage `attach`
2024-02-27 11:04:46 +00:00
Nicolas De Loof
58ec0e9fb6
get log to manage attach
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-22 18:27:05 +01:00
Guillaume Lours
a7224411b4
Merge pull request #11513 from glours/use-go-ps-pid-lock
Double check watch pid if detected as still running on Windows
2024-02-22 16:21:47 +01:00
Guillaume Lours
c5a88deeba
Merge pull request #11536 from glours/bump-compose-go-2.0.0-rc.8
bump compose-go to version v2.0.0-rc.8
2024-02-21 19:57:19 +01:00
Guillaume Lours
349d9f34d0 bump compose-go to version v2.0.0-rc.8
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-02-21 19:41:04 +01:00
Guillaume Lours
9d38ee1726
Merge pull request #11537 from glours/fix-flakyness-run-quiet-pull
use a dedicated compose file for --quiet-pull e2e test
2024-02-21 19:40:01 +01:00
Guillaume Lours
697a48af32
use an dedicated compose file --quiet-pull e2e test
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-02-21 18:59:09 +01:00
Guillaume Lours
9b0d1ffcf8
Add a fallback check of Watch pid on Windows
False positives were detected when checking the previous watch process state

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-02-19 15:01:38 +01:00
Guillaume Lours
d10a179f3e add support of QuietOption to create command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-02-19 14:19:01 +01:00
Guillaume Lours
94246f3cac pass QuietOption when starting dependencies from run command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-02-19 14:19:01 +01:00
Nicolas De Loof
9630cc5808 when ran with ANSI disabled, force progress=plain
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-18 12:33:20 +01:00
Gautham Hullikunte
6c175548b8 Issue-11374: Modified compose up command to respect COMPOSE_REMOVE_ORPHANS environment variable
Signed-off-by: Gautham Hullikunte <46633282+batcity@users.noreply.github.com>
Signed-off-by: Gautham Hullikunte <gautham@Gauthams-MacBook-Pro.local>
2024-02-17 09:37:00 +01:00
Guillaume Lours
f1431b2a48
Merge pull request #11512 from laurazard/bump-engine-ci
ci: bump engine version to `25.0.3`
2024-02-16 15:03:09 +01:00
Laura Brehm
9b0e3d53eb
ci: bump engine version to 25.0.3
changes: https://github.com/moby/moby/releases/tag/v25.0.3

(Hopefully, this fixes some networking flakyness)

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-02-16 12:47:24 +00:00
Nicolas De Loof
de3da829ea sort containers to optimize scale down
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-15 17:47:42 +01:00
Nicolas De Loof
c79aabde32 discard stdout for laaarge log test
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-15 16:18:58 +01:00
Guillaume Lours
eb5f7d76fe
Merge pull request #11503 from ndeloof/includes_metric
use listeners to collect include metrics
2024-02-15 11:27:19 +01:00
Nicolas De Loof
0aad322140
use listeners to collect include metrics
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-15 11:20:09 +01:00
David Karlsson
b1c06770d4 docs: update cli reference link
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2024-02-15 08:20:11 +01:00
Guillaume Lours
a220043ca0
Merge pull request #11497 from milas/rm-docker-cp-syncer
chore(watch): remove old `docker cp` implementation
2024-02-14 21:26:05 +01:00
Piotr Dąbrowski
e330f5905b
docs: unify no trailing dots in docstrings and help (#11301) 2024-02-14 14:02:37 -05:00
Guillaume Lours
aa56ab3e71
Merge pull request #11492 from jhrotko/use-listeners-for-file-metadata
Use listener for file metadata
2024-02-14 18:04:06 +01:00
jhrotko
16c8099cf8 Use listener for file metadata
Signed-off-by: jhrotko <joana.hrotko@docker.com>
2024-02-14 16:51:56 +00:00
Nicolas De Loof
07bda5960e fix deadlock collecting large logs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-13 20:15:19 +01:00
Milas Bowman
d203402998 chore(watch): remove old docker cp implementation
This has not been the default for quite a while and required
setting an environment variable to revert back.

The tar implementation is more performant and addresses several
edge cases with the original `docker cp` version, so it's time
to fully retire it.

The scaffolding for multiple sync implementations remains to
support future experimentation here.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-02-13 12:56:53 -05:00
Nicolas De loof
894ab41c3b
ci(deps): bump docker/cli to v25.0.3 (#11481)
https://github.com/docker/cli/releases/tag/v25.0.3
https://github.com/moby/moby/releases/tag/v25.0.3
2024-02-12 11:20:31 -05:00
1arp
3ba66453d2 pass All option to backend api.Service when length statuses is not equal to zero
Signed-off-by: 1arp <dekhijaegi@gmail.com>
2024-02-09 16:37:29 +01:00
Guillaume Lours
4ce63f53f7
Merge pull request #11485 from jhrotko/add-otel-build-depends-capabilities
add OTEL build,depends and capabilities to attributes
2024-02-09 12:25:07 +01:00
jhrotko
2eca9313c2 Add OTEL specs: build, depends_on, capabilities (gpu/tpu)
Signed-off-by: jhrotko <joana.hrotko@docker.com>
2024-02-09 10:55:07 +00:00
dependabot[bot]
1fea7c1beb build(deps): bump github.com/opencontainers/image-spec
Bumps [github.com/opencontainers/image-spec](https://github.com/opencontainers/image-spec) from 1.1.0-rc5 to 1.1.0-rc6.
- [Release notes](https://github.com/opencontainers/image-spec/releases)
- [Changelog](https://github.com/opencontainers/image-spec/blob/main/RELEASES.md)
- [Commits](https://github.com/opencontainers/image-spec/compare/v1.1.0-rc5...v1.1.0-rc6)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/image-spec
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-08 15:47:39 +01:00
Milas Bowman
acf2ffb0c7 feat(tracing): add project hash attr
Hash the project config and add it as an attribute. This can be
used to group multiple spans.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-02-08 15:47:25 +01:00
Milas Bowman
0d48a93f57 chore(load): ensure context passed to load
This wasn't always getting passed, so adding it to the wrapper
function where it'll pass the `WithContext()` loader method at
the last moment.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-02-08 15:46:37 +01:00
Laura Brehm
aaa7ef6de5 Include all networks in ContainerCreate call if API >= 1.44
Previously, we included the container's primary network in the
ContainerCreate API call, and then connected the created container
to each extra network one-by-one, by calling NetworkConnect.

However, starting API version 1.44, the ContainerCreate endpoint now
takes multiple EndpointsConfigs, allowing us to just include all the
network configurations there and skip connecting the container to each
extra network separately.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-02-07 16:21:15 +01:00
Nicolas De Loof
6ef55a531f bump compose-go to v2.0.0-rc.4
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-07 10:44:44 +01:00
Nicolas De Loof
a553db33c6 CI: docker engine version matrix
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-05 12:09:45 +01:00
Guillaume Lours
338ffe07a0
Merge pull request #11443 from docker/dependabot/go_modules/github.com/docker/cli-25.0.2incompatible
build(deps): bump github.com/docker/cli from 25.0.1+incompatible to 25.0.2+incompatible
2024-02-01 12:03:18 +01:00
dependabot[bot]
05bec55d21
build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 25.0.1+incompatible to 25.0.2+incompatible.
- [Commits](https://github.com/docker/cli/compare/v25.0.1...v25.0.2)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-01 09:44:43 +00:00
Guillaume Lours
3c25af4fe9
Merge pull request #11405 from ndeloof/issue_11392
Fix load .env from project directory when project file is set by COMPOSE_FILE
2024-01-31 10:52:28 +01:00
Milas Bowman
8fdd45cd4c
chore(e2e): fix flaky test & standalone behavior (#11382) 2024-01-30 10:49:53 -05:00
CrazyMax
a0954dc59d
ci(deps): replace buildkit to fix fsutil issues on Windows (#11426) 2024-01-30 10:48:48 -05:00
jhrotko
0582001810 Fix canonical container name
Signed-off-by: jhrotko <joana.hrotko@docker.com>
2024-01-30 15:12:22 +01:00
Guillaume Lours
ac8ea082a1
Merge pull request #11409 from ndeloof/swarm_overlay_network
don't check external network existence when swarm is enabled
2024-01-29 20:11:13 +01:00
Nicolas De Loof
da1a34a8f2 don't check external network existence when swarm is enabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-01-29 20:00:29 +01:00
Guillaume Lours
cdb6eb55d5
Merge pull request #11406 from docker/dependabot/go_modules/github.com/docker/cli-25.0.1incompatible
build(deps): bump github.com/docker/cli from 25.0.0+incompatible to 25.0.1+incompatible
2024-01-29 19:56:56 +01:00
dependabot[bot]
8b023ae07d build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 25.0.0+incompatible to 25.0.1+incompatible.
- [Commits](https://github.com/docker/cli/compare/v25.0.0...v25.0.1)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-29 19:46:03 +01:00
Guillaume Lours
e08140babe
Merge pull request #11407 from docker/dependabot/go_modules/github.com/docker/docker-25.0.1incompatible
build(deps): bump github.com/docker/docker from 25.0.0+incompatible to 25.0.1+incompatible
2024-01-29 19:44:44 +01:00
dependabot[bot]
8c80297c76 build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 25.0.0+incompatible to 25.0.1+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v25.0.0...v25.0.1)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-29 19:33:58 +01:00
Guillaume Lours
05f1472f6a
Merge pull request #11422 from ndeloof/storage_opts
Add support for storage_opt
2024-01-29 19:33:22 +01:00
Guillaume Lours
5728c43db8
Merge pull request #11410 from thaJeztah/bump_engine_25.0.1
ci(deps): update DOCKER_CLI_VERSION to v25.0.1
2024-01-29 19:31:45 +01:00
Nicolas De Loof
7e991515bc Add support for storage_opt
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-01-29 19:24:23 +01:00
Sebastiaan van Stijn
d979115692 ci(deps): update DOCKER_CLI_VERSION to v25.0.1
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-29 19:23:26 +01:00
Guillaume Lours
c653ddf439
Merge pull request #11411 from laurazard/update-maintainers
Update MAINTAINERS file
2024-01-29 19:22:49 +01:00
Guillaume Lours
a9cbb0f481
Merge pull request #11416 from glours/fix-merge-compose-go-issue
bump compose-go to fix multiple compose files merge issues
2024-01-29 15:41:24 +01:00
Guillaume Lours
71bebc16ee
bump compose-go to v2.0.0-rc.3 which fixes multiple compose files merge issues
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-01-29 15:26:26 +01:00
Guillaume Lours
b0dc374abc
Merge pull request #11415 from dvdksn/bump-artifact-upload-v4
build(deps): bump actions/upload-artifact from v3 to v4
2024-01-26 09:49:48 +01:00
David Karlsson
25d16d1fb4 build(deps): bump actions/upload-artifact from v3 to v4
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2024-01-26 09:39:24 +01:00
Laura Brehm
ab97dcc7c5
update MAINTAINERS file
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-01-25 14:28:44 +00:00
Nicolas De Loof
a8bd3b7af1
Fix load .env from project directory when project file is set by COMPOSE_FILE
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-01-25 09:26:22 +01:00
Guillaume Lours
bef8785fc2
Merge pull request #11400 from glours/fix-fsutils-windows
use a custom version of fsutils that fixes a bug on Windows causing all Compose builds to fail
2024-01-24 18:39:58 +01:00
Guillaume Lours
811364b4f8
use a custom version of fsutils that fixes a bug on Windows causing all Compose builds to fail
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-01-24 17:59:13 +01:00
Nicolas De Loof
1551fcb4e6 introduce stopAndRemoveContainer to share logic scaling down
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-01-23 14:16:13 +01:00
Guillaume Lours
143ac0f1b6
Merge pull request #11390 from ndeloof/compose-go-v2.0.0-rc.2
bump compose-go to v2.0.0-rc.2
2024-01-22 17:07:26 +01:00
Nicolas De Loof
eb4249ece4
bump compose-go to v2.0.0-rc.2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-01-22 12:27:38 +01:00
Milas Bowman
1e8241f67c
ci(deps): upgrade to Moby v25.0.0 GA (#11381)
https://github.com/moby/moby/releases/tag/v25.0.0
2024-01-19 12:33:21 -05:00
Sebastiaan van Stijn
388169011f
Merge pull request #11359 from dvdksn/docs-update-cli-reference-link
docs: update link to use canonical URL for command
2024-01-19 12:52:12 +01:00
David Karlsson
053a560466 docs: update link to use canonical URL for command
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2024-01-19 11:38:14 +01:00
Laura Brehm
35e262e778
Merge pull request #11372 from thaJeztah/bump_engine_deps 2024-01-18 17:43:24 +00:00
Sebastiaan van Stijn
34ba0bc9dd
go.mod: github.com/moby/sys/mountinfo v0.7.1
full diff: https://github.com/moby/sys/compare/mountinfo/v0.6.2...mountinfo/v0.7.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-18 17:59:21 +01:00
Sebastiaan van Stijn
56e38260ea
go.mod: github.com/google/uuid v1.5.0
full diff: https://github.com/google/uuid/compare/v1.3.1...v1.5.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-18 17:58:39 +01:00
Guillaume Lours
83e020734d
Merge pull request #11368 from glours/bump-compose-go-v2.0.0-rc.1
bump version of compose-go to v2.0.0-rc.1
2024-01-18 10:47:24 +01:00
Guillaume Lours
c28bf5227a bump version of compose-go to v2.0.0-rc.1
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-01-18 10:34:22 +01:00
Guillaume Lours
326ee2ad69
Merge pull request #11367 from docker/dependabot/go_modules/github.com/docker/docker-25.0.0-rc.3incompatible
build(deps): bump github.com/docker/docker from 25.0.0-rc.2+incompatible to 25.0.0-rc.3+incompatible
2024-01-18 10:33:58 +01:00
dependabot[bot]
51c113b623 build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 25.0.0-rc.2+incompatible to 25.0.0-rc.3+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v25.0.0-rc.2...v25.0.0-rc.3)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-18 10:23:59 +01:00
Guillaume Lours
194b8af242
Merge pull request #11365 from docker/dependabot/go_modules/github.com/docker/cli-25.0.0-rc.3incompatible
build(deps): bump github.com/docker/cli from 25.0.0-rc.2+incompatible to 25.0.0-rc.3+incompatible
2024-01-18 10:23:45 +01:00
Guillaume Lours
0d895a23f8
Merge pull request #11363 from glours/remove-watch-from-alpha
remove watch subcommand from the alpha command
2024-01-18 10:23:08 +01:00
Guillaume Lours
7cdc7e15e3 remove watch command from the alpha command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-01-18 10:14:43 +01:00
Guillaume Lours
fb6d92250c
Merge pull request #11361 from laurazard/always-handle-signals
signals/utils: always handle received signals
2024-01-18 10:14:27 +01:00
dependabot[bot]
fb026543f2
build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 25.0.0-rc.2+incompatible to 25.0.0-rc.3+incompatible.
- [Commits](https://github.com/docker/cli/compare/v25.0.0-rc.2...v25.0.0-rc.3)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-18 09:05:40 +00:00
Milas Bowman
d688d3bf22 fix(tracing): batch span exports to prevent blocking
This was a bad configuration (my fault) that meant each span was
exported synchronously, as it ended. That can cause weird behavior
such as stuttering/blocking.

There's really no reason to NOT use the batch processor, it's the
recommended way to configure it. In the future, it might make sense
to tune the intervals based on the fact that Compose is a CLI vs
a long-running server app, but we handle flushing out on exit
already, so it's not a huge deal.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-01-17 21:17:16 +01:00
Laura Brehm
898e1b605d
signals/utils: always handle received signals
The changes in
dcbf005fe4
fixed the "cancellable context" detection, and made it so that Compose
would conditionally set up signal handling when the context was already
not cancellable/when the plugin was running through the CLI, as we'd
introduced a mechanism into the CLI to signal plugins to exit through a
socket instead of handling signals themselves.

This had some (not noticed at the time) issues when running through the
CLI as, due to sharing a process group id with the parent CLI process,
when a user CTRL-Cs the CLI will notify the plugin via the socket but
the plugin process itself will also be signalled if attached to the TTY.
This impacted some Compose commands that don't set up signal handling -
so not `compose up`, but other commands would immediately quit instead
of getting some "graceful" cancelled output.

We initially attempted to address this "double notification" issue in
the CLI by executing plugins under a new pgid so that they wouldn't be
signalled, but that posed an issue with Buildx reading from the TTY,
(see: https://github.com/moby/moby/issues/47073) so we reverted the
process group id changes and ended at a temporary solution in
https://github.com/docker/cli/pull/4792 where the CLI will only notify
plugins via the socket when they are not already going to be signalled
(when attached to a TTY).

Due to this, plugins should always set up some signal handling, which
this commit implements.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-01-17 17:18:20 +00:00
Nicolas De Loof
f414bf7892 fix engine version require to use healthcheck.start_interval
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-01-17 10:45:01 +01:00
Nicolas De Loof
3c4593f2ad Stop the resource timer after last expected event
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-01-16 22:18:42 +01:00
dependabot[bot]
d2562029f6
build(deps): bump github.com/containerd/containerd from 1.7.11 to 1.7.12 (#11347)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-16 15:13:12 -05:00
dependabot[bot]
26ed1051eb
build(deps): bump github.com/docker/docker from 25.0.0-rc.1+incompatible to 25.0.0-rc.2+incompatible (#11349)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-16 15:12:57 -05:00
dependabot[bot]
191c10b9d0
build(deps): bump github.com/docker/cli from 25.0.0-rc.1+incompatible to 25.0.0-rc.2+incompatible (#11348)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-16 15:12:35 -05:00
Guillaume Lours
8b16ab1040
Merge pull request #11307 from glours/compose-go-immutable-projects
update compose-go to version using immutable Project functions
2024-01-11 14:11:12 +01:00
Guillaume Lours
24d34040e3
Merge pull request #11181 from g0t4/11153-compose-attach-override-container-attach-cmd
Implement `docker compose attach`
2024-01-11 11:11:10 +01:00
Guillaume Lours
dbe7819fd4
Merge pull request #11333 from milas/hack-user-agent
feat(cli): report more useful User-Agent on engine API requests
2024-01-11 10:57:14 +01:00
Guillaume Lours
5d05df6e5c update compose-go to version using immutable Project functions
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-01-11 10:44:42 +01:00
Milas Bowman
b621948c1b feat(cli): report more useful User-Agent on engine API requests
When using the Moby/Docker Engine API client, we do not have a
useful user agent value being reported. Ideally, in the future,
the Docker CLI will set this appropriately for plugins when it
initializes the client.

For now, manually set it, which is a bit hacky because it
requires some casting & manually invoking an option function
that's technically meant for initialization. In practice, this
is pretty safe - the cast is checked defensively and we ignore
any errors (which shouldn't be possible anyway).

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-01-10 13:38:27 -05:00
Guillaume Lours
6f62bcccbb
Merge pull request #11332 from milas/bump-golangci-lint
ci(deps): bump golangci-lint to v1.55.2
2024-01-10 19:30:00 +01:00
Milas Bowman
f5c53c2d07 ci(deps): bump golangci-lint to v1.55.2
No new violations / changes needed.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-01-10 12:56:48 -05:00
Guillaume Lours
1cfeda71eb
ci(deps): bump golang to version v1.21.6 (#11331)
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-01-10 12:18:43 -05:00
Guillaume Lours
e9c7a3a9d5
Merge pull request #11324 from docker/dependabot/go_modules/golang.org/x/sys-0.16.0
build(deps): bump golang.org/x/sys from 0.15.0 to 0.16.0
2024-01-10 15:50:30 +01:00
Brian Goff
2bf2b22fbe Add source policies for build
Build{x,kit} support passing in source policies via an (expirimental)
env var.
This change adds those policies to the build request.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-01-10 11:41:03 +01:00
Guillaume Lours
8d81b87513
Merge pull request #11330 from ndeloof/watch_tar
watch: remove requirements for tar binary and for sync target to be rw
2024-01-09 16:58:38 +01:00
Nicolas De Loof
575f2ed7f2
watch: remove requirements for tar binary and for sync target to be rw
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-01-09 15:43:34 +01:00
Wes Higbee
5f4b22ed7c make docs
Signed-off-by: Wes Higbee <wes.mcclure@gmail.com>
2024-01-08 17:21:26 -06:00
Wes Higbee
dcf6bd779f make mocks
Signed-off-by: Wes Higbee <wes.mcclure@gmail.com>
2024-01-08 17:15:11 -06:00
Wes Higbee
80823b77ef go ahead and wire up sig-proxy and no-stdin for consistency with underlying docker container attach
Signed-off-by: Wes Higbee <wes.mcclure@gmail.com>
2024-01-08 17:15:11 -06:00
Wes Higbee
2c16e16db7 docker compose attach via RunAttach (from docker/cli's docker container attach)
Signed-off-by: Wes Higbee <wes.mcclure@gmail.com>
2024-01-08 17:14:49 -06:00
dependabot[bot]
d1be9caf59
build(deps): bump golang.org/x/sys from 0.15.0 to 0.16.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.15.0 to 0.16.0.
- [Commits](https://github.com/golang/sys/compare/v0.15.0...v0.16.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-08 09:34:40 +00:00
Guillaume Lours
f659918743
Merge pull request #11298 from ndeloof/proxy
remove ServiceProxy which was introduced for archived compose-cli
2024-01-08 10:04:00 +01:00
dependabot[bot]
c3c0cf3d94
build(deps): bump golang.org/x/sync from 0.5.0 to 0.6.0 (#11317)
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.5.0 to 0.6.0.
- [Commits](https://github.com/golang/sync/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-05 13:43:38 -05:00
Milas Bowman
eec822de8f
Merge pull request #11321 from thaJeztah/gha_bump_cli_version
gha: update DOCKER_CLI_VERSION to v24.0.7
2024-01-05 13:42:29 -05:00
Milas Bowman
6df3886b44
Merge pull request #11320 from thaJeztah/bump_engine3
go.mod: update docker/docker and docker/cli to v25.0.0-rc.1
2024-01-05 13:41:33 -05:00
Sebastiaan van Stijn
279874158c
gha: update DOCKER_CLI_VERSION to v24.0.7
I noticed that the CLI was still on 20.10, but the daemon on 24.0.7;

    Docker info
    /usr/bin/docker version
    Client:
    Version:           20.10.17
    API version:       1.41
    Go version:        go1.17.11
    Git commit:        100c701
    Built:             Mon Jun  6 22:56:42 2022
    OS/Arch:           linux/amd64
    Context:           default
    Experimental:      true
    Server: Docker Engine - Community
    Engine:
    Version:          24.0.7
    API version:      1.43 (minimum version 1.12)
    Go version:       go1.20.10
    Git commit:       311b9ff
    Built:            Thu Oct 26 09:07:41 2023
    OS/Arch:          linux/amd64
    Experimental:     false
    containerd:
    Version:          1.6.26
    GitCommit:        3dd1e886e55dd695541fdcd67420c2888645a495
    runc:
    Version:          1.1.10
    GitCommit:        v1.1.10-0-g18a0cb0
    docker-init:
    Version:          0.19.0
    GitCommit:        de40ad0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-05 19:32:23 +01:00
Sebastiaan van Stijn
566d2207f3
go.mod: github.com/docker/cli v25.0.0-rc.1
full diff: https://github.com/docker/cli/compare/v25.0.0-beta.3...v25.0.0-rc.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-05 18:57:57 +01:00
Sebastiaan van Stijn
d09c39dced
go.mod: github.com/docker/docker v25.0.0-rc.1
full diff: https://github.com/docker/docker/compare/v25.0.0-beta.3...v25.0.0-rc.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-05 18:57:15 +01:00
Sebastiaan van Stijn
a1d36379a3
go.mod: github.com/klauspost/compress v1.17.4
full diff: https://github.com/klauspost/compress/compare/v1.17.2...v1.17.4

v1.17.4:

- huff0: Speed up symbol counting
- huff0: Remove byteReader
- gzhttp: Allow overriding decompression on transport
- gzhttp: Clamp compression level
- gzip: Error out if reserved bits are set

v1.17.3:

- fse: Fix max header size
- zstd: Improve better/best compression
- gzhttp: Fix missing content type on Close

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-05 18:45:31 +01:00
Sebastiaan van Stijn
0c55998b41
go.mod: github.com/felixge/httpsnoop v1.0.4
full diff: https://github.com/felixge/httpsnoop/compare/v1.0.3...v1.0.4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-05 18:39:58 +01:00
Sebastiaan van Stijn
2f6ec9b777
go.mod: github.com/docker/go-connections v0.5.0
no diff, as the tag is the same commit as we used already;
https://github.com/docker/go-connections/compare/fa09c952e3ea...v0.5.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-05 18:33:26 +01:00
Milas Bowman
06af729dc8
Merge pull request #11292 from laurazard/update-cli-signal-handling
Up: teardown when command context is cancelled
2024-01-02 15:48:14 -05:00
Laura Brehm
dcbf005fe4
up: gracefully teardown when command ctx cancelled
Previously, if a long-lived plugin process (such as
an execution of `compose up`) was running and then
detached from a terminal, signalling the parent CLI
process to exit would leave the plugin process behind.

To address this, changes were introduced on the CLI side
(see: https://github.com/docker/cli/pull/4599) to enable
the CLI to notify a running plugin process that it should
exit. This makes it so that, when the parent CLI process
is going to exit, the command context of the plugin
command being executed is cancelled.

This commit takes advantage of these changes by tapping into
the command context's done channel and using it to teardown
on an up.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-12-23 02:49:27 +00:00
Nicolas De Loof
e105f16527 introduce stats command
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-22 16:03:02 +01:00
Laura Brehm
ce5a0c656f
Fix cancellable context detection in AdaptCmd
`AdaptCmd` was previously checking for a `.WithCancel` suffix
on context strings, however it's possible for a context to be
cancellable without ending in that suffix, such as when
`context.WithValue` was called after `WithContext`, e.g.:

```go
context.Background.WithCancel.WithValue(type trace.traceContextKeyType,
val <not Stringer>).WithValue(type api.DryRunKey, val <not Stringer>)
```

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-12-22 13:39:04 +00:00
Nicolas De Loof
f58f23a6a2
remove ServiceProxy which was introduced for archived compose-cli
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-22 14:02:21 +01:00
Guillaume Lours
d82a1a5a03
Merge pull request #11294 from thaJeztah/bump_engine2
go.mod: docker/docker and docker/cli v25.0.0-beta.3
2023-12-22 11:28:37 +01:00
Sebastiaan van Stijn
9aa5232601 go.mod: docker/docker and docker/cli v25.0.0-beta.3
- https://github.com/docker/cli/compare/70216b662dc4...v25.0.0-beta.3
- https://github.com/docker/docker/compare/v25.0.0-beta.2...v25.0.0-beta.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Sebastiaan van Stijn
ccd83b8a74 go.mod: github.com/gorilla/mux v1.8.1
full diff: https://github.com/gorilla/mux/compoare/v1.8.0...v1.8.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Sebastiaan van Stijn
9e57850c16 go.mod: github.com/docker/distribution v2.8.3
full diff: https://github.com/docker/distribution/compare/v2.8.2...v2.8.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Sebastiaan van Stijn
35d3a7ca56 go.mod: golang.org/x/crypto v0.17.0
update the package, which contains a fix in the ssh package.

full diff: https://github.com/golang/crypto/compare/v0.16.0...v0.17.0

from the security mailing:

> Hello gophers,
>
> Version v0.17.0 of golang.org/x/crypto fixes a protocol weakness in the
> golang.org/x/crypto/ssh package that allowed a MITM attacker to compromise
> the integrity of the secure channel before it was established, allowing
> them to prevent transmission of a number of messages immediately after
> the secure channel was established without either side being aware.
>
> The impact of this attack is relatively limited, as it does not compromise
> confidentiality of the channel. Notably this attack would allow an attacker
> to prevent the transmission of the SSH2_MSG_EXT_INFO message, disabling a
> handful of newer security features.
>
> This protocol weakness was also fixed in OpenSSH 9.6.
>
> Thanks to Fabian Bäumer, Marcus Brinkmann, and Jörg Schwenk from Ruhr
> University Bochum for reporting this issue.
>
> This is CVE-2023-48795 and Go issue https://go.dev/issue/64784.
>
> Cheers,
> Roland on behalf of the Go team

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Sebastiaan van Stijn
6c998602bb go.mod: golang.org/x/crypto v0.16.0
full diff: https://github.com/golang/crypto/compare/v0.14.0...v0.16.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Sebastiaan van Stijn
402f368830 go.mod: golang.org/x/text v0.14.0
full diff: https://github.com/golang/text/compare/v0.13.0...v0.14.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Sebastiaan van Stijn
30dd3e66d7 go.mod: golang.org/x/term v0.15.0
full diff: https://github.com/golang/term/compare/v0.13.0...v0.15.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Nicolas De Loof
0c4fa017b9 Bump compose-go v2-beta.2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-22 11:16:13 +01:00
dependabot[bot]
b12e23b0bd build(deps): bump go.uber.org/mock from 0.3.0 to 0.4.0
Bumps [go.uber.org/mock](https://github.com/uber/mock) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/uber/mock/releases)
- [Changelog](https://github.com/uber-go/mock/blob/main/CHANGELOG.md)
- [Commits](https://github.com/uber/mock/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: go.uber.org/mock
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-21 14:52:59 +01:00
Nicolas De Loof
17da54da20 introduce build --with-dependencies
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-20 15:58:54 +01:00
horus
1baa4f4489 up: fix write/close race condition in logPrinter
The code used an atomic bool to guard channel writes. However, this
failed to synchronize with the call to close(), causing a panic.

Fix the race condition by using a mutex to guard the update to the
bool `stopped` and subsequent channel writes. This ensures atomic
execution of both updates to `stopped` and channel writes, preventing
races between writes and close().

Signed-off-by: horus <horus.li@gmail.com>
2023-12-20 15:45:12 +01:00
Guillaume Lours
aefc2a111a
Merge pull request #11283 from laurazard/update-cli-version-go
deps: update docker/cli to fix go version selection issue
2023-12-19 15:26:24 +01:00
Laura Brehm
7781b7c992
deps: update docker/cli to fix go version selection issue
see: 70216b662d

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-12-19 14:15:16 +00:00
Albin Kerouanton
785835b1a2 Add support for endpoint-specific MAC address
Related to:

- https://github.com/compose-spec/compose-spec/pull/435
- https://github.com/moby/moby/pull/45905

Since API v1.44, Moby supports a per-endpoint MAC address and returns a
warning when the container-wide mac_address field is set.

A corresponding field has been added to compose-spec and compose-go, so
we need to leverage it to set the right API field.

This commit is backward-compatible with compose files that still set the
container-wide mac_address field, and older API versions that don't know
about the endpoint-specific MAC address field.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-12-18 12:04:45 +01:00
Nicolas De Loof
e4fb5545f0 build do not require environment to be reslved
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-14 11:21:46 +01:00
Nicolas De Loof
74cc091225 github.com/golang/mock is deprecated
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-13 14:47:39 +01:00
Nicolas De Loof
5e61c62ecf collect services to build using WithServices
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-07 17:05:42 +01:00
Nicolas De Loof
fb3868ffaf add support for start_interval
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-07 15:59:22 +01:00
Guillaume Lours
30e80d2440
Merge pull request #11251 from ndeloof/completion_disabled
include disabled services for shell completion
2023-12-06 09:47:00 +01:00
Nicolas De Loof
bdbda79043 include disabled services for shell completion
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-06 09:38:11 +01:00
Guillaume Lours
862f2a19f4
Merge pull request #11249 from glours/bump-golang-1.21.5
bump golang to version 1.21.5
2023-12-06 09:37:18 +01:00
Guillaume Lours
ae4fd7916c
bump golang to version 1.21.5
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-12-06 00:04:15 +01:00
Nicolas De Loof
26aca867d8 avoid use of service.Name when iterating on project.Services
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-05 18:54:31 +01:00
Nicolas De Loof
138facea62 project.Services is a map
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-05 18:54:31 +01:00
Nicolas De Loof
cda04f288e adopt compose-go/v2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-05 18:54:31 +01:00
Milas Bowman
85a1aec123 regen docs
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-12-05 18:08:38 +01:00
Milas Bowman
9c29d2236d use custom config type for OCI v1.0
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-12-05 18:08:38 +01:00
Milas Bowman
df6fe59f72 tweak help message on oci version flag
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-12-05 18:08:38 +01:00
Milas Bowman
07df9cc46e fix typo
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-12-05 18:08:38 +01:00
Milas Bowman
7c8ff36d78 move around OCI logic, auto fallback/retry 1.1 -> 1.0
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-12-05 18:08:38 +01:00
Milas Bowman
111ad3b039 fix(publish): add OCI 1.0 fallback support for AWS ECR
Currently, we publish Compose artifacts following the OCI 1.1
specification, which is still in the RC state.

As a result, not all registries support it yet. Most notably,
AWS ECR will reject certain OCI 1.1-compliant requests with
`405 Method Not Supported` with cryptic `Invalid JSON` errors.

This adds initial support for Compose to generate either an
OCI 1.0 or OCI 1.1 compatible manifest. Notably, the OCI 1.0
manifest will be missing the `application/vnd.docker.compose.project`
artifact type, as that does not exist in that version of the
spec. (Less importantly, it uses an empty `ImageConfig`
instead of the newer `application/vnd.oci.empty.v1+json` media
type for the config.)

Currently, this is not exposed as an option (via CLI flags or
env vars). By default, OCI 1.1 is used unless the registry
domain is `amazonaws.com`, which indicates an ECR registry, so
Compose will instead use OCI 1.0.

Moving forward, we should decide how much we want to expose/
support different OCI versions and investigate if there's a
more generic way to feature probe the registry to avoid
maintaining a hardcoded list of domains, which is both tedious
and insufficient.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-12-05 18:08:38 +01:00
Nicolas De Loof
8026d0e2f2 adopt container.RestartPolicy*
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-05 17:02:37 +01:00
Nicolas De Loof
df1533a1ca [lint] don't use deprecated types
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-05 17:02:37 +01:00
Nicolas De Loof
8639fbae86 go mod tidy
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-05 17:02:37 +01:00
Wes Higbee
56e2ad9ee5 update to v1.25 for RunAttach
Signed-off-by: Wes Higbee <wes.mcclure@gmail.com>
2023-12-05 17:02:37 +01:00
Nicolas De Loof
ce1ddb6c7e fix combination of --pull always --no-build
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-04 11:08:08 +01:00
dependabot[bot]
c5824702bf build(deps): bump golang.org/x/sys from 0.14.0 to 0.15.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.14.0 to 0.15.0.
- [Commits](https://github.com/golang/sys/compare/v0.14.0...v0.15.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-30 09:42:39 +01:00
vyneer
1f148244af send out a cancel event on SIGINT/SIGTERM
Signed-off-by: vyneer <vyn33r@gmail.com>
2023-11-30 09:11:55 +01:00
johnthagen
9faef4aebb Update README.md to use standard compose.yaml file name
Signed-off-by: johnthagen <johnthagen@users.noreply.github.com>
2023-11-30 08:53:44 +01:00
Nicolas De Loof
59f11ecbeb Fix configs are mounted under /<id>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-29 16:53:22 +01:00
Amit Saha
750553c866 introduce compose logs --index to select a replica container
Signed-off-by: Amit Saha <asaha@atlassian.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-29 13:56:16 +01:00
Amit Saha
8c964f5ad3 Update E2E test
Signed-off-by: Amit Saha <asaha@atlassian.com>
2023-11-29 13:56:16 +01:00
Amit Saha
90ca13b747 Fix E2E test to have index in the correct position
Signed-off-by: Amit Saha <asaha@atlassian.com>
2023-11-29 13:56:16 +01:00
Amit Saha
f9946127ce Fix docs
Signed-off-by: Amit Saha <asaha@atlassian.com>
2023-11-29 13:56:16 +01:00
Amit Saha
ddda59a130 Add index option to compose logs command
Signed-off-by: Amit Saha <asaha@atlassian.com>
2023-11-29 13:56:16 +01:00
Amit Saha
e981c35863 Add failing test
Signed-off-by: Amit Saha <asaha@atlassian.com>
2023-11-29 13:56:16 +01:00
Nicolas De Loof
16c4241c0b log we don't expose service ports when --verbose
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-29 11:40:16 +01:00
Guillaume Lours
f5e3ff03f0
Merge pull request #11225 from ndeloof/ddev-bump
bump ddev to 1.22.4
2023-11-27 14:29:36 +01:00
Nicolas De Loof
9025d63a63
bump ddev
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-27 14:19:53 +01:00
Nicolas De Loof
a1de0b96c3 Restore Project is ps json output
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-24 10:46:33 +01:00
Guillaume Lours
ba24a656bf
Merge pull request #11220 from ndeloof/ps_profile
Introduce ps --orphans to include/exclude services not declared by project
2023-11-23 13:52:20 +01:00
Nicolas De Loof
caa0cbbc4b
Introduce ps --orphans so user can include/exclude services not declared by project
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-23 13:43:49 +01:00
Guillaume Lours
8c0c5cb671
Merge pull request #11219 from ndeloof/no_answer
let contributor know we might close unanswered issues
2023-11-23 11:28:04 +01:00
Nicolas De Loof
29e9fdba16
let contributor know we might close unanswered issues
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-23 11:06:31 +01:00
Guillaume Lours
c665c53cc1 bump buildx to v0.12.0 and adapt code to changes
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-11-23 07:36:13 +01:00
Guillaume Lours
a1aceba655
Merge pull request #11215 from docker/dependabot/go_modules/github.com/compose-spec/compose-go-1.20.2
build(deps): bump github.com/compose-spec/compose-go from 1.20.1 to 1.20.2
2023-11-22 14:29:48 +01:00
dependabot[bot]
a39cf75e86 build(deps): bump github.com/compose-spec/compose-go
Bumps [github.com/compose-spec/compose-go](https://github.com/compose-spec/compose-go) from 1.20.1 to 1.20.2.
- [Release notes](https://github.com/compose-spec/compose-go/releases)
- [Commits](https://github.com/compose-spec/compose-go/compare/v1.20.1...v1.20.2)

---
updated-dependencies:
- dependency-name: github.com/compose-spec/compose-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-22 14:19:50 +01:00
Guillaume Lours
5b0dcc5a44
Merge pull request #11214 from docker/dependabot/go_modules/github.com/spf13/cobra-1.8.0
build(deps): bump github.com/spf13/cobra from 1.7.0 to 1.8.0
2023-11-22 14:19:27 +01:00
dependabot[bot]
46ba9c99ce
build(deps): bump github.com/spf13/cobra from 1.7.0 to 1.8.0
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-22 09:43:55 +00:00
Guillaume Lours
1148b6765a
Merge pull request #11142 from docker/dependabot/go_modules/github.com/docker/cli-24.0.7incompatible
build(deps): bump github.com/docker/cli from 24.0.6+incompatible to 24.0.7+incompatible
2023-11-22 10:15:33 +01:00
dependabot[bot]
5c5d30c674 build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 24.0.6+incompatible to 24.0.7+incompatible.
- [Commits](https://github.com/docker/cli/compare/v24.0.6...v24.0.7)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-22 09:55:15 +01:00
Guillaume Lours
2068eceee4
Merge pull request #11143 from docker/dependabot/go_modules/github.com/docker/docker-24.0.7incompatible
build(deps): bump github.com/docker/docker from 24.0.6+incompatible to 24.0.7+incompatible
2023-11-22 09:54:14 +01:00
dependabot[bot]
36fa8d4e71 build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 24.0.6+incompatible to 24.0.7+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v24.0.6...v24.0.7)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-22 09:43:45 +01:00
Guillaume Lours
69985b8b89
Merge pull request #11112 from docker/dependabot/go_modules/github.com/moby/buildkit-0.12.3
build(deps): bump github.com/moby/buildkit from 0.12.2 to 0.12.3
2023-11-22 09:43:06 +01:00
dependabot[bot]
2384635ee1 build(deps): bump github.com/moby/buildkit from 0.12.2 to 0.12.3
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.12.2 to 0.12.3.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.12.2...v0.12.3)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-22 09:33:44 +01:00
Guillaume Lours
587dba1167
Merge pull request #11213 from glours/watch-force-build-at-startup
in watch mode force pull policy to build for services with both build and develop attributes
2023-11-22 09:32:15 +01:00
Guillaume Lours
2ba5e4c1d0
in watch mode force pull policy to build for services with both build and develop attributes
This default behaviour will force a rebuild of the service images at watch process startup and be sure containers will be in sync with the local source code

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-11-21 16:42:43 +01:00
Nicolas De Loof
b1a26dac1d Assume /src/pkg/compose/testdata absolute workingdir to make tests reproducible
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-21 16:11:42 +01:00
Guillaume Lours
0ab21a2080
Merge pull request #11211 from ndeloof/Services
avoir use of []types.ServiceConfig
2023-11-21 12:17:09 +01:00
Nicolas De Loof
5e77ae9247
avoir use of []types.ServiceConfig
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-21 12:08:12 +01:00
Guillaume Lours
f557220140 identify services to build and don't display 'building' if none
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-11-21 11:35:11 +01:00
Nicolas De Loof
8e1b32365e fix --remove-orphans not to consider disabled services as orphaned
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-20 21:35:13 +01:00
Guillaume Lours
a1b7bee094
Merge pull request #11206 from ndeloof/check_runtime
introduce RuntimeVersion for code to check container runtime support
2023-11-20 11:59:43 +01:00
Nicolas De Loof
7cb1f8baf2
introduce RuntimeVersion for code to check container runtime supports required features
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-20 11:45:16 +01:00
Nicolas De Loof
cb01186c2b push also consider build.tags
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-17 16:31:52 +01:00
Ulysses Souza
efea084df6
Merge pull request #11192 from ulyssessouza/exclude-tests-context 2023-11-16 12:25:13 +01:00
Nicolas De Loof
9c4efbdd92 Strip project prefix from docker-compose up output
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-15 21:39:16 +01:00
Ulysses Souza
8ea7c9e0d2 Make it context aware and add test skipping options
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2023-11-15 21:09:50 +01:00
Nicolas De Loof
c16943609c render quiet after filtering applied
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-15 20:25:40 +01:00
Guillaume Lours
254a94b07d bump golang to version 1.21.4
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-11-13 22:16:33 +01:00
Nicolas De Loof
cf608fa954 bump compose-go to v1.20.1
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-13 22:07:02 +01:00
Nicolas De Loof
426377a4c9 reject compose file using secrets|configs.driver or template_driver
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-13 17:26:00 +01:00
Guillaume Lours
43c3f54598
Merge pull request #11180 from ulyssessouza/skip-flaky-tests
skips flaky e2e tests on watch and attach
2023-11-10 19:51:00 +01:00
Ulysses Souza
493f6c8055 skips flaky e2e tests on watch and attach
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2023-11-10 18:31:25 +01:00
Guillaume Lours
c1a9ffa07e
Merge pull request #11171 from szampardi/main
fix docker/compose#11170 add newline in cmd/compose/build.go fmt.Fprint
2023-11-08 23:23:16 +01:00
szampardi
646a8fc0e8 fix docker/compose#11170 add newline in cmd/compose/build.go fmt.Fprint
Signed-off-by: szampardi <szampardi@deepnull.com>
2023-11-08 16:17:23 +01:00
Nicolas De Loof
2945532f97 fix --pull documentation
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-07 09:03:49 +01:00
Guillaume Lours
e5cd265abb improve watch configuration logging
Add action associated to each managed path

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-11-06 13:48:15 +01:00
Nicolas De Loof
d646d757a2 lint
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-02 11:16:35 +01:00
Nicolas De Loof
71237ef62b do not resolve cache dir until remote resource is in use
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-02 11:16:35 +01:00
Nicolas De Loof
0d905a896d add a copyright notice with original author
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-02 11:16:35 +01:00
Nicolas De Loof
b847c7f5a4 implement runtime file selection
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-02 11:16:35 +01:00
Nicolas De Loof
5e3d8f671d re-implement cache folder detection
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-02 11:16:35 +01:00
Nicolas De Loof
6727908803 introduce --resolve-image-digests for publish to seal service images by digest
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-02 10:43:45 +01:00
Guillaume Lours
5661fd1bfe
Merge pull request #11149 from aevesdocker/ENGDOCS-1764
ENGDOCS-1764: Trivial fixes
2023-11-02 10:30:10 +01:00
aevesdocker
4cd61957ed fix build
Signed-off-by: aevesdocker <allie.sadler@docker.com>
2023-10-31 10:50:42 +00:00
aevesdocker
0d4cbbdbc9 fix
Signed-off-by: aevesdocker <allie.sadler@docker.com>
2023-10-31 10:44:59 +00:00
aevesdocker
9631a49daa ENGDOCS-1764
Signed-off-by: aevesdocker <allie.sadler@docker.com>
2023-10-31 10:40:48 +00:00
David Karlsson
328ca3f239 add docs upstream validation workflow
verifies that the reference docs don't contain broken links etc

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2023-10-30 18:36:30 +01:00
dependabot[bot]
e1bbfc6376 build(deps): bump go.uber.org/goleak from 1.2.1 to 1.3.0
Bumps [go.uber.org/goleak](https://github.com/uber-go/goleak) from 1.2.1 to 1.3.0.
- [Release notes](https://github.com/uber-go/goleak/releases)
- [Changelog](https://github.com/uber-go/goleak/blob/master/CHANGELOG.md)
- [Commits](https://github.com/uber-go/goleak/compare/v1.2.1...v1.3.0)

---
updated-dependencies:
- dependency-name: go.uber.org/goleak
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-30 08:18:38 +01:00
kimdcottrell
616bba0afd linter errors fixed
Signed-off-by: kimdcottrell <me@kimdcottrell.com>
2023-10-29 22:08:00 +01:00
kimdcottrell
ee6e3c2a44 NetworkList to NetworkInspect for ID search
Signed-off-by: kimdcottrell <me@kimdcottrell.com>
2023-10-29 22:08:00 +01:00
kimdcottrell
c7e31a3c15 Squashing feature branch commits in order to add signoff message.
- added clarity with error handling. added test to show issue.

- in manual testing, this fixes the issue and allows watch to run after rebuild

- added cleanup back in

- fixed issue where watch extnet rebuild test would start all containers listed in the fixture

Signed-off-by: kimdcottrell <me@kimdcottrell.com>
2023-10-29 22:08:00 +01:00
Matthew Walowski
704a9fd337 Use project.ServiceNames() if no service specified in hash
Signed-off-by: Matthew Walowski <mattwalowski@gmail.com>
2023-10-27 21:16:15 +02:00
temenuzhka-thede
d9e0e42d95 Add branch configuration for pull_request trigger
Signed-off-by: temenuzhka-thede <temenuzhka.thede@docker.com>

Add check-latest option to set up go step

Signed-off-by: temenuzhka-thede <temenuzhka.thede@docker.com>
2023-10-27 09:17:32 +02:00
temenuzhka-thede
c48e3c4a4f Initial codeql.yml commit
Signed-off-by: temenuzhka-thede <temenuzhka.thede@docker.com>

add new line

Signed-off-by: temenuzhka-thede <temenuzhka.thede@docker.com>

remove new line

Signed-off-by: temenuzhka-thede <temenuzhka.thede@docker.com>

remove new line

Signed-off-by: temenuzhka-thede <temenuzhka.thede@docker.com>

remove new line

Signed-off-by: temenuzhka-thede <temenuzhka.thede@docker.com>

remove new line

Signed-off-by: temenuzhka-thede <temenuzhka.thede@docker.com>

remove new line

Signed-off-by: temenuzhka-thede <temenuzhka.thede@docker.com>

remove os customization

Signed-off-by: temenuzhka-thede <temenuzhka.thede@docker.com>

remove os customization

Signed-off-by: temenuzhka-thede <temenuzhka.thede@docker.com>
2023-10-27 09:17:32 +02:00
Nicolas De Loof
dd0803dba1 fix SIGTERM support to stop/kill stack
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-10-26 12:19:50 +02:00
Nicolas De Loof
39008c539c align with OCI artifact best practices
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-10-23 20:26:13 +02:00
Guillaume Lours
6ab41d629f
Merge pull request #11060 from Juneezee/refactor/redundant-len-check
refactor(cmd/compose/run): remove redundant `len` check
2023-10-23 10:32:46 +02:00
Eng Zer Jun
6c345b3755
refactor(cmd/compose/run): remove redundant len check
From the Go specification [1]:

  "1. For a nil slice, the number of iterations is 0."

`len` returns 0 if the slice is nil [2]. Therefore, checking
`len(v) > 0` before a loop is unnecessary.

[1]: https://go.dev/ref/spec#For_range
[2]: https://pkg.go.dev/builtin#len

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2023-10-23 16:06:52 +08:00
Guillaume Lours
b8773ad1c5
Merge pull request #11110 from ndeloof/wait_missing
fail start if depependency is missing
2023-10-19 10:04:32 +02:00
Nicolas De Loof
1ffa194e12
fail start if depependency is missing
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-10-19 09:50:37 +02:00
Guillaume Lours
b92981015e check that the pull policy provided is a valid one
or is not missing when --pull is used

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-10-18 15:44:37 +02:00
Guillaume Lours
af87f10650
Merge pull request #11108 from ndeloof/down-services
enable profile when down is ran with explicit service names
2023-10-18 13:49:11 +02:00
Guillaume Lours
5e1d3f2b41
Merge pull request #11051 from ndeloof/warn_remote_disabled
warn user remote resource is disabled
2023-10-18 12:54:40 +02:00
Guillaume Lours
3d0207ebc8
remove uncessary return value of pullComposeFiles function
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-10-18 12:42:11 +02:00
Nicolas De Loof
16a7c20960
enable profile when down is ran with explicit service names
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-10-18 12:19:45 +02:00
Guillaume Lours
818bc3c34a add sync+restart action to watch attribute
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-10-18 12:11:02 +02:00
Guillaume Lours
cf3e686d8c
Merge pull request #11078 from docker/dependabot/go_modules/github.com/containerd/containerd-1.7.7
build(deps): bump github.com/containerd/containerd from 1.7.6 to 1.7.7
2023-10-18 11:35:04 +02:00
dependabot[bot]
38bc6d5dbc build(deps): bump github.com/containerd/containerd from 1.7.6 to 1.7.7
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.6 to 1.7.7.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.6...v1.7.7)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-18 11:20:06 +02:00
Guillaume Lours
4a2d4c44b2
Merge pull request #11083 from docker/dependabot/go_modules/github.com/google/go-cmp-0.6.0
build(deps): bump github.com/google/go-cmp from 0.5.9 to 0.6.0
2023-10-18 11:18:06 +02:00
dependabot[bot]
0b6ce6ee42 build(deps): bump github.com/google/go-cmp from 0.5.9 to 0.6.0
Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.9 to 0.6.0.
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](https://github.com/google/go-cmp/compare/v0.5.9...v0.6.0)

---
updated-dependencies:
- dependency-name: github.com/google/go-cmp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-18 11:03:14 +02:00
Guillaume Lours
034458dac7
Merge pull request #11105 from docker/dependabot/go_modules/google.golang.org/grpc-1.59.0
build(deps): bump google.golang.org/grpc from 1.58.2 to 1.59.0
2023-10-18 11:00:43 +02:00
dependabot[bot]
ae16bbbf05
build(deps): bump google.golang.org/grpc from 1.58.2 to 1.59.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.2 to 1.59.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.58.2...v1.59.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-18 08:45:06 +00:00
Guillaume Lours
eb5f01baf4
Merge pull request #11068 from docker/dependabot/go_modules/golang.org/x/sync-0.4.0
build(deps): bump golang.org/x/sync from 0.3.0 to 0.4.0
2023-10-18 10:44:00 +02:00
dependabot[bot]
d13ad1f997 build(deps): bump golang.org/x/sync from 0.3.0 to 0.4.0
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.3.0 to 0.4.0.
- [Commits](https://github.com/golang/sync/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-18 10:27:48 +02:00
Guillaume Lours
9b4d577c65 remove refrecence docs generation
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-10-11 14:19:56 +02:00
Guillaume Lours
b30978fb40
Merge pull request #11076 from glours/remove-cucumber
remove cucumber tests as we haven't added new ones for a while
2023-10-10 23:16:33 +02:00
Guillaume Lours
14b43c1a93
remove cucumber tests as we haven't added new ones for a while
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-10-10 09:57:25 +02:00
Guillaume Lours
9dd081b92e add support of COMPOSE_ENV_FILES env variable to pass a list of env files
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-10-05 21:55:43 +02:00
Guillaume Lours
2c0b023273 add dry-run support for publish command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-10-05 21:55:00 +02:00
Nicolas De Loof
599e4b242a
extract method to reduce cyclomatic complexity
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-29 10:18:11 +02:00
Nicolas De Loof
fe8c2780c8 warn user remote resource is disabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-29 09:30:38 +02:00
Matthew Walowski
a345515f91 Don't delete dependent services
Signed-off-by: Matthew Walowski <mattwalowski@gmail.com>
2023-09-29 06:43:16 +02:00
Matthew Walowski
8967df7a91 Apply platform before hashing
Signed-off-by: Matthew Walowski <mattwalowski@gmail.com>
2023-09-29 06:43:16 +02:00
Matthieu MOREL
4f694919ff deps: remove deprecated github.com/pkg/errors
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-09-29 06:28:58 +02:00
Matthew Walowski
6ecab95775 Include image name in error message
Signed-off-by: Matthew Walowski <mattwalowski@gmail.com>
2023-09-29 06:25:10 +02:00
Bjorn Neergaard
12e0ac898a pkg/compose/publish: use empty config descriptor mediaType
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-09-29 05:27:14 +02:00
Bjorn Neergaard
a6b7d78575 pkg/remote/oci: check artifactType instead of config.mediaType
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-09-29 05:27:14 +02:00
Bjorn Neergaard
991901f2ef pkg/remote/oci: refer to the manifest as manifest
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-09-29 05:27:14 +02:00
Guillaume Lours
bd74a9260d
Merge pull request #11047 from glours/update-watch-warning-section
update the watch warning message when no services with a develop section
2023-09-27 23:41:53 +02:00
Guillaume Lours
2d971fc97d
update the watch warning message when no services with a develop section
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-09-27 23:28:45 +02:00
Djordje Lukic
78f3361921
ci: enable verbose output for e2e tests (#11045)
It's easier to see that something is happening.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-27 16:29:54 +00:00
Nicolas De Loof
44d21280e7 truncate command by default, introduce --no-trunc flag to get the full command
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-23 06:34:26 +02:00
Guillaume Lours
cd743d17ba
Merge pull request #11036 from docker/dependabot/go_modules/google.golang.org/grpc-1.58.2
build(deps): bump google.golang.org/grpc from 1.58.1 to 1.58.2
2023-09-22 11:23:05 +02:00
dependabot[bot]
ff2ff18cdc
build(deps): bump google.golang.org/grpc from 1.58.1 to 1.58.2
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.1 to 1.58.2.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.58.1...v1.58.2)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-22 09:10:26 +00:00
Guillaume Lours
bd32ed1454
Merge pull request #11025 from ndeloof/SkipResolveEnvironment
config --xx don't need `env_file` being parsed
2023-09-21 12:28:25 +02:00
Nicolas De Loof
ab81db5bdb
config --xx don't need env_file being parsed
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-21 10:47:38 +02:00
Guillaume Lours
52a641bf6d
Merge pull request #11021 from glours/move-watch-to-main-cmd
move watch from alpha to main command
2023-09-21 10:08:23 +02:00
Guillaume Lours
75f5c07d3d
Merge pull request #11023 from glours/fix-watch-e2e-test-cleanup
remove --timeout=0 flag to cleanup function of watch e2e test
2023-09-20 21:43:51 +02:00
Guillaume Lours
61c8be11c0 remove --timeout=0 flag to cleanup function of watch e2e test
compose down command need the watch process to be killed to succeed

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-09-20 21:32:03 +02:00
Guillaume Lours
6be5f3003a move watch from alpha to main command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-09-20 18:55:08 +02:00
Guillaume Lours
421a6b0506
Merge pull request #11031 from ndeloof/TestWatch
TestWatch to use new  `develop` section
2023-09-20 18:54:20 +02:00
Nicolas De Loof
c34c306cb9
TestWatch to use new develop section
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-20 18:39:32 +02:00
Nicolas De Loof
5ca35c88be implement publish
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-20 18:14:58 +02:00
Nicolas De loof
805541be9d
watch: use official develop section (#11026)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-20 11:51:53 -04:00
Guillaume Lours
d322ad91e8
Merge pull request #11027 from docker/dependabot/go_modules/github.com/opencontainers/image-spec-1.1.0-rc5
build(deps): bump github.com/opencontainers/image-spec from 1.1.0-rc4 to 1.1.0-rc5
2023-09-20 12:03:40 +02:00
dependabot[bot]
8f489d6d61 build(deps): bump github.com/opencontainers/image-spec
Bumps [github.com/opencontainers/image-spec](https://github.com/opencontainers/image-spec) from 1.1.0-rc4 to 1.1.0-rc5.
- [Release notes](https://github.com/opencontainers/image-spec/releases)
- [Changelog](https://github.com/opencontainers/image-spec/blob/main/RELEASES.md)
- [Commits](https://github.com/opencontainers/image-spec/compare/v1.1.0-rc4...v1.1.0-rc5)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/image-spec
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-20 11:50:03 +02:00
Guillaume Lours
a214a715a0
Merge pull request #11017 from docker/dependabot/go_modules/github.com/moby/buildkit-0.12.2
build(deps): bump github.com/moby/buildkit from 0.12.1 to 0.12.2
2023-09-20 11:39:08 +02:00
dependabot[bot]
9ea8fbc69b build(deps): bump github.com/moby/buildkit from 0.12.1 to 0.12.2
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.12.1 to 0.12.2.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.12.1...v0.12.2)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-20 11:26:04 +02:00
Guillaume Lours
062fa75534
Merge pull request #11020 from docker/dependabot/go_modules/gotest.tools/v3-3.5.1
build(deps): bump gotest.tools/v3 from 3.5.0 to 3.5.1
2023-09-20 10:53:36 +02:00
dependabot[bot]
76f150e49d
build(deps): bump gotest.tools/v3 from 3.5.0 to 3.5.1
Bumps [gotest.tools/v3](https://github.com/gotestyourself/gotest.tools) from 3.5.0 to 3.5.1.
- [Release notes](https://github.com/gotestyourself/gotest.tools/releases)
- [Commits](https://github.com/gotestyourself/gotest.tools/compare/v3.5.0...v3.5.1)

---
updated-dependencies:
- dependency-name: gotest.tools/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-20 08:21:25 +00:00
Guillaume Lours
d45d943e91
Merge pull request #11019 from docker/dependabot/go_modules/google.golang.org/grpc-1.58.1
build(deps): bump google.golang.org/grpc from 1.58.0 to 1.58.1
2023-09-20 10:19:32 +02:00
dependabot[bot]
f447c8096f build(deps): bump google.golang.org/grpc from 1.58.0 to 1.58.1
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.0 to 1.58.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.58.0...v1.58.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-20 10:05:44 +02:00
Guillaume Lours
722796ca28
Merge pull request #11016 from docker/dependabot/go_modules/github.com/containerd/containerd-1.7.6
build(deps): bump github.com/containerd/containerd from 1.7.3 to 1.7.6
2023-09-19 21:31:46 +02:00
dependabot[bot]
4587d4bad5
build(deps): bump github.com/containerd/containerd from 1.7.3 to 1.7.6
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.3 to 1.7.6.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.3...v1.7.6)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-19 09:41:32 +00:00
Nicolas De Loof
a697a0690a introduce pull --missing flag to only pull images not present in cache
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-15 08:41:27 +02:00
Nicolas De Loof
8af49ff369 resolve service reference into container based on observed state
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-14 15:29:50 +02:00
Nicolas De Loof
f6e31dbc6a don't rely on depends_on to resolve volume_from, better use observed state
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-14 15:29:50 +02:00
Guillaume Lours
e19232e8a3
Merge pull request #11000 from thaJeztah/update_golang_1.21.1
update to go1.21.1
2023-09-14 09:50:50 +02:00
Sebastiaan van Stijn
6d5eb6fde6
update to go1.21.1
go1.21.1 (released 2023-09-06) includes four security fixes to the cmd/go,
crypto/tls, and html/template packages, as well as bug fixes to the compiler,
the go command, the linker, the runtime, and the context, crypto/tls,
encoding/gob, encoding/xml, go/types, net/http, os, and path/filepath packages.
See the Go 1.21.1 milestone on our issue tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.21.1+label%3ACherryPickApproved

full diff: https://github.com/golang/go/compare/go1.21.0...go1.21.1

From the security mailing:

[security] Go 1.21.1 and Go 1.20.8 are released

Hello gophers,

We have just released Go versions 1.21.1 and 1.20.8, minor point releases.

These minor releases include 4 security fixes following the security policy:

- cmd/go: go.mod toolchain directive allows arbitrary execution
  The go.mod toolchain directive, introduced in Go 1.21, could be leveraged to
  execute scripts and binaries relative to the root of the module when the "go"
  command was executed within the module. This applies to modules downloaded using
  the "go" command from the module proxy, as well as modules downloaded directly
  using VCS software.

  Thanks to Juho Nurminen of Mattermost for reporting this issue.

  This is CVE-2023-39320 and Go issue https://go.dev/issue/62198.

- html/template: improper handling of HTML-like comments within script contexts
  The html/template package did not properly handle HMTL-like "<!--" and "-->"
  comment tokens, nor hashbang "#!" comment tokens, in <script> contexts. This may
  cause the template parser to improperly interpret the contents of <script>
  contexts, causing actions to be improperly escaped. This could be leveraged to
  perform an XSS attack.

  Thanks to Takeshi Kaneko (GMO Cybersecurity by Ierae, Inc.) for reporting this
  issue.

  This is CVE-2023-39318 and Go issue https://go.dev/issue/62196.

- html/template: improper handling of special tags within script contexts
  The html/template package did not apply the proper rules for handling occurrences
  of "<script", "<!--", and "</script" within JS literals in <script> contexts.
  This may cause the template parser to improperly consider script contexts to be
  terminated early, causing actions to be improperly escaped. This could be
  leveraged to perform an XSS attack.

  Thanks to Takeshi Kaneko (GMO Cybersecurity by Ierae, Inc.) for reporting this
  issue.

  This is CVE-2023-39319 and Go issue https://go.dev/issue/62197.

- crypto/tls: panic when processing post-handshake message on QUIC connections
  Processing an incomplete post-handshake message for a QUIC connection caused a panic.

  Thanks to Marten Seemann for reporting this issue.

  This is CVE-2023-39321 and CVE-2023-39322 and Go issue https://go.dev/issue/62266.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-14 09:29:39 +02:00
Guillaume Lours
9d7e0ad6cb correct scale error messages formatting
Co-authored-by: Milas Bowman <devnull@milas.dev>
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-09-13 11:15:14 +02:00
Guillaume Lours
1a98a70b8a add scale command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-09-13 11:15:14 +02:00
Milas Bowman
19bbb12fac
ci: tweak restricted imports in linter (#10992)
* Eliminate direct dependency on gopkg.in/yaml.v2
* Add gopkg.in/yaml.v2 as a restricted import
* Add github.com/distribution/distribution as a restricted dependency in favor of distribution/reference which is the subset of functionality that Compose needs
* Remove an unused exclusion

NOTE: This does change the `compose config` output slightly but does NOT  change the semantics:
* YAML indentation is slightly different for lists (this is a `v2` / `v3` thing)
* JSON is now "minified" instead of pretty-printed (I think this generally desirable and more consistent with other JSON command outputs)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-09-11 15:53:19 +00:00
Milas Bowman
7a13457853
deps: upgrade Moby to v24.0.6 and gRPC to v1.58.0 (#10991)
There are numerous transitive dependency upgrades as a result here.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-09-11 11:37:42 -04:00
Milas Bowman
13115468d5
cli: fix --build flag for create (#10982)
I missed this during a refactor and there wasn't test coverage.
Instead of adding more heavy-weight integration tests, I tried
to use `gomock` here to assert on the options objects after CLI
flag parsing. I think with a few more helpers, this could be a
good way to get a lot more combinations covered without adding
a ton of slow E2E tests.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-09-08 11:35:57 -04:00
Rory
e1aa4f779b
otel: add args & flags to cli traces (#10974)
Signed-off-by: rvigus <roryvigus@gmail.com>
2023-09-07 16:04:36 -04:00
Milas Bowman
d7b0b2bd7d
watch: build & launch the project at start (#10957)
The `alpha watch` command current "attaches" to an already-running
Compose project, so it's necessary to run something like
`docker compose up --wait` first.

Now, we'll do the equivalent of an `up --build` before starting the
watch, so that we know the project is up-to-date and running.

Additionally, unlike an interactive `up`, the services are not stopped
when `watch` exits (e.g. via `Ctrl-C`). This prevents the need to start
from scratch each time the command is run - if some services are already
running and up-to-date, they can be used as-is. A `down` can always be
used to destroy everything, and we can consider introducing a flag like
`--down-on-exit` to `watch` or changing the default.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-09-07 13:27:23 -04:00
Nicolas De Loof
e0f39ebbef pull OCI remote resource
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-07 07:27:32 +02:00
Nicolas De Loof
c9d54f09cf introduce publish (alpha) command
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-07 07:27:32 +02:00
Guillaume Lours
aeb835a525
Merge pull request #10966 from kumarlokesh/patch-1
doc: updated README.md to remove broken link
2023-09-04 21:47:05 +02:00
Lokesh Kumar
52e54ef910
doc: updated README.md to remove broken link
- Removed the broken link in README.md file about `backward compatibility`.
- The section 
`# About update and backward compatibility` was removed in an earlier PR (https://github.com/docker/compose/pull/10889/files).

Signed-off-by: Lokesh Kumar <lkumar94@gmail.com>
2023-09-04 20:57:41 +02:00
Guillaume Lours
203bce883c
Merge pull request #10954 from thaJeztah/swap_reference
migrate to github.com/distribution/reference
2023-09-04 17:46:16 +02:00
Sebastiaan van Stijn
f4f2e934ac
migrate to github.com/distribution/reference
The "reference" package was moved to a separate module, which was extracted
from b9b19409cf

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-04 14:36:36 +02:00
Nicolas De Loof
32c3d0a3ff Enable service explicitly requested to be restarted
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-09-01 12:01:02 +02:00
Milas Bowman
1fdbcb6255 build: pass BuildOptions around explicitly & fix multi-platform issues
The big change here is to pass around an explicit `*BuildOptions` object
as part of Compose operations like `up` & `run` that may or may not do
builds. If the options object is `nil`, no builds whatsoever will be
attempted.

Motivation is to allow for partial rebuilds in the context of an `up`
for watch. This was broken and tricky to accomplish because various parts
of the Compose APIs mutate the `*Project` for convenience in ways that
make it unusable afterwards. (For example, it might set `service.Build = nil`
because it's not going to build that service right _then_. But we might
still want to build it later!)

NOTE: This commit does not actually touch the watch logic. This is all
      in preparation to make it possible.

As part of this, a bunch of code moved around and I eliminated a bunch
of partially redundant logic, mostly around multi-platform. Several
edge cases have been addressed as part of this:
 * `DOCKER_DEFAULT_PLATFORM` was _overriding_ explicitly set platforms
   in some cases, this is no longer true, and it behaves like the Docker
   CLI now
 * It was possible for Compose to build an image for one platform and
   then try to run it for a different platform (and fail)
 * Errors are no longer returned if a local image exists but for the
   wrong platform - the correct platform will be fetched/built (if
   possible).

Because there's a LOT of subtlety and tricky logic here, I've also tried
to add an excessive amount of explanatory comments.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-09-01 08:32:56 +02:00
Milas Bowman
407a0d5b53
up: fix various race/deadlock conditions on exit (#10934)
If running `up` in foreground mode (i.e. not `-d`),
when exiting via `Ctrl-C`, Compose stops all the
services it launched directly as part of that `up`
command.

In one of the E2E tests (`TestUpDependenciesNotStopped`),
this was occasionally flaking because the stop
behavior was racy: the return might not block on
the stop operation because it gets added to the
error group in a goroutine. As a result, it was
possible for no services to get terminated on exit.

There were a few other related pieces here that
I uncovered and tried to fix while stressing this.
For example, the printer could cause a deadlock if
an event was sent to it after it stopped.

Also, an error group wasn't really appropriate here;
each goroutine is a different operation for printing,
signal-handling, etc. If one part fails, we don't
actually want printing to stop, for example. This has
been switched to a `multierror.Group`, which has the
same API but coalesces errors instead of canceling a
context the moment the first one fails and returning
that single error.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-31 10:47:14 -04:00
Milas Bowman
d0dfb848df
Merge pull request #10953 from thaJeztah/drop_uuid
pkg/api: replace uuid for basic random id
2023-08-31 10:43:34 -04:00
Sebastiaan van Stijn
8caa6f1f3e
pkg/api: replace uuid for basic random id
The uuid package in distribution was created as a utility for the distribution
project itself, to cut down external dependencies (see [1][1]).

For compose, this has the reverse effect, as it now brings all the dependencies
of the distribution module with it.

This patch switches to the uuid generation to crypto/rand to produce a random
id. I was considering using a different uuid implementation, or docker's
"stringid.GenerateRandomID", but all of those are doing more than needed,
so keep it simple.

Currently, this change has little effect, because compose also uses the
distribution module for other purposes, but the distribution project is
in the process of moving the "reference" package to a separate module,
in which case we don't want to depend on the distribution module only for
the uuid package.

[1]: 36e34a55ad

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-31 10:13:32 +02:00
Milas Bowman
d6f842b042
test: e2e test reliability improvements (#10950)
* Use unique project name prefixes (some of these tests assert
  on output using the project name as a magic string, so could
  be impacted by other tests with the same project name prefix)
* Tear down port range project before starting to try and avoid
  race conditions with the engine and port assignment

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-30 16:01:15 -04:00
Milas Bowman
4fbbf201cd
build(deps): upgrade to compose-go v1.18.3 (#10947)
https://github.com/compose-spec/compose-go/releases/tag/v1.18.3

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-30 09:17:57 -04:00
Bilal Khan
935d72f46f added the dot at the end of the sentence
Signed-off-by: Bilal Khan <bilalkhanrecovered@gmail.com>
2023-08-28 09:19:26 +02:00
Nicolas De Loof
41682acc77 add support for attributes exposed by docker ps
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-08-25 16:36:45 +02:00
Nicolas De Loof
1054792b47 align docker compose ps with docker CLI to support --format
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-08-25 16:36:45 +02:00
Milas Bowman
19f66918cc watch: only allow a single instance per-project
This is a good place to start introducing (local) exclusivity
to Compose. Now, when `alpha watch` launches, it will check for
the existence of a PID file in the user XDG runtime directory,
and create one if the existing one is stale or does not exist.
If the PID file exists and is valid, an error is returned and
Compose exits.

A slight tweak to the experimental remote Git loader has been
made to use the XDG package for consistency.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-25 15:49:28 +02:00
Milas Bowman
186744e034 ci: bump golangci-lint to v1.54.2
Also improve incremental lint caching.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-24 08:57:47 +02:00
Milas Bowman
bc9d696fa0
Merge pull request #10922 from thaJeztah/replace_dockerignore
replace dockerfile/dockerignore with patternmatcher/ignorefile
2023-08-23 16:04:19 -04:00
Nicolas De loof
6204fb1c94
logs: fix for missing output on container exit (#10925)
We can't assume we receive container logs line by line. Some framework won't buffer output and will send char by char, and we also can receive looong lines which get buffered to 32kb and then cut into multiple logs.

This assumes we will catch container streams being closed before we receive a die event for container, which could be subject to race condition, but at least the impact here is minimal and the fix works for reproduction examples provided in linked issues.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-08-23 08:57:18 -04:00
Sebastiaan van Stijn
5d732010a7
replace dockerfile/dockerignore with patternmatcher/ignorefile
The BuildKit dockerignore package was integrated in the patternmatcher
repository / module. This patch updates our uses of the BuildKit package
with its new location.

A small local change was made to keep the format of the existing error message,
because the "ignorefile" package is slightly more agnostic in that respect
and doesn't include ".dockerignore" in the error message.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 00:43:17 +02:00
Sebastiaan van Stijn
2006f3fe7d
go.mod: github.com/moby/patternmatcher v0.6.0
- integrate frontend/dockerfile/dockerignore from buildkit

full diff: https://github.com/moby/patternmatcher/compare/v0.5.0...v0.6.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 00:40:12 +02:00
Sebastiaan van Stijn
192718c001
go.mod: remove some outdated comments
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 00:39:35 +02:00
Milas Bowman
c79f67fead otel: add include to project up span
Flatten the list of included files and add as a slice attribute.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-22 16:10:18 +02:00
dependabot[bot]
3b294bfdda
build(deps): bump github.com/compose-spec/compose-go from 1.18.1 to 1.18.2 (#10915)
build(deps): bump github.com/compose-spec/compose-go

Bumps [github.com/compose-spec/compose-go](https://github.com/compose-spec/compose-go) from 1.18.1 to 1.18.2.
- [Release notes](https://github.com/compose-spec/compose-go/releases)
- [Commits](https://github.com/compose-spec/compose-go/compare/v1.18.1...v1.18.2)

---
updated-dependencies:
- dependency-name: github.com/compose-spec/compose-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-21 14:02:03 -04:00
Nicolas De loof
dd34f7a22b
include: add experimental support for Git resources (#10811)
Requires setting `COMPOSE_EXPERIMENTAL_GIT_REMOTE=1`.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-08-18 09:16:45 -04:00
Milas Bowman
caad72713b up: handle various attach use cases better
By default, `compose up` attaches to all services (i.e.
shows log output from every associated container). If
a service is specified, e.g. `compose up foo`, then
only `foo`'s logs are tailed. The `--attach-dependencies`
flag can also be used, so that if `foo` depended upon
`bar`, then `bar`'s logs would also be followed. It's
also possible to use `--no-attach` to filter out one
or more services explicitly, e.g. `compose up --no-attach=noisy`
would launch all services, including `noisy`, and would
show log output from every service _except_ `noisy`.
Lastly, it's possible to use `up --attach` to explicitly
restrict to a subset of services (or their dependencies).

How these flags interact with each other is also worth
thinking through.

There were a few different connected issues here, but
the primary issue was that running `compose up foo` was
always attaching dependencies regardless of `--attach-dependencies`.

The filtering logic here has been updated so that it
behaves predictably both when launching all services
(`compose up`) or a subset (`compose up foo`) as well
as various flag combinations on top of those.

Notably, this required making some changes to how it
watches containers. The logic here between attaching
for logs and monitoring for lifecycle changes is
tightly coupled, so some changes were needed to ensure
that the full set of services being `up`'d are _watched_
and the subset that should have logs shown are _attached_.
(This does mean faking the attach with an event but not
actually doing it.)

While handling that, I adjusted the context lifetimes
here, which improves error handling that gets shown to
the user and should help avoid potential leaks by getting
rid of a `context.Background()`.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-18 12:38:38 +02:00
Nicolas De loof
792afb8d13
build: use correct values for proxy variables (#10908)
clone variable before we capture a pointer

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-08-17 14:25:28 -04:00
Nicolas De Loof
150449bbd2 warn user secret uid/gid/mode is not supported
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-08-16 19:17:28 +02:00
Guillaume Lours
8d0df18762
Merge pull request #10867 from docker/dependabot/go_modules/github.com/moby/buildkit-0.12.1
build(deps): bump github.com/moby/buildkit from 0.12.1-0.20230717122532-faa0cc7da353 to 0.12.1
2023-08-11 10:45:05 +02:00
dependabot[bot]
5b53f8e47f
build(deps): bump github.com/moby/buildkit
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.12.1-0.20230717122532-faa0cc7da353 to 0.12.1.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/commits/v0.12.1)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-11 08:28:23 +00:00
Guillaume Lours
c5fef61383
Merge pull request #10893 from glours/bump-compose-go-v1.18.1
bump compose-go to version v1.18.1
2023-08-10 21:08:07 +02:00
Guillaume Lours
ce3cb2b00c
bump compose-go to version v1.18.1
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-08-10 20:51:22 +02:00
Guillaume Lours
d9e73db8e6
Merge pull request #10891 from glours/bump-compose-go-v1.18.0
bump compose-go to version v1.18.0
2023-08-10 17:13:53 +02:00
Guillaume Lours
d6b4d1c755
bump compose-go to version v1.18.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-08-10 17:00:32 +02:00
Guillaume Lours
0baf24a269
Merge pull request #10890 from glours/bump-golang-1.21
upgrade Golang to 1.21
2023-08-10 15:22:50 +02:00
Guillaume Lours
0511b0c2b8
Merge pull request #10878 from relrelb/profiles_completion
Add shell completion for `--profile`
2023-08-10 15:16:24 +02:00
Guillaume Lours
5bbdf3d84a
Merge pull request #10879 from relrelb/project_directory_completion
Improve shell completion for `--project-directory`
2023-08-10 15:15:58 +02:00
Guillaume Lours
52103cce74 update README and CI workflows to match main branch
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-08-10 15:11:27 +02:00
Guillaume Lours
020b57ca31
upgrade Golang to 1.21
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-08-10 15:07:09 +02:00
Milas Bowman
bfa54081d4
build: fix missing proxy build args for classic builder (#10887)
Refactor to use a consistent code path for determining the build
args for a service image regardless of whether BuildKit or the
classic builder is being used.

After recent changes, these code paths had diverged, so the classic
builder was missing the proxy variables from the Docker client
config.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-10 08:57:28 -04:00
Milas Bowman
0be8e4a676
trace: do not block connecting to OTLP endpoint (#10882)
This was left over from debugging, but we should not block.
OTel will handle the connection in the background.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-08 15:47:18 -04:00
Milas Bowman
fd8ab2f7ac
watch: enable tar-based syncer by default (#10877)
Swap the default implementation now that batching is merged.
Keeping the `docker cp` based implementation around for the
moment, but it needs to be _explicitly_ disabled now by setting
`COMPOSE_EXPERIMENTAL_WATCH_TAR=0`.

After the next release, we should remove the `docker cp`
implementation entirely.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-04 16:58:01 -04:00
Guillaume Lours
b406b393bf
Merge pull request #10881 from silvin-lubecki/display-builder-name
Display builder's name on the first build line.
2023-08-04 17:36:18 +02:00
Silvin Lubecki
0a9d1277c5 Display builder's name on the first build line.
Code borrowed from buildx commands/build.go.

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2023-08-04 17:11:44 +02:00
Milas Bowman
c350f80d4b
up: do not warn on successful optional dependency complete (#10870)
If an optional dependency exits successfully (exit code of 0),
with a service condition of `service_completed_successfully`,
don't log a warning.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 21:00:49 +00:00
relrelb
8a4095b507 Improve shell completion for --project-directory
Signed-off-by: Ariel Bachar <relrelb@users.noreply.github.com>
Signed-off-by: relrelb <relrelb@users.noreply.github.com>
2023-08-03 23:40:56 +03:00
relrelb
0345461412 Add shell completion for --profile
Signed-off-by: Ariel Bachar <relrelb@users.noreply.github.com>
Signed-off-by: relrelb <relrelb@users.noreply.github.com>
2023-08-03 23:09:13 +03:00
Milas Bowman
80856eacaf
progress: minor correctness fixes (#10871)
* When waiting for dependencies, `select` on the context as well
  as the ticker
* Write multiple progress events "transactionally" (i.e. hold the
  lock for the duration to avoid other events being interleaved)
* Do not change "finished" steps back to "in progress" to prevent
  flickering

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 15:14:17 -04:00
Praful Gupta
d7b1972d5e
doc: update Config() comment in API Service interface (#10840)
Update Config comment in Service interface

Signed-off-by: Praful Gupta <prafulgupta6@gmail.com>
2023-08-03 15:13:26 -04:00
Silvin Lubecki
7c42776770
Improve buildkit node creation (#10843)
Move builder and nodes initialization code up, avoiding to recreate/load them for every service build.

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2023-08-03 15:11:16 -04:00
Milas Bowman
3b0742fd57
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.

When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.

Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
Milas Bowman
efd44de1b7
watch: support multiple containers for tar implementation (#10860)
Support services with scale > 1 for the tar watch sync.

Add a "lossy" multi-writer specific to pipes that writes the
tar data to each `io.PipeWriter`, which is connected to `stdin`
for the `tar` process being exec'd in the container.

The data is written serially to each writer. This could be
adjusted to do concurrent writes but that will rapidly increase
the I/O load, so is not done here - in general, 99% of the
time you'll be developing (and thus using watch/sync) with a
single replica of a service.

If a write fails, the corresponding `io.PipeWriter` is removed
from the active set and closed with an error.

This means that a single container copy failing won't stop
writes to the others that are succeeding. Of course, they will
be in an inconsistent state afterwards still, but that's a
different problem.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:52:39 -04:00
Milas Bowman
bdb3f91eb4
test: temporarily disable an exit-code-from Cucumber test case (#10875)
Something is wrong here, disabling while we investigate.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:49:59 -04:00
Milas Bowman
f94cb49062
test: fix e2e test for privileged builds (#10873)
We cannot guarantee the exact value of `CapEff` across
environments, and this test has started failing some places,
e.g. Docker Desktop, and now GitHub Actions (likely due to
a kernel upgrade on the runners or similar).

By setting `privileged: true` on the build, we're asking for
the `security.insecure` entitlement on the build. A safe
assumption is that will include `CAP_SYS_ADMIN`, which won't
be present otherwise, so mask the `CapEff` value and check
for that.

It's worth noting that realistically, the build won't even
be able to complete without the correct entitlement, since the
`Dockerfile` uses `RUN --security=insecure`, so this is really
an additional sanity check.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 12:23:24 -04:00
Milas Bowman
e7ed070690
Merge pull request #10861 from thaJeztah/update_go1.20.7
update to go1.20.7
2023-08-02 10:08:37 -04:00
Sebastiaan van Stijn
8a1bf5d28b
update to go1.20.7
Includes a fix for CVE-2023-29409

go1.20.7 (released 2023-08-01) includes a security fix to the crypto/tls
package, as well as bug fixes to the assembler and the compiler. See the
Go 1.20.7 milestone on our issue tracker for details:

- https://github.com/golang/go/issues?q=milestone%3AGo1.20.7+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.20.6...go1.20.7

From the mailing list announcement:

[security] Go 1.20.7 and Go 1.19.12 are released

Hello gophers,

We have just released Go versions 1.20.7 and 1.19.12, minor point releases.

These minor releases include 1 security fixes following the security policy:

- crypto/tls: restrict RSA keys in certificates to <= 8192 bits

  Extremely large RSA keys in certificate chains can cause a client/server
  to expend significant CPU time verifying signatures. Limit this by
  restricting the size of RSA keys transmitted during handshakes to <=
  8192 bits.

  Based on a survey of publicly trusted RSA keys, there are currently only
  three certificates in circulation with keys larger than this, and all
  three appear to be test certificates that are not actively deployed. It
  is possible there are larger keys in use in private PKIs, but we target
  the web PKI, so causing breakage here in the interests of increasing the
  default safety of users of crypto/tls seems reasonable.

  Thanks to Mateusz Poliwczak for reporting this issue.

View the release notes for more information:
https://go.dev/doc/devel/release#go1.20.7

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-02 00:22:13 +02:00
dependabot[bot]
7ef392004f
build(deps): bump github.com/docker/docker from 24.0.5-0.20230714235725-36e9e796c6fc+incompatible to 24.0.5+incompatible (#10844)
build(deps): bump github.com/docker/docker

Bumps [github.com/docker/docker](https://github.com/docker/docker) from 24.0.5-0.20230714235725-36e9e796c6fc+incompatible to 24.0.5+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/commits/v24.0.5)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 18:46:15 +00:00
dependabot[bot]
f34f5b4d26
build(deps): bump github.com/containerd/containerd from 1.7.2 to 1.7.3 (#10850)
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.2 to 1.7.3.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.2...v1.7.3)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 14:41:57 -04:00
dependabot[bot]
b0484700da
build(deps): bump google.golang.org/grpc from 1.56.2 to 1.57.0 (#10847)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.56.2 to 1.57.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.56.2...v1.57.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 14:40:31 -04:00
Milas Bowman
f65fd02383
watch: add tar sync implementation (#10853)
Brought to you by Tilt ❤️ 

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-01 14:39:08 -04:00
Milas Bowman
cf8dc46560
Merge pull request #10845 from docker/dependabot/go_modules/github.com/docker/cli-24.0.5incompatible
build(deps): bump github.com/docker/cli from 24.0.4+incompatible to 24.0.5+incompatible
2023-08-01 14:29:27 -04:00
dependabot[bot]
2cfbe63533
build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 24.0.4+incompatible to 24.0.5+incompatible.
- [Commits](https://github.com/docker/cli/compare/v24.0.4...v24.0.5)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-25 09:25:44 +00:00
Guillaume Lours
8318f66330
Merge pull request #10791 from milas/watch-refactor-sync
watch: move sync logic into separate package
2023-07-19 13:11:24 +02:00
Milas Bowman
cb17c3c8a6 watch: move sync logic into separate package
Just moving some code around in preparation for an alternative
sync implementation that can do bulk transfers by using `tar`.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-07-19 12:25:13 +02:00
Guillaume Lours
9174a99d27
Merge pull request #10828 from thaJeztah/minor_cli_changes
pkg/compose: RunOneOffContainer: don't use NewStartOptions()
2023-07-19 12:24:37 +02:00
Sebastiaan van Stijn
4eb43c53fa pkg/compose: RunOneOffContainer: don't use NewStartOptions()
It's no longer used in docker/cli, and doesn't do anything other than
creating an empty struct, so replacing it (as we're planning to
deprecate that function)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-19 12:13:40 +02:00
Guillaume Lours
150b88ab5d
Merge pull request #10829 from milas/e2e-watch-test-fix
test: watch e2e reliability tweaks
2023-07-19 12:07:10 +02:00
Guillaume Lours
5159058c7e
Merge pull request #10831 from milas/instrument-up
trace: instrument `compose up` at a high-level
2023-07-19 12:06:56 +02:00
Milas Bowman
1ae191a936 trace: instrument compose up at a high-level
* Image pull
* Image build
* Service apply
  * Scale down/up (event)
  * Recreate container (event)
  * Scale up (event)
  * Container start (event)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-07-19 11:26:12 +02:00
Guillaume Lours
3b2f3cdce3
Merge pull request #10819 from ndeloof/windows_abs
check secret target is an absolute windows path
2023-07-19 11:24:45 +02:00
Nicolas De Loof
47778f8b77 check secret target is an absolute windows path
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-07-19 10:57:22 +02:00
Guillaume Lours
7d88edaf24
Merge pull request #10814 from milas/fix-build-push
build: do not attempt to push unnamed service images
2023-07-19 10:57:00 +02:00
Milas Bowman
636c13f818 build: do not attempt to push unnamed service images
When building, if images are being pushed, ensure that only
named images (i.e. services with a populated `image` field)
are attempted to be pushed.

Services without `image` get an auto-generated name, which
will be a "Docker library" reference since they're in the
format `$project-$service`, which is implicitly the same as
`docker.io/library/$project-$service`. A push for that is
never desirable / will always fail.

The key here is that we cannot overwrite the `<svc>.image`
field when doing builds, as we need to be able to check for
its presence to determine whether a push makes sense.

Fixes #10813.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-07-19 09:58:37 +02:00
Guillaume Lours
5a072b1ad5
Merge pull request #10792 from glours/add-depends_on-required
add support of depends_on.required attribute
2023-07-19 09:53:49 +02:00
Milas Bowman
ddceb1ac9d test: do not run watch e2e tests in parallel
This isn't playing nicely with the GHA CI runner.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-07-18 18:54:23 -04:00
Milas Bowman
d48f28c72c test: skip watch e2e test on macOS for the moment
Fix forthcoming via https://github.com/compose-spec/compose-go/pull/436
which addresses some symlink limitations. These can
actually effect other platforms but are most common
on macOS because the test creates temporary directories,
which are symlinked on macOS.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-07-18 18:53:26 -04:00
Guillaume Lours
2d16a05afa
only check if a dependency is required when something unexpected happens
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-07-18 23:45:31 +02:00
Guillaume Lours
bb94ea034e add support of depends_on.required attribute
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-07-18 23:13:47 +02:00
Milas Bowman
0938c7e96f
Merge pull request #10827 from thaJeztah/bump_buildx_buildkit
go.mod: buildx v0.11.2, buildkit v0.12, docker/cli v24.0.5-dev
2023-07-18 16:43:24 -04:00
Sebastiaan van Stijn
f429ee958a
go.mod: github.com/docker/docker v24.0.5-dev (tip of 24 release branch)
full diff: 8443a06149...f329397077

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-18 22:25:50 +02:00
Sebastiaan van Stijn
e9ded2c518
go.mod: github.com/docker/buildx v0.11.2
full diff:

- https://github.com/docker/buildx/compare/v0.11.1...v0.11.2
- https://github.com/moby/buildkit/v0.12.0...faa0cc7da353

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-18 21:57:42 +02:00
Sebastiaan van Stijn
54e6e0bd8f
go.mod: github.com/moby/buildkit v0.12.0
Switching to back to released versions / release-branche. The old version
was a commit from master (v0.12.0-dev).

full diff:

- https://github.com/moby/buildkit/compare/2d91ddcceedc...v0.12.0
- https://github.com/tonistiigi/fsutil/compare/9e7a6df48576...36ef4d8c0dbb

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-18 21:54:49 +02:00
Milas Bowman
3bc871e64b test: speed up the e2e test suite
Lots of our phony Compose files launch pointless long-lived processes
so we can assert on state. However, this means they often don't respond
well to signals on their own, requiring Compose to timeout and kill
them when doing a `down`.

Add in lots of `init: true` where appropriate so that we don't block
for no reason while running E2E tests all over the place.

Additionally, a couple tests have gotten a cleanup so they don't leave
behind containers. I still want to build this into the framework in
the future, but this is easier for the moment and won't cause any
trouble in the future.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-07-18 11:08:06 +02:00
Milas Bowman
6ff15d9472
Merge pull request #10812 from thaJeztah/update_go_1.20.6
update go to go1.20.6
2023-07-17 12:08:05 -04:00
Sebastiaan van Stijn
49bc0603e3
update go to go1.20.6
go1.20.6 (released 2023-07-11) includes a security fix to the net/http package,
as well as bug fixes to the compiler, cgo, the cover tool, the go command,
the runtime, and the crypto/ecdsa, go/build, go/printer, net/mail, and text/template
packages. See the Go 1.20.6 milestone on our issue tracker for details.

https://github.com/golang/go/issues?q=milestone%3AGo1.20.6+label%3ACherryPickApproved

Full diff: https://github.com/golang/go/compare/go1.20.5...go1.20.6

These minor releases include 1 security fixes following the security policy:

net/http: insufficient sanitization of Host header

The HTTP/1 client did not fully validate the contents of the Host header.
A maliciously crafted Host header could inject additional headers or entire
requests. The HTTP/1 client now refuses to send requests containing an
invalid Request.Host or Request.URL.Host value.

Thanks to Bartek Nowotarski for reporting this issue.

Includes security fixes for [CVE-2023-29406 ][1] and Go issue https://go.dev/issue/60374

[1]: https://github.com/advisories/GHSA-f8f7-69v5-w4vx

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-17 17:35:48 +02:00
Sebastiaan van Stijn
ce8a09b53f
go.mod: github.com/docker/docker 8443a06149b5 (v24.0.5-dev) (#10810)
relevant changes:

- client: define a "dummy" hostname to use for local connections
  fixes "http: invalid Host header" errors when compiling with
  go1.20.6 or go1.19.11

full diff: https://github.com/docker/docker/compare/v24.0.4...8443a06149b5ba9c0763b92f832698474bcf2a13

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-17 10:47:52 -04:00
Milas Bowman
3dc8734897
watch: add end-to-end test (#10801)
Add an end-to-end test that covers the core watch functionality,
i.e. CRUD on files & directories.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-07-17 10:47:36 -04:00
Guillaume Lours
852e192820
bump buildkit to version v0.11.0-rc3.0.20230620112432-2d91ddcceedc (#10794)
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-07-12 08:23:02 -04:00
dependabot[bot]
d9e7859664
build(deps): bump github.com/docker/cli from 24.0.2+incompatible to 24.0.4+incompatible (#10799)
build(deps): bump github.com/docker/cli

Bumps [github.com/docker/cli](https://github.com/docker/cli) from 24.0.2+incompatible to 24.0.4+incompatible.
- [Commits](https://github.com/docker/cli/compare/v24.0.2...v24.0.4)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-12 08:21:46 -04:00
Guillaume Lours
e28b223650
Merge pull request #10793 from milas/dockerfile-cache-mounts
ci: speed up a couple Dockerfile targets w/ cache mount
2023-07-10 19:26:41 +02:00
Milas Bowman
1964693074 ci: speed up a couple Dockerfile targets w/ cache mount
The local Go package module path was missing from a couple of jobs,
which made them slower than needed since they were re-downloading
a bunch of dependencies.

In particular, this makes `make lint` waaaay faster!

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-07-10 13:13:10 -04:00
Guillaume Lours
dc74e6aa0e
Merge pull request #10776 from docker/dependabot/go_modules/github.com/docker/buildx-0.11.1
build(deps): bump github.com/docker/buildx from 0.11.0 to 0.11.1
2023-07-10 18:15:39 +02:00
dependabot[bot]
b182cf6850
build(deps): bump github.com/docker/buildx from 0.11.0 to 0.11.1
Bumps [github.com/docker/buildx](https://github.com/docker/buildx) from 0.11.0 to 0.11.1.
- [Release notes](https://github.com/docker/buildx/releases)
- [Commits](https://github.com/docker/buildx/compare/v0.11.0...v0.11.1)

---
updated-dependencies:
- dependency-name: github.com/docker/buildx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-10 15:51:31 +00:00
Guillaume Lours
f330b24632
Merge pull request #10788 from docker/dependabot/go_modules/github.com/docker/docker-24.0.4incompatible
build(deps): bump github.com/docker/docker from 24.0.2+incompatible to 24.0.4+incompatible
2023-07-10 17:49:45 +02:00
Guillaume Lours
8339269e13
Merge pull request #10789 from ndeloof/run_no_deps
Apply no-deps before we select and mutate target service
2023-07-10 15:46:01 +02:00
Guillaume Lours
ee6aeed84e
Merge pull request #10700 from ndeloof/attach
support `attach`
2023-07-10 15:17:44 +02:00
Guillaume Lours
7a9dfa4284
Merge pull request #10790 from milas/e2e-process-leak
test: fix process leak in wait e2e test
2023-07-10 15:09:41 +02:00
Guillaume Lours
29daae3d6e
Merge pull request #10784 from shantanoo-desai/v2
fix(secrets): file permission value does not comply with spec
2023-07-10 14:54:16 +02:00
Milas Bowman
8dea7b5cae test: fix process leak in wait e2e test
* Run `down` before and after test to not leave around containers
* Kill the `wait` process that's waiting on `infinity`
  * NOTE: If the test is actually working, this should exit once
    the `down` happens, but this ensures that we kill everything
    we start

I'd like to generalize more of this into the framework, but this
is a quick fix to prevent filling up CI machines with tons of
processes over time.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-07-10 08:42:09 -04:00
Guillaume Lours
bc6ad2e4a4
Merge pull request #10764 from docker/dependabot/go_modules/github.com/opencontainers/image-spec-1.1.0-rc4
build(deps): bump github.com/opencontainers/image-spec from 1.1.0-rc3 to 1.1.0-rc4
2023-07-10 14:39:44 +02:00
Nicolas De Loof
e6a7694b8d
Apply no-deps before we select and mutate target service
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-07-10 14:37:42 +02:00
Nicolas De Loof
46d936c750 support attach
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-07-10 14:34:28 +02:00
dependabot[bot]
15bc7850bb build(deps): bump github.com/opencontainers/image-spec
Bumps [github.com/opencontainers/image-spec](https://github.com/opencontainers/image-spec) from 1.1.0-rc3 to 1.1.0-rc4.
- [Release notes](https://github.com/opencontainers/image-spec/releases)
- [Changelog](https://github.com/opencontainers/image-spec/blob/main/RELEASES.md)
- [Commits](https://github.com/opencontainers/image-spec/compare/v1.1.0-rc3...v1.1.0-rc4)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/image-spec
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-10 14:17:14 +02:00
Guillaume Lours
8a64ab56a0
Merge pull request #10760 from docker/dependabot/go_modules/gotest.tools/v3-3.5.0
build(deps): bump gotest.tools/v3 from 3.4.0 to 3.5.0
2023-07-10 14:16:34 +02:00
dependabot[bot]
1178c51e6a build(deps): bump gotest.tools/v3 from 3.4.0 to 3.5.0
Bumps [gotest.tools/v3](https://github.com/gotestyourself/gotest.tools) from 3.4.0 to 3.5.0.
- [Release notes](https://github.com/gotestyourself/gotest.tools/releases)
- [Commits](https://github.com/gotestyourself/gotest.tools/compare/v3.4.0...v3.5.0)

---
updated-dependencies:
- dependency-name: gotest.tools/v3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-10 12:40:37 +02:00
dependabot[bot]
3b3fd3e56c
build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 24.0.2+incompatible to 24.0.4+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v24.0.2...v24.0.4)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-10 10:39:23 +00:00
Guillaume Lours
b1e10f559e
Merge pull request #10781 from milas/deps-docs-0.6
deps: bump docker/cli-docs-tool to v0.6.0
2023-07-10 12:38:04 +02:00
Milas Bowman
baea5a48f5 deps: bump docker/cli-docs-tool to v0.6.0
Required re-running `make docs` to pick up changes.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-07-10 12:23:48 +02:00
Guillaume Lours
cb3a6ce52b
Merge pull request #10787 from docker/dependabot/go_modules/google.golang.org/grpc-1.56.2
build(deps): bump google.golang.org/grpc from 1.56.0 to 1.56.2
2023-07-10 12:23:25 +02:00
dependabot[bot]
28f3802a07
build(deps): bump google.golang.org/grpc from 1.56.0 to 1.56.2
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.56.0 to 1.56.2.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.56.0...v1.56.2)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-10 09:23:22 +00:00
Shan Desai
fd0e0a2cbd
fix(secrets): file permission value does not comply with spec
closes #10783

Compose Spec mentions that default values for secrets is `0444` aka. world-readable permissions. However, the value was previously set to `0400`. 


Signed-off-by: Shan Desai <shantanoo.desai@gmail.com>
2023-07-07 18:58:21 +02:00
Guillaume Lours
e90df62bb0
Merge pull request #10763 from ndeloof/exec_index
when --index is not set select first service container
2023-07-07 14:39:50 +02:00
Nicolas De Loof
b0af2deb2b when --index is not set select first service container
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-07-07 14:08:24 +02:00
Milas Bowman
be22bc735a network: fix random missing network when service has more than one
As part of the fix for #10668, the logic was adjusted so that the
default (highest-priority) network is used in the `ContainerCreate`,
and then the remaining networks are connected via calls to
`NetworkConnect` before starting the container.

Unfortunately, `ServiceConfig::NetworksByPriority` is neither
deterministic nor stable when networks have the same priority.

It's non-deterministic because the order of networks from parsing
YAML is random, since they are loaded into a Go map (which have
random iteration order). Additionally, it's not using a `SortStable`
in `compose-go`, so even if the load order was predictable, it
still might produce different results.

While I look at improving `compose-go` here to prevent this from
tripping us up in the future, this fix looks at _all_ networks for
a service and ignores the "default" one now. Before, it would
always skip the first one in the slice since that _should_ have
been the "default".

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-07-07 09:18:01 +02:00
Nicolas De Loof
b5f5e27597 don't use unitialized cli to setup DryRunClient
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-07-06 14:27:57 +02:00
Guillaume Lours
b1334b8dfc
Merge pull request #10768 from cloud-native-team/v2
fix some comments
2023-07-06 10:06:05 +02:00
cui fliter
25ca75db4d fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-07-04 11:34:49 +08:00
Guillaume Lours
827e864ed0
Merge pull request #10745 from glours/add-builder-support
add support of --builder and BUILDX_BUILDER
2023-07-03 10:46:02 +02:00
Guillaume Lours
28301fb1a4 add support of --builder and BUILDX_BUILDER
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-07-03 10:11:18 +02:00
Ulysses Souza
fa3e16c66b
Merge pull request #10742 from ulyssessouza/add-wait
Add `docker compose wait`
2023-07-02 13:54:34 +02:00
Ulysses Souza
edd76bfd70 Add docker compose wait
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2023-06-30 16:07:03 +02:00
Milas Bowman
c496c23071
ci: upgrade compose-go to v1.15.1 (#10757)
* Fix for "`build.context` is required" errors

https://github.com/compose-spec/compose-go/releases/tag/v1.15.1

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-06-29 16:50:10 -04:00
Guillaume Lours
02284378bf
Merge pull request #10756 from milas/network-race
up: fix race condition on network connect
2023-06-29 22:47:29 +02:00
Milas Bowman
10b290e682 up: fix race condition on network connect
Engine API only allows at most one network to be connected as
part of the ContainerCreate API request. Compose will pick the
highest priority network.

Afterwards, the remaining networks (if any) are connected before
the container is actually started.

The big change here is that, previously, the highest-priority
network was connected in the create, and then disconnected and
immediately reconnected along with all the others. This was
racy because evidently connecting the container to the network
as part of the create isn't synchronous, so sometimes when Compose
tried to disconnect it, the API would return an error like:
```
container <id> is not connected to the network <network>
```

To avoid needing to disconnect and immediately reconnect, the
network config logic has been refactored to ensure that it sets
up the network config correctly the first time.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-06-29 16:00:55 -04:00
aroramrinaal
3906a7a67c Updated documentation files for my contribution
Ran 'make docs' to generate updated doc files from the reference.

Signed-off-by: aroramrinaal <aroramrinaal@gmail.com>
2023-06-27 22:48:17 +02:00
aroramrinaal
83671db3dd Fix capitalization error in sentence by adding an uppercase letter at beginning
Signed-off-by: aroramrinaal <aroramrinaal@gmail.com>
2023-06-27 22:48:17 +02:00
Jes Cok
1a41678c58 fix typos
Signed-off-by: Jes Cok <xigua67damn@gmail.com>
2023-06-27 16:12:25 +02:00
Guillaume Lours
035276e027
watch: add warning when a path is already used by a bind mount volume (#10741)
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-06-26 18:56:04 -04:00
Guillaume Lours
db24023884
Merge pull request #10720 from docker/dependabot/go_modules/google.golang.org/grpc-1.56.0
build(deps): bump google.golang.org/grpc from 1.53.0 to 1.56.0
2023-06-21 13:02:20 +02:00
dependabot[bot]
c48f542962 build(deps): bump google.golang.org/grpc from 1.53.0 to 1.56.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.53.0 to 1.56.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.53.0...v1.56.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-21 12:08:40 +02:00
Guillaume Lours
42dc7a6a87
Merge pull request #10730 from glours/bump-compose-go-1.15.0
bump compose-go to version v1.15.0
2023-06-21 11:58:37 +02:00
Guillaume Lours
30b3b47383
bump compose-go to version v1.15.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-06-21 11:45:36 +02:00
Milas Bowman
061b52da9a ci: build fix for new buildx
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-06-21 11:17:39 +02:00
Milas Bowman
04aa155878 ci: upgrade to buildx v0.11
https://github.com/docker/buildx/releases/tag/v0.11.0

Several `replace` directives have been removed and dependencies
aligned with buildx as needed.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-06-21 11:17:39 +02:00
Guillaume Lours
2d4f8d31fc
Merge pull request #10709 from ndeloof/secret_uid
warn user build.secrets uid,gid,mode are not implemented
2023-06-21 10:19:43 +02:00
Milas Bowman
e1f8603a62 otel: refactor root command span reporting
* Move all the initialization code out of `main.go`
* Ensure spans are reported when there's an error with the
  command
* Attach the Compose version & active Docker context to the
  resource instead of the span
* Name the root CLI span `cli/<cmd>` for clarity and grab
  the full subcommand path (e.g. `alpha-viz` instead of just
  `viz`)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-06-20 17:25:58 +02:00
Nicolas De Loof
a2ce602f6c fix race condition, waiting for containers when one exit
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-06-20 16:17:15 +02:00
dependabot[bot]
401334e03f
build(deps): bump github.com/AlecAivazis/survey/v2 from 2.3.6 to 2.3.7 (#10699)
Bumps [github.com/AlecAivazis/survey/v2](https://github.com/AlecAivazis/survey) from 2.3.6 to 2.3.7.
- [Release notes](https://github.com/AlecAivazis/survey/releases)
- [Commits](https://github.com/AlecAivazis/survey/compare/v2.3.6...v2.3.7)

---
updated-dependencies:
- dependency-name: github.com/AlecAivazis/survey/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-20 09:15:33 -04:00
Guillaume Lours
93cf2b921a use main branch of Docker Desktop repo to trigger remote workflow
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-06-20 12:14:08 +02:00
Guillaume Lours
83b2433a27
Merge pull request #10724 from glours/add-missing-comma-merge
add missing comma in desktop-edge-test job
2023-06-19 21:02:00 +02:00
Guillaume Lours
c8d06137b5
add missing comma in desktop-edge-test job
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-06-19 20:01:52 +02:00
Nicolas De Loof
c61b8aa5ac introduce run --cap-add to run maintenance commands using service image
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-06-19 14:20:20 +02:00
Milas Bowman
ff3984e609
otel: fix initialization / error-handling (#10717)
* If there's no `otel` key (or the value is `null`) in the config,
  don't return an error
* Propagate error from the exporter instead of panicking

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-06-15 12:43:15 -04:00
Guillaume Lours
2efea2e9f5
Merge pull request #10715 from docker/dependabot/go_modules/golang.org/x/sync-0.3.0
build(deps): bump golang.org/x/sync from 0.2.0 to 0.3.0
2023-06-15 18:03:23 +02:00
dependabot[bot]
6a3a95c4a8 build(deps): bump golang.org/x/sync from 0.2.0 to 0.3.0
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.2.0 to 0.3.0.
- [Commits](https://github.com/golang/sync/compare/v0.2.0...v0.3.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-15 17:52:44 +02:00
Guillaume Lours
fee8a1c6c6
Merge pull request #10703 from glours/add-repo-input-dd-token
specify origin repo in generation token step of docker desktop edge testing
2023-06-15 17:47:48 +02:00
Nicolas De Loof
7ffe83dc95 don't apply "rebuild" watch strategy by default
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-06-15 15:30:21 +02:00
Nicolas De Loof
d20c2551f2 warn user build.secrets uid,gid,mode are not implemented
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-06-14 10:21:20 +02:00
Guillaume Lours
0e9a5b6b78
specify origin repo in generation token step of docker desktop edge testing
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-06-13 16:23:51 +02:00
Guillaume Lours
6887a3fc3e
Merge pull request #10702 from glours/fix-DD-APP-ID
add vars. prefix to DOCKERDESKTOP_APP_ID
2023-06-13 14:46:52 +02:00
Guillaume Lours
586fe87f98
add vars. prefix to DOCKERDESKTOP_APP_ID
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-06-13 14:45:26 +02:00
Guillaume Lours
6d66130266
Merge pull request #10701 from glours/fix-DD-APP-ID
use directly DOCKERDESKTOP_APP_ID without env. prefix
2023-06-13 14:21:01 +02:00
Guillaume Lours
0f83a8630e
use directly DOCKERDESKTOP_APP_ID without env. prefix
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-06-13 14:19:56 +02:00
Guillaume Lours
26cb941f79
Merge pull request #10698 from glours/fix-DD-APP-ID
fix typo in merge workflow for DOCKERDESKTOP_APP_ID
2023-06-13 10:23:28 +02:00
Guillaume Lours
43783d36e2
fix typo in merge workflow for DOCKERDESKTOP_APP_ID
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-06-13 10:18:58 +02:00
Guillaume Lours
08e6bfc859
Merge pull request #10691 from glours/fix-dd-workflow-json-parsing
escape containerimage.digest attribute in merge.yml GHA worlflow
2023-06-13 09:52:13 +02:00
Guillaume Lours
7a870e2449 Update .github/workflows/merge.yml
Co-authored-by: CrazyMax <github@crazymax.dev>
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-06-12 16:54:21 +02:00
Guillaume Lours
8cd8f08d77 escape containerimage.digest attribut in merge.yml GHA worlflow
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-06-12 16:54:21 +02:00
Nicolas De Loof
cfe91becc7 use --progress to configure progress UI stylet push
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-06-12 16:53:42 +02:00
Guillaume Lours
9384e5f4d7
Merge pull request #10694 from milas/dependabot-ignore-more
ci: add more ignore rules to dependabot
2023-06-12 16:32:17 +02:00
robbert-ef
68bd0eb523
cli: fix timeout behavior on up / restart / stop (#10672)
Do not set a hardcoded default timeout of 10 seconds when restarting / stopping but use the container `StopTimeout` (defaults to 10 seconds).

Also fixed custom timeout not used when invoking `up`.

Signed-off-by: Robbert Segeren <robbert.segeren@easyflex.nl>
2023-06-12 09:18:25 -04:00
Milas Bowman
3fe665b93d ci: add more ignore rules to dependabot
Reduce PR spam for dependencies that we manually manage.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-06-12 09:06:21 -04:00
Guillaume Lours
508d71c5df
ci: fix merge workflow (#10685)
use env instead of variables prefix to use `DOCKERDESKTOP_APPID`

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-06-09 15:35:47 -04:00
Guillaume Lours
58c5ea8217
Merge pull request #10625 from glours/compose-edge-desktop-integration
add GitHub action to trigger Docker Desktop e2e tests with Compose edge version
2023-06-09 21:18:37 +02:00
Guillaume Lours
ec31d3c2ac add GitHub action to trigger Docker Desktop e2e tests with Compose edge version
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-06-09 21:07:03 +02:00
Laura Brehm
599723f890
Merge pull request #10677 from docker/dependabot/go_modules/github.com/Microsoft/go-winio-0.6.1
build(deps): bump github.com/Microsoft/go-winio from 0.5.2 to 0.6.1
2023-06-09 12:13:09 +02:00
dependabot[bot]
0a9b9fd8fe
build(deps): bump github.com/Microsoft/go-winio from 0.5.2 to 0.6.1
Bumps [github.com/Microsoft/go-winio](https://github.com/Microsoft/go-winio) from 0.5.2 to 0.6.1.
- [Release notes](https://github.com/Microsoft/go-winio/releases)
- [Commits](https://github.com/Microsoft/go-winio/compare/v0.5.2...v0.6.1)

---
updated-dependencies:
- dependency-name: github.com/Microsoft/go-winio
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-09 10:00:25 +00:00
Milas Bowman
3c8a56dbf3
trace: add OTEL initialization (#10526)
This is a bunch of OTEL initialization code. It's all in
`internal/` because there are re-usable parts here, but Compose
isn't the right spot. Once we've stabilized the interfaces a bit
and the need arises, we can move it to a separate module.

Currently, a single span is produced to wrap the root Compose
command.

Compose will respect the standard OTEL environment variables
as well as OTEL metadata from the Docker context. Both can be
used simultaneously. The latter is intended for local system
integration and is restricted to Unix sockets / named pipes.

None of this is enabled by default. It requires setting the
`COMPOSE_EXPERIMENTAL_OTEL=1` environment variable to
gate it during development.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-06-08 16:46:07 -04:00
Milas Bowman
e63ab14b1e
ci: merge Go coverage reports before upload (#10666)
Attempting to fix the state of codecov action checks right now,
which are behaving very erratically.

Using the new functionality in Go 1.20 to merge multiple reports,
so now the unit & E2E coverage data reports are stored as artifacts
and then downloaded, merged, and finally uploaded to codecov as a
new job.

Additionally, add a `codecov.yml` config and try to turn down the
aggressiveness of it for CI checks.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-06-08 14:58:21 -04:00
Guillaume Lours
32cf776ecd
Merge pull request #10620 from ndeloof/Building
do not render `Building` when no build is needed
2023-06-08 12:16:46 +02:00
Guillaume Lours
955784c406
Merge pull request #10662 from milas/bump-deps
ci: upgrade to Go 1.20.5 and Moby v24.x
2023-06-08 12:03:23 +02:00
Guillaume Lours
2d22c2b5ce
Merge pull request #10652 from ndeloof/watch_mkdir
create directory in container using `mkdir -p`
2023-06-08 11:39:21 +02:00
Nicolas De Loof
852c9e80b4 create directory in container using mkdir -p
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-06-08 11:28:22 +02:00
Milas Bowman
37850f7955 ci: upgrade to Go 1.20.5 and Moby v24.x
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-06-07 10:41:49 -04:00
Nicolas De Loof
4bf2fe9fed assume we receive logs by lines and don't ignore those without EOL
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-06-07 10:40:37 +02:00
Guillaume Lours
e21a8d6293
Merge pull request #10657 from ndeloof/compose_project_name
don't skip `compose` used as project name
2023-06-07 08:26:21 +02:00
dependabot[bot]
f8b6459403
build(deps): bump github.com/sirupsen/logrus from 1.9.2 to 1.9.3 (#10653)
Bumps [github.com/sirupsen/logrus](https://github.com/sirupsen/logrus) from 1.9.2 to 1.9.3.
- [Release notes](https://github.com/sirupsen/logrus/releases)
- [Changelog](https://github.com/sirupsen/logrus/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sirupsen/logrus/compare/v1.9.2...v1.9.3)

---
updated-dependencies:
- dependency-name: github.com/sirupsen/logrus
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-06 16:44:25 -04:00
Milas Bowman
be6c9565e3
ci: bump golangci-lint to v1.53.x (#10659)
Requires some changes for depguard config

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-06-06 16:31:41 -04:00
Nicolas De Loof
60fe97416c don't skip compose used as project name
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-06-06 10:24:59 +02:00
Nicolas De Loof
629c9f62e9 better diagnostic message on network label mismatch
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-06-05 16:54:58 +02:00
Guillaume Lours
7c3fe359b7
Merge pull request #10622 from ndeloof/logs_follow
fix `compose -p x logs -f` detect new services started after command
2023-06-02 09:39:20 +02:00
Nicolas De Loof
d2aa15c06e bump buildx and use confutil.ConfigDir
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-06-01 12:09:13 +02:00
Guillaume Lours
6530880361
Merge pull request #10623 from jfly/jfly/tweak-warning-message
Fix typo in warning about existing volume
2023-06-01 08:50:33 +02:00
Nicolas De loof
1bd8a773a7
detect network conflict as name is not guaranteed to be unique (#10612)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-31 14:46:23 -04:00
Nicolas De Loof
fed8ef6b79 forward signal to container
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-31 15:10:11 +02:00
Guillaume Lours
419fcdd6c8
Merge pull request #10604 from aevesdocker/ENGDOCS-1373
update docs to reflect dry run mode is feature complete
2023-05-31 12:49:14 +02:00
Allie Sadler
65b714c108 fix build issue
Signed-off-by: Allie Sadler <102604716+aevesdocker@users.noreply.github.com>
2023-05-31 10:24:49 +01:00
Allie Sadler
44dd232e97
Merge branch 'v2' into ENGDOCS-1373 2023-05-31 10:18:45 +01:00
Guillaume Lours
83ad5e97b7 add Windows drive prefix to temp dir usage in the doc generation task
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-05-31 10:18:23 +02:00
Guillaume Lours
b0a35ccc98
Merge pull request #10632 from docker/dependabot/go_modules/github.com/stretchr/testify-1.8.4
build(deps): bump github.com/stretchr/testify from 1.8.3 to 1.8.4
2023-05-30 12:15:51 +02:00
dependabot[bot]
f5480ee3ed
build(deps): bump github.com/stretchr/testify from 1.8.3 to 1.8.4
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.3 to 1.8.4.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.3...v1.8.4)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-30 10:00:07 +00:00
Nick Sieger
b4924dee83
Merge pull request #10627 from nicksieger/test-cucumber-port-conflict 2023-05-27 08:34:50 -05:00
Nick Sieger
2ca8ab914a
e2e: make test re-runnable on the same machine
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2023-05-26 15:54:39 -05:00
Nick Sieger
3ec8c60657
e2e: add a cuke feature to test compose errors with port conflicts
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2023-05-26 15:54:35 -05:00
Nicolas De Loof
06ec06472f up should not silently ignore missing depends_on service
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-26 21:59:29 +02:00
Nicolas De Loof
466e1d3197
prevent buildkt's progress to render Building when no built is needed
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-26 15:04:37 +02:00
Nicolas De Loof
0d6b99e6f9
e2e test to cover logs -f managing service being added/scaled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-26 14:51:23 +02:00
Nicolas De Loof
01d91c490c detect new container from project have started when running compose logs with no explicit services
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-26 14:15:48 +02:00
Nicolas De Loof
6f6e1635fd compute service hash with a default DeployConfig
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-26 14:15:33 +02:00
Jeremy Fleischman
3d05a1becf
Fix typo in warning about existing volume
Previously, this was telling us "but was not created for project
[project-it-was-created-for]", which is wrong. I opted to make the
message super explicit and print both the actual project and the
expected project.

Signed-off-by: Jeremy Fleischman <jeremyfleischman@gmail.com>
2023-05-25 17:16:47 -07:00
Laura Brehm
42cd961d58
Merge pull request #10582 from docker/dependabot/go_modules/github.com/stretchr/testify-1.8.3 2023-05-25 14:16:17 +02:00
dependabot[bot]
d15fcc6444
build(deps): bump github.com/stretchr/testify from 1.8.2 to 1.8.3
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.2 to 1.8.3.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.2...v1.8.3)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-25 12:03:43 +00:00
Laura Brehm
22c2471a08
Merge pull request #10572 from docker/dependabot/go_modules/github.com/cloudflare/cfssl-1.6.4 2023-05-25 13:53:07 +02:00
dependabot[bot]
29a1cc452d
build(deps): bump github.com/cloudflare/cfssl from 1.4.1 to 1.6.4
Bumps [github.com/cloudflare/cfssl](https://github.com/cloudflare/cfssl) from 1.4.1 to 1.6.4.
- [Release notes](https://github.com/cloudflare/cfssl/releases)
- [Changelog](https://github.com/cloudflare/cfssl/blob/master/CHANGELOG)
- [Commits](https://github.com/cloudflare/cfssl/compare/v1.4.1...v1.6.4)

---
updated-dependencies:
- dependency-name: github.com/cloudflare/cfssl
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-24 21:10:49 +00:00
Milas Bowman
b05a94fd66
progress: remove errant import (#10614)
Write the warning using `logrus.Warn`. The function being used was
coming from `cfssl`'s log package, which was presumably the result
of auto-import being _slightly_ too aggressive.

(Note: `cfssl` is still an indirect dependency after this.)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-05-24 17:08:46 -04:00
Guillaume Lours
15cad92b61 fix display of volumes flag in down help command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-05-24 22:11:58 +02:00
Nicolas De Loof
c7afc6188b detect conflict removing volume/image and warn user
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-24 17:32:32 +02:00
Nicolas De Loof
ca19b7fcc9 introduce WithRootNodesAndDown to walk the graph from specified nodes and down
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-24 17:32:32 +02:00
Nicolas De Loof
93bd27a0cc introduce ability to select service to be stopped by compose down
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-24 17:32:32 +02:00
Nicolas De loof
68c462e607
scale: sort containers by creation date to remove older ones first (#10571)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-23 13:58:32 -04:00
Nicolas De loof
916aac6c27
watch: only monitor configured paths (#10599)
For performance, don't watch the entire build context.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-23 13:35:50 -04:00
Nicolas De loof
eafcd1b35e
secrets: only set CopyUIDGID when required (#10598)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-23 13:34:24 -04:00
Allie Sadler
1e399c271a update docs to reflect dry run mode is feature complete
Signed-off-by: Allie Sadler <102604716+aevesdocker@users.noreply.github.com>
2023-05-23 15:53:48 +01:00
Guillaume Lours
544b579cb0
Merge pull request #10597 from ndeloof/ComposeProjectName
fix support for project name set by COMPOSE_PROJECT_NAME env var
2023-05-22 20:24:13 +02:00
Nicolas De Loof
daa6bec80a
fix support for project name set by COMPOSE_PROJECT_NAME env var
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-22 19:14:57 +02:00
Sebastiaan van Stijn
34bd41cc0c go.mod: golang.org/x/oauth2 v0.1.0
docker/docker already depends on oauth2 v0.1.0, which differs only in
dependencies;

https://github.com/golang/oauth2/compare/6fdb5e3db783...v0.1.0

The replace rule is still needed to help with some dependency hell when
resolving the version to use;

    go mod tidy
    go: downloading cloud.google.com/go v0.75.0
    github.com/docker/compose/v2/pkg/compose imports
        github.com/moby/buildkit/client imports
        go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc tested by
        go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc.test imports
        google.golang.org/grpc/interop imports
        golang.org/x/oauth2/google imports
        cloud.google.com/go/compute/metadata: ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules:
        cloud.google.com/go v0.75.0 (/Users/thajeztah/go/pkg/mod/cloud.google.com/go@v0.75.0/compute/metadata)
        cloud.google.com/go/compute/metadata v0.2.1 (/Users/thajeztah/go/pkg/mod/cloud.google.com/go/compute/metadata@v0.2.1)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-22 15:01:38 +02:00
Guillaume Lours
70953b18c0
Merge pull request #10591 from ndeloof/fix_detect_swarm_enabled
fix detection of swarm mode
2023-05-22 09:25:56 +02:00
Nicolas De Loof
cfe1a860ff
fix detection of swarm mode
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-22 08:26:22 +02:00
Laura Brehm
4dcda432cf
Merge pull request #10578 from docker/dependabot/go_modules/github.com/sirupsen/logrus-1.9.2
build(deps): bump github.com/sirupsen/logrus from 1.9.0 to 1.9.2
2023-05-18 11:14:10 +01:00
dependabot[bot]
5c2a885647
build(deps): bump github.com/sirupsen/logrus from 1.9.0 to 1.9.2
Bumps [github.com/sirupsen/logrus](https://github.com/sirupsen/logrus) from 1.9.0 to 1.9.2.
- [Release notes](https://github.com/sirupsen/logrus/releases)
- [Changelog](https://github.com/sirupsen/logrus/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sirupsen/logrus/compare/v1.9.0...v1.9.2)

---
updated-dependencies:
- dependency-name: github.com/sirupsen/logrus
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-18 09:59:38 +00:00
Guillaume Lours
cd0fc214a5 only check the platform of cached image if image found
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-05-17 08:04:54 +02:00
Nicolas De Loof
9b5a4588f9 introduce --no-path-resolution to skip relative path to be resolved
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-16 13:02:56 +02:00
Nicolas De Loof
00f72cb553 report external network not found when swarm is disabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-15 20:57:19 +02:00
Nicolas De Loof
fd7847f2ac parallel flag belong do top-level "compose" cobra command, not the current one
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-15 20:57:09 +02:00
Nicolas De Loof
18a112e88c detect terminal is not a console.File to avoid a panic
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-15 20:56:33 +02:00
Guillaume Lours
dc01b98aa6
Merge pull request #10559 from ndeloof/COMPOSE_ANSI
introduce COMPOSE_ANSI to define --ansi default value
2023-05-15 10:42:06 +02:00
Guillaume Lours
312f0d1d61 Update dry-run documentation
Co-authored-by: Allie Sadler <102604716+aevesdocker@users.noreply.github.com>
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-05-15 09:39:46 +02:00
Guillaume Lours
e8caad1903 move dry-run support from alpha to main command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-05-15 09:39:46 +02:00
Nicolas De Loof
fca454b41f
introduce COMPOSE_ANSI to define --ansi default value
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-12 12:52:20 +02:00
Mateus Esdras
77dc9b54f3
rm: remove debugging output (#10554)
For example, when no container was being removed,
this would print `[]`.

Signed-off-by: Mateus Esdras <linux.esdras@gmail.com>
2023-05-11 16:32:29 -04:00
Nicolas De loof
bceb3c1876
detect active endpoint trying to remove network and skip with a warning (#10555)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-11 16:31:29 -04:00
Nicolas De loof
a14abb9044
cli: option to write status messages on stdout (#10549)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-11 12:45:00 -04:00
Nicolas De loof
0363d9260a
fix local image removal when compose down is ran with --project-name (#10558)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-11 12:41:14 -04:00
Nicolas De loof
0e375a8c61
restore long description to be included in docker compose help (#10504)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-11 12:33:45 -04:00
Nicolas De Loof
b776826d92 check local image matches the required platform
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-10 16:57:21 +02:00
Guillaume Lours
3b32a264c7
Merge pull request #10544 from ndeloof/parallel_race
fix race condition when --parallel is used with a large number of dependent services
2023-05-10 11:50:59 +02:00
Nicolas De Loof
e92c5d1392 fix race condition running compose up with --parallel < number of services
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-10 11:39:07 +02:00
Nicolas De loof
0c1a691fa5
fix container being recreated while config has not changed (#10540)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-09 15:15:40 -04:00
Laura Brehm
f72d5d6099
Merge pull request #10508 from laurazard/tests-inline-dockerfile
Update 🥒 tests to use `dockerfile_inline`
2023-05-09 17:38:05 +01:00
Laura Brehm
ee70085fba tests: inline dockerfile
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-05-09 17:27:47 +01:00
dependabot[bot]
90bcf610b3
build(deps): bump github.com/moby/term from 0.0.0-20221205130635-1aeaba878587 to 0.5.0 (#10523)
build(deps): bump github.com/moby/term

Bumps [github.com/moby/term](https://github.com/moby/term) from 0.0.0-20221205130635-1aeaba878587 to 0.5.0.
- [Release notes](https://github.com/moby/term/releases)
- [Commits](https://github.com/moby/term/commits/v0.5.0)

---
updated-dependencies:
- dependency-name: github.com/moby/term
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-09 10:07:14 -04:00
Laura Brehm
2d25019fe9
Merge pull request #10521 from docker/dependabot/go_modules/go.opentelemetry.io/otel-1.15.1
build(deps): bump go.opentelemetry.io/otel from 1.15.0 to 1.15.1
2023-05-09 11:38:30 +01:00
Laura Brehm
fb16e49cb2
Merge pull request #10542 from docker/dependabot/go_modules/github.com/docker/cli-23.0.6incompatible
build(deps): bump github.com/docker/cli from 23.0.5+incompatible to 23.0.6+incompatible
2023-05-09 11:34:27 +01:00
Laura Brehm
109ce190c4
deps: update related modules
(see https://github.com/docker/compose/pull/10542/files#r1188432369)

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-05-09 11:18:09 +01:00
dependabot[bot]
ef03c906b9
build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 23.0.5+incompatible to 23.0.6+incompatible.
- [Commits](https://github.com/docker/cli/compare/v23.0.5...v23.0.6)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-09 09:59:44 +00:00
dependabot[bot]
865a0867a4
build(deps): bump go.opentelemetry.io/otel from 1.15.0 to 1.15.1
Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.15.0 to 1.15.1.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.15.0...v1.15.1)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-08 13:23:13 +00:00
dependabot[bot]
6ee0376bb6
build(deps): bump golang.org/x/sync from 0.1.0 to 0.2.0 (#10534)
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.1.0 to 0.2.0.
- [Commits](https://github.com/golang/sync/compare/v0.1.0...v0.2.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-08 09:22:03 -04:00
Nicolas De loof
67455e9f33
fix builkit progressui integration (#10535)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-08 09:21:41 -04:00
Guillaume Lours
5fdcaa0fe1
Merge pull request #10529 from glours/dry-run-up-support
add dry-run support to up command
2023-05-05 09:41:18 +02:00
Guillaume Lours
01afe5265e
Merge pull request #10527 from ndeloof/build_secret_id
let user declare build secret target
2023-05-04 15:17:30 +02:00
Guillaume Lours
2e4faf80f5 add dry-run support to up command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-05-04 15:11:11 +02:00
Guillaume Lours
e88836ffbd
Merge pull request #10525 from thaJeztah/update_go1.20.4
update go to go1.20.4
2023-05-04 11:52:37 +02:00
Nicolas De Loof
b45ca82791
let user declare build secret target (id)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-05-04 10:01:10 +02:00
Sebastiaan van Stijn
d1c36c6e6b
update go to go1.20.4
go1.20.4 (released 2023-05-02) includes three security fixes to the html/template
package, as well as bug fixes to the compiler, the runtime, and the crypto/subtle,
crypto/tls, net/http, and syscall packages. See the Go 1.20.4 milestone on our
issue tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.20.4+label%3ACherryPickApproved

release notes: https://go.dev/doc/devel/release#go1.20.4
full diff: https://github.com/golang/go/compare/go1.20.3...go1.20.4

from the announcement:

> These minor releases include 3 security fixes following the security policy:
>
> - html/template: improper sanitization of CSS values
>
>   Angle brackets (`<>`) were not considered dangerous characters when inserted
>   into CSS contexts. Templates containing multiple actions separated by a '/'
>   character could result in unexpectedly closing the CSS context and allowing
>   for injection of unexpected HMTL, if executed with untrusted input.
>
>   Thanks to Juho Nurminen of Mattermost for reporting this issue.
>
>   This is CVE-2023-24539 and Go issue https://go.dev/issue/59720.
>
> - html/template: improper handling of JavaScript whitespace
>
>   Not all valid JavaScript whitespace characters were considered to be
>   whitespace. Templates containing whitespace characters outside of the character
>   set "\t\n\f\r\u0020\u2028\u2029" in JavaScript contexts that also contain
>   actions may not be properly sanitized during execution.
>
>   Thanks to Juho Nurminen of Mattermost for reporting this issue.
>
>   This is CVE-2023-24540 and Go issue https://go.dev/issue/59721.
>
> - html/template: improper handling of empty HTML attributes
>
>   Templates containing actions in unquoted HTML attributes (e.g. "attr={{.}}")
>   executed with empty input could result in output that would have unexpected
>   results when parsed due to HTML normalization rules. This may allow injection
>   of arbitrary attributes into tags.
>
>   Thanks to Juho Nurminen of Mattermost for reporting this issue.
>
>   This is CVE-2023-29400 and Go issue https://go.dev/issue/59722.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-03 21:38:19 +02:00
TP-O
b304c4e154 stop containers after termination
Signed-off-by: TP-O <letranphong2k1@gmail.com>
2023-05-03 11:47:56 +02:00
Guillaume Lours
eca1365d42
cli: dry run support for build (#10502)
* add dry-run support for classic builder
* add dry-run support for buildkit

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-05-02 14:23:26 -04:00
Guillaume Lours
03f4c0e631
progress: make title configurable (#10507)
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-05-02 14:15:35 -04:00
Guillaume Lours
2a0e83ad9a
Merge pull request #10519 from glours/revert-image-spec-upgrade
Revert "build(deps): bump github.com/opencontainers/image-spec"
2023-05-02 13:13:13 +02:00
Guillaume Lours
2df9919ece
Revert "build(deps): bump github.com/opencontainers/image-spec"
This reverts commit d54a95fed74030fc11d5343edb35315d62e9153d.

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-05-02 12:31:27 +02:00
Guillaume Lours
74fc40d895
Merge pull request #10518 from docker/dependabot/go_modules/github.com/opencontainers/image-spec-1.1.0-rc.3
build(deps): bump github.com/opencontainers/image-spec from 1.1.0-rc2.0.20221005185240-3a7f492d3f1b to 1.1.0-rc.3
2023-05-02 12:11:16 +02:00
dependabot[bot]
d54a95fed7
build(deps): bump github.com/opencontainers/image-spec
Bumps [github.com/opencontainers/image-spec](https://github.com/opencontainers/image-spec) from 1.1.0-rc2.0.20221005185240-3a7f492d3f1b to 1.1.0-rc.3.
- [Release notes](https://github.com/opencontainers/image-spec/releases)
- [Changelog](https://github.com/opencontainers/image-spec/blob/main/RELEASES.md)
- [Commits](https://github.com/opencontainers/image-spec/commits/v1.1.0-rc3)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/image-spec
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-02 09:58:57 +00:00
Guillaume Lours
c1369869f5
Merge pull request #10515 from docker/dependabot/go_modules/go.opentelemetry.io/otel-1.15.0
build(deps): bump go.opentelemetry.io/otel from 1.14.0 to 1.15.0
2023-05-02 11:32:07 +02:00
dependabot[bot]
f5ff40a2f3 build(deps): bump go.opentelemetry.io/otel from 1.14.0 to 1.15.0
Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.14.0 to 1.15.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.14.0...v1.15.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-02 10:51:17 +02:00
Guillaume Lours
6347b49f9c
Merge pull request #10516 from docker/dependabot/go_modules/github.com/moby/buildkit-0.11.6
build(deps): bump github.com/moby/buildkit from 0.11.5 to 0.11.6
2023-05-02 10:50:09 +02:00
dependabot[bot]
c072a6f5f5
build(deps): bump github.com/moby/buildkit from 0.11.5 to 0.11.6
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.11.5 to 0.11.6.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.11.5...v0.11.6)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-01 10:05:25 +00:00
Guillaume Lours
a06d32e7b6
Merge pull request #10506 from docker/dependabot/go_modules/github.com/opencontainers/image-spec-1.1.0-rc.3
build(deps): bump github.com/opencontainers/image-spec from 1.1.0-rc2.0.20221005185240-3a7f492d3f1b to 1.1.0-rc.3
2023-04-28 12:41:15 +02:00
dependabot[bot]
28fa309c23 build(deps): bump github.com/opencontainers/image-spec
Bumps [github.com/opencontainers/image-spec](https://github.com/opencontainers/image-spec) from 1.1.0-rc2.0.20221005185240-3a7f492d3f1b to 1.1.0-rc.3.
- [Release notes](https://github.com/opencontainers/image-spec/releases)
- [Changelog](https://github.com/opencontainers/image-spec/blob/main/RELEASES.md)
- [Commits](https://github.com/opencontainers/image-spec/commits/v1.1.0-rc.3)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/image-spec
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-28 12:26:50 +02:00
Laura Brehm
4f2c933f78
Merge pull request #10501 from docker/dependabot/go_modules/github.com/docker/cli-23.0.5incompatible
build(deps): bump github.com/docker/cli from 23.0.4+incompatible to 23.0.5+incompatible
2023-04-28 10:59:34 +01:00
dependabot[bot]
e22c8964b9
build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 23.0.4+incompatible to 23.0.5+incompatible.
- [Release notes](https://github.com/docker/cli/releases)
- [Commits](https://github.com/docker/cli/compare/v23.0.4...v23.0.5)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-28 09:49:02 +00:00
Nicolas De Loof
07c4849cb9 TailMsgf must format with args
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-04-27 22:12:12 +02:00
Guillaume Lours
e606701d9f
Merge pull request #10500 from docker/dependabot/go_modules/github.com/docker/docker-23.0.5incompatible
build(deps): bump github.com/docker/docker from 23.0.4+incompatible to 23.0.5+incompatible
2023-04-27 12:12:33 +02:00
dependabot[bot]
114e5c6425
build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 23.0.4+incompatible to 23.0.5+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v23.0.4...v23.0.5)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-27 10:00:06 +00:00
dependabot[bot]
37dfb5bf26
build(deps): bump github.com/moby/buildkit from 0.11.5 to 0.11.6 (#10489)
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.11.5 to 0.11.6.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.11.5...v0.11.6)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-25 13:34:18 -04:00
Nicolas De Loof
d01ef5887a restore support for --memory
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-04-25 15:41:08 +02:00
Nicolas De Loof
dec608f3cd don't block events loop collecting logs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-04-25 15:20:05 +02:00
Guillaume Lours
eb0632b1d8
Merge pull request #10494 from milas/e2e-dd-419
test: fix E2E tests under Engine v23 / DD 4.19
2023-04-25 08:37:24 +02:00
Milas Bowman
1383ab09ec test: fix E2E tests under Engine v23 / DD 4.19
Some error messages have been tweaked slightly, this adapts the
assertions to work on both Engine v20.10.x and v23.x.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-04-25 08:27:42 +02:00
Benjamín Guzmán
5eaafe4237 Fixed issue when project name contains dashes (-)
Signed-off-by: Benjamín Guzmán <bg@benjaminguzman.dev>
2023-04-24 12:18:37 +02:00
Benjamín Guzmán
7840a92c40 Added tests to viz subcommand
Signed-off-by: Benjamín Guzmán <bg@benjaminguzman.dev>
2023-04-24 12:18:37 +02:00
Benjamín Guzmán
3751c3074b Added docs
Signed-off-by: Benjamín Guzmán <bg@benjaminguzman.dev>
2023-04-24 12:18:37 +02:00
Benjamín Guzmán
2bc6a45c0b Replaced calls to WriteRune with WriteByte and reformatted imports
Signed-off-by: Benjamín Guzmán <bg@benjaminguzman.dev>
2023-04-24 12:18:37 +02:00
Benjamín Guzmán
2268d1e573 Started working on viz subcommand
Signed-off-by: Benjamín Guzmán <bg@benjaminguzman.dev>
2023-04-24 12:18:37 +02:00
Nicolas De Loof
7b0ed13209 bump compose-go to v1.13.4
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-04-20 11:12:07 +02:00
Laura Brehm
d4441efe1e
Merge pull request #10474 from docker/dependabot/go_modules/github.com/docker/docker-23.0.4incompatible
build(deps): bump github.com/docker/docker from 23.0.3+incompatible to 23.0.4+incompatible
2023-04-18 19:44:16 +01:00
dependabot[bot]
58368f69e9
build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 23.0.3+incompatible to 23.0.4+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v23.0.3...v23.0.4)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-18 18:29:07 +00:00
Laura Brehm
bc2b2e52e5
Merge pull request #10475 from docker/dependabot/go_modules/github.com/docker/cli-23.0.4incompatible
build(deps): bump github.com/docker/cli from 23.0.3+incompatible to 23.0.4+incompatible
2023-04-18 19:27:54 +01:00
dependabot[bot]
7723d11930
build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 23.0.3+incompatible to 23.0.4+incompatible.
- [Release notes](https://github.com/docker/cli/releases)
- [Commits](https://github.com/docker/cli/compare/v23.0.3...v23.0.4)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-18 09:59:33 +00:00
Nicolas De Loof
65fda18821 bump compose-go
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-04-17 17:19:56 +02:00
Tran Phong
0e7e1b940b
Remove redundant goroutine while removing containers (#10449)
don't use goroutine to stop container while removing

Signed-off-by: TP-O <letranphong2k1@gmail.com>
2023-04-17 10:57:29 -04:00
Milas Bowman
af6f0ffb9e
Merge pull request #10458 from thaJeztah/simplify_auth
Don't use "info.IndexServerAddress" for authentication
2023-04-12 12:19:04 -04:00
Milas Bowman
9ef173a3ac
log: fix race on container kill (#10459)
If we go to inspect a container that we got an event for and it
no longer exists on the server, handle clean up without erroring
out.

Fixes #10373.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-04-12 12:15:58 -04:00
Guillaume Lours
1fb0c03e8b
Merge pull request #10457 from thaJeztah/mod_tidy
go.mod: fix grouping of dependencies, and tidy
2023-04-11 23:36:19 +02:00
Sebastiaan van Stijn
1892be8c70
Don't use "info.IndexServerAddress" for authentication
The IndexServerAddress field was  as part of the initial Windows implementation
of the engine. For legal reasons, Microsoft Windows (and thus Docker images
based on Windows) were not allowed to be distributed through non-Microsoft
infrastructure. As a temporary solution, a dedicated "registry-win-tp3.docker.io"
registry was created to serve Windows images.

Using separate registries was not an ideal solution, and a more permanent
solution was created by introducing "foreign image layers" in the distribution
spec, after which the "registry-win-tp3.docker.io" ceased to exist, and
removed from the engine.

This replaces the code that calls out to the "/info" endpoint to use the
GetAuthConfigKey() function instead.

Related PR in docker/cli:
b4ca1c7368

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-11 23:10:22 +02:00
Sebastiaan van Stijn
37068a700f
go.mod: fix grouping of dependencies, and tidy
go mod tidy sometimes messes up grouping of imports, and may
need a bit of hand-holding in those cases :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-11 22:32:53 +02:00
Guillaume Lours
a4af5e229d
Merge pull request #10455 from docker/dependabot/go_modules/github.com/opencontainers/runc-1.1.5
build(deps): bump github.com/opencontainers/runc from 1.1.3 to 1.1.5
2023-04-10 20:59:28 +02:00
dependabot[bot]
87da6c1470
build(deps): bump github.com/opencontainers/runc from 1.1.3 to 1.1.5
Bumps [github.com/opencontainers/runc](https://github.com/opencontainers/runc) from 1.1.3 to 1.1.5.
- [Release notes](https://github.com/opencontainers/runc/releases)
- [Changelog](https://github.com/opencontainers/runc/blob/main/CHANGELOG.md)
- [Commits](https://github.com/opencontainers/runc/compare/v1.1.3...v1.1.5)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/runc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-10 18:47:06 +00:00
Guillaume Lours
a99acd940a
Merge pull request #10444 from glours/dry-run-down-support
add dry-run support to down command
2023-04-07 15:46:39 +02:00
Guillaume Lours
7fb87856aa add dry-run support to down command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-04-07 10:41:51 +02:00
Guillaume Lours
eb933adde0
Merge pull request #10451 from glours/fix-gocyclo-ci-issue
fix gocyclo lint error which currently block Compose CI
2023-04-07 10:41:36 +02:00
Guillaume Lours
cb688b5fd4
fix gocyclo lint error which currently block Compose CI
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-04-07 10:19:06 +02:00
Nicolas De Loof
8b5b78fbb6 can't watch a service without a build section
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-04-06 08:55:49 +02:00
Nicolas De Loof
d3e49fe360 ansi=auto|never|always
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-04-06 08:24:04 +02:00
Guillaume Lours
1bca8d5c01
Merge pull request #10438 from glours/bump-docker-23.0.3
bump docker version to 23.0.3 (CVE-2023-28840)
2023-04-05 12:17:47 +02:00
Guillaume Lours
76d9cf2711
bump docker version to 23.0.3 (CVE-2023-28840)
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-04-05 12:02:57 +02:00
Nicolas De loof
d762f5f473
better support NO_COLOR by disabling colors, not ANSI TUI (#10434)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-04-04 17:00:10 -04:00
Guillaume Lours
90eda35f3d
Merge pull request #10437 from milas/bump-go-1.20.3
ci: bump Go to 1.20.3 and various dependencies
2023-04-04 21:33:20 +02:00
Milas Bowman
7ce0096f40 ci: bump Go to 1.20.3 and various dependencies
Use latest Go minor release. Note: this release included fixes for
several CVEs, but they do not impact Compose.

Small errors have been fixed to keep the linter happy.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-04-04 15:15:02 -04:00
Milas Bowman
00eca0af70
Merge pull request #10432 from ndeloof/timeout
restore `--timeout` flag renamed by mistake
2023-04-04 15:03:04 -04:00
Nicolas De Loof
a10c4c6df5
restore --timeout flag renamed by mistake
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-04-04 08:48:00 +02:00
Guillaume Lours
6a37428491
Merge pull request #10413 from glours/dry-run-create-support
add dry-run support to create command
2023-04-03 18:25:55 +02:00
Guillaume Lours
449a46a252
Merge pull request #10423 from ndeloof/build_classic_panic
prevent panic using classic builder
2023-03-31 12:36:27 +02:00
Nicolas De Loof
981cb2024e
prevent panic using classic builder
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-31 11:59:22 +02:00
Guillaume Lours
b83edbd039 add dry-run support to create command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-03-30 10:25:56 +02:00
Milas Bowman
02ad467f89
Merge pull request #10415 from docker/dependabot/go_modules/github.com/docker/cli-23.0.2incompatible
build(deps): bump github.com/docker/cli from 23.0.1+incompatible to 23.0.2+incompatible
2023-03-29 09:28:45 -04:00
Milas Bowman
d9e1d419c1
Merge pull request #10414 from docker/dependabot/go_modules/github.com/docker/docker-23.0.2incompatible
build(deps): bump github.com/docker/docker from 23.0.1+incompatible to 23.0.2+incompatible
2023-03-29 09:28:20 -04:00
dependabot[bot]
a4c324b8e6
build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 23.0.1+incompatible to 23.0.2+incompatible.
- [Release notes](https://github.com/docker/cli/releases)
- [Commits](https://github.com/docker/cli/compare/v23.0.1...v23.0.2)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-29 09:59:37 +00:00
dependabot[bot]
087fae98b6
build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 23.0.1+incompatible to 23.0.2+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v23.0.1...v23.0.2)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-29 09:59:27 +00:00
Milas Bowman
aafeaa66e2
Merge pull request #10409 from ndeloof/ContainerList_race
workaround race condition in ContainerList
2023-03-28 14:53:53 -04:00
Nicolas De Loof
c5317496ac
workaround race condition in ContainerList
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-28 12:28:41 +02:00
Milas Bowman
67c9ecb4f4
Merge pull request #10404 from glours/dry-run-run-support
add dry-run support to run command
2023-03-27 17:42:28 -04:00
Guillaume Lours
72a61c0602 add dry-run support to run command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-03-27 18:57:11 +02:00
Guillaume Lours
0b6133f75b
Merge pull request #10406 from milas/fix-name-validation
ci: bump compose-go to v1.13.2
2023-03-26 16:09:47 +02:00
Milas Bowman
b24af42bcc ci: bump compose-go to v1.13.2
https://github.com/compose-spec/compose-go/releases/tag/v1.13.2

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-03-26 09:55:53 -04:00
Milas Bowman
cc70851bc8
Merge pull request #10403 from milas/fix-e2e-win
test: fix e2e commands on Windows
2023-03-24 12:13:42 -04:00
Milas Bowman
3b85cd2fa9 test: fix e2e commands on Windows
Instead of trying to make this work nicely cross-platform,
just push the Coverage logic into the GitHub Actions job,
as that's really where we care about it.

(It's surprisingly difficult to make this nicely portable;
to make PowerShell not error out if the path does not exist
you have to ignore ALL errors and the way that env vars are
passed to processes is not the same.)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-03-24 11:50:05 -04:00
Milas Bowman
d818bf6f34
Merge pull request #10401 from milas/deps-update
ci: upgrade to Go 1.20.2 & bump deps
2023-03-24 11:05:53 -04:00
Milas Bowman
45a852f438 test: generate valid Compose project names from Cucumber specs
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-03-24 10:54:33 -04:00
Milas Bowman
f0bf4fca76
Merge pull request #10402 from milas/fix-e2e-race
test: fix race in e2e build test
2023-03-24 10:44:54 -04:00
Milas Bowman
cd17c8a950 test: update error message
Validation got improved in `compose-go` so the error message is
slightly different.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-03-24 10:42:43 -04:00
Milas Bowman
36625ed229 test: fix race in e2e build test
This was running two tests in parallel that would build/delete the
same images. Run in serial instead since that's not safe.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-03-24 10:32:55 -04:00
Milas Bowman
a6ffdf6110 ci: upgrade to Go 1.20.2 & bump deps
* Go 1.20.2
* golangci-lint v1.52.0
* compose-go v1.13.1: https://github.com/compose-spec/compose-go/releases/tag/v1.13.1

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-03-24 09:31:28 -04:00
Milas Bowman
72260d615d
Merge pull request #10400 from docker/dependabot/go_modules/github.com/moby/buildkit-0.11.5
build(deps): bump github.com/moby/buildkit from 0.11.4 to 0.11.5
2023-03-24 09:12:51 -04:00
Milas Bowman
fd28ab8d38
Merge pull request #10399 from ndeloof/watch_rebuild
watch involves up --build after change has been detected
2023-03-24 09:10:56 -04:00
dependabot[bot]
9ab5d8c44e
build(deps): bump github.com/moby/buildkit from 0.11.4 to 0.11.5
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.11.4 to 0.11.5.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.11.4...v0.11.5)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-24 10:00:03 +00:00
Nicolas De Loof
d637cc3ade watch involves up --build after change has been detected
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-24 10:49:27 +01:00
Milas Bowman
925bc6fbf3
Merge pull request #10393 from milas/fix-watch-segfault
watch: data race / segfault fixes
2023-03-23 17:07:49 -04:00
Milas Bowman
16d5354d70 watch: add note about goroutine-safety & test
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-03-23 11:33:03 -04:00
Milas Bowman
7aaea283ca watch: data race / segfault fixes
Was getting segfaults with multiple services using
`x-develop` and `watch` at the same time. Turns out
the Moby path matcher lazily initializes the regex
pattern internally the first time it's used, so it's
not goroutine-safe.

Change here is to not use a global instance for the
ephemeral path matcher, but a per-watcher instance.

Additionally, the data race detector caught a couple
other issues that were easy enough to fix:
 * Use the lock that's used elsewhere for convergence
   before manipulating
 * Eliminate concurrent map access when triggering
   rebuilds

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-03-22 18:05:56 -04:00
Guillaume Lours
6bedc196cc update -p project name flag documentation
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-03-22 10:53:54 +01:00
Nicolas De Loof
a11515e038 introduce ignore attribute for watch triggers
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-21 18:29:49 +01:00
Nicolas De Loof
6c1f06e420 Run classic builder with BuildConfig, not buildx.Options
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-21 15:37:55 +01:00
Nicolas De Loof
88b0d17ff8 use build as common API for build scenarios
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-21 15:37:55 +01:00
Nicolas De Loof
9e19bc8441 use progress to show copy status
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-21 14:40:52 +01:00
Guillaume Lours
bef9c48a1a
Merge pull request #10386 from milas/fw-renames
watch: add file delete/rename handling
2023-03-21 13:48:56 +01:00
Milas Bowman
105a7c5b70 watch: add file delete/rename handling
This approach mimics Tilt's behavior[^1]:
 1. At sync time, `stat` the path on host
 2. If the path does not exist -> `rm` from container
 3. If the path exists -> sync to container

By handling things this way, we're always syncing based on the true
state, regardless of what's happened in the interim. For example, a
common pattern in POSIX tools is to create a file and then rename it
over an existing file. Based on timing, this could be a sync, delete,
sync (every file gets seen & processed) OR a delete, sync (by the
the time we process the event, the "temp" file is already gone, so
we just delete it from the container, where it never existed, but
that's fine since we deletes are idempotent thanks to the `-f` flag
on `rm`).

Additionally, when syncing, if the `stat` call shows it's for a
directory, we ignore it. Otherwise, duplicate, nested copies of the
entire path could get synced in. (On some OSes, an event for the
directory gets dispatched when a file inside of it is modified. In
practice, I think we might want this pushed further down in the
watching code, but since we're already `stat`ing the paths here now,
it's a good place to handle it.)

Lastly, there's some very light changes to the text when it does a
full rebuild that will list out the (merged) set of paths that
triggered it. We can continue to improve the output, but this is
really helpful for understanding why it's rebuilding.

[^1]: db7f887b06/internal/controllers/core/liveupdate/reconciler.go (L911)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-03-21 08:37:18 -04:00
Laura Brehm
03f0ed132d
Merge pull request #10352 from docker/dependabot/go_modules/github.com/docker/buildx-0.10.4
build(deps): bump github.com/docker/buildx from 0.10.3 to 0.10.4
2023-03-19 21:11:57 +00:00
Laura Brehm
f7a13aee11
build(deps): bump github.com/docker/buildx from 0.10.3 to 0.10.4
Bumps [github.com/docker/buildx](https://github.com/docker/buildx) from 0.10.3 to 0.10.4.
- [Release notes](https://github.com/docker/buildx/releases)
- [Commits](https://github.com/docker/buildx/compare/v0.10.3...v0.10.4)

---
updated-dependencies:
- dependency-name: github.com/docker/buildx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-03-19 20:59:58 +00:00
Luis Rascao
bfeb1dc277 Fix concurrent map read/write when recreating containers
Signed-off-by: Luis Rascao <luis.rascao@gmail.com>
2023-03-19 21:56:06 +01:00
Laura Brehm
9ec43973e2
Merge pull request #10353 from docker/dependabot/go_modules/github.com/moby/buildkit-0.11.4
build(deps): bump github.com/moby/buildkit from 0.11.3 to 0.11.4
2023-03-19 20:40:31 +00:00
dependabot[bot]
0b41df9821
build(deps): bump github.com/moby/buildkit from 0.11.3 to 0.11.4
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.11.3 to 0.11.4.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.11.3...v0.11.4)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-19 20:28:31 +00:00
Guillaume Lours
643557d534 build and push binaries images when a PR is merged or a tag pushed
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-03-16 11:23:49 +01:00
Laura Brehm
200f47e5be Add support for additional_contexts in build service config
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-03-15 14:00:51 +01:00
Nicolas De Loof
e0aaccf430 introduce dockerfile_inline
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-15 10:19:04 +01:00
Nicolas De Loof
754c06886f one off container name use configured Separator for naming
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-15 09:47:43 +01:00
Nicolas De Loof
e492330dd5 collect built image IDs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-15 09:47:32 +01:00
Nicolas De Loof
bbe1b77a67 progress writer uses dockercli.Err stream
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-15 09:47:13 +01:00
Tianon Gravi
fc4d2dfdd8 Remove "-s" from LDFLAGS
While this stripping does decrease the binary size by some amount, it also removes the ability for `govulncheck` (https://go.dev/blog/vuln) to scan the binary for actual uses of vulnerable functions, requiring the user to clone the code locally and hope they're testing against the same version of the stdlib, etc that the binary was built with.  If we stop passing `-s`, then we can then run `govulncheck` on the binary directly (making it easier to flag both false positives in CVE scans _and_ actual issues worth looking into).

Here's an example of the output on a freshly built binary with this change:

```console
$ govulncheck ./bin/build/docker-compose
govulncheck is an experimental tool. Share feedback at https://go.dev/s/govulncheck-feedback.

Using govulncheck@v0.0.0 with
vulnerability data from https://vuln.go.dev (last modified 27 Feb 23 16:29 UTC).

Scanning your binary for known vulnerabilities...
No vulnerabilities found.
```

Compared to the 1.16.0 release binary:

```console
$ govulncheck ./docker-compose
go: downloading golang.org/x/vuln v0.0.0-20230224180816-edec1fb0a9c7
govulncheck is an experimental tool. Share feedback at https://go.dev/s/govulncheck-feedback.

Using govulncheck@v0.0.0 with
vulnerability data from https://vuln.go.dev (last modified 27 Feb 23 16:29 UTC).

Scanning your binary for known vulnerabilities...
govulncheck: vulncheck.Binary: reading go:func.*: no symbol "go:func.*"
```

It's not 100% apples-to-apples, but the size difference between these binaries is ~46MiB for the 1.16.0 release and ~52MiB for the binary I built from this commit.

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2023-03-13 08:16:48 +00:00
Nicolas De Loof
85ddfde5d6 use go 1.20 -cover support
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-10 16:54:39 +00:00
Nicolas De Loof
6a0398d786 pad can be negative on small terminal
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-09 10:27:43 +00:00
Guillaume Lours
4434cea535 add dry-run support for push command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-03-08 14:23:57 +00:00
Guillaume Lours
62fbf20887
Merge pull request #10341 from glours/dry-run-pull-support
add dry-run support for pull command
2023-03-06 11:13:42 +01:00
Guillaume Lours
3f7d3c2661 add dry-run support for pull command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-03-05 22:04:32 +01:00
Nicolas De Loof
9cc1613b55 adopt http://no-color.org/
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-03 11:15:40 +01:00
Guillaume Lours
c4b47fe911
Merge pull request #10339 from glours/dry-run-restart-support
Dry run restart support
2023-03-02 10:25:51 +01:00
Guillaume Lours
167c6a89b1 add dry-run support to restart command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-03-02 10:14:59 +01:00
Guillaume Lours
a84345be8f
Merge pull request #10338 from glours/fix-restart-depends_on
restart only needed services by checking depends_on relations
2023-03-02 10:14:28 +01:00
Guillaume Lours
3cfbac6624
restart only needed services by checking depends_on relations
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-03-01 18:22:40 +01:00
Nicolas De Loof
a3bed265f2 update compose-go
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-01 17:14:53 +01:00
Nicolas De Loof
ae26426cc8 Report error if project name is empty after normalization
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-01 16:37:43 +01:00
Nicolas De Loof
4ea44797f5 only consider containers with config_hash labels (i.e, created by compose)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-03-01 15:46:50 +01:00
Guillaume Lours
a99a0b50ef
Merge pull request #10320 from milas/e2e-win-pause
test: tweak pause test to try and prevent failures in Windows CI
2023-03-01 10:36:11 +01:00
Guillaume Lours
af414e9e2c
Merge pull request #10330 from docker/dependabot/go_modules/github.com/containerd/containerd-1.6.19
build(deps): bump github.com/containerd/containerd from 1.6.18 to 1.6.19
2023-03-01 10:34:25 +01:00
dependabot[bot]
89633748d2 build(deps): bump github.com/containerd/containerd from 1.6.18 to 1.6.19
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.18 to 1.6.19.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.18...v1.6.19)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-01 10:10:11 +01:00
Laura Brehm
f648c2949b
Merge pull request #10329 from docker/dependabot/go_modules/go.opentelemetry.io/otel-1.14.0
build(deps): bump go.opentelemetry.io/otel from 1.13.0 to 1.14.0
2023-02-28 12:50:06 +01:00
dependabot[bot]
33aa6acefe
build(deps): bump go.opentelemetry.io/otel from 1.13.0 to 1.14.0
Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.13.0 to 1.14.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.13.0...v1.14.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-28 10:01:36 +00:00
Milas Bowman
e31b95c16d test: tweak pause test to try and prevent failures in Windows CI
This test keeps failing with a timeout in Windows. I don't actually
think it should take that long to bring up an nginx container, so
I'm guessing that there's something else going on that's causing
trouble.

Increase the verbosity when running Compose commands: I think this
will generally make E2E test failures easier to diagnose by always
logging the full command that's going to be run and also capturing
stdout.

Add a health check and use `--wait` when launching the fixture for
the pause test. Combined with the verbosity increase, this should
make it easier to understand what's going on here.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-02-27 14:20:20 -05:00
Milas Bowman
d4f156cc7d
Merge pull request #10311 from milas/fw-ephemeral
watch: ignore ephemeral files & minor output tweaks
2023-02-27 09:26:18 -05:00
Laura Brehm
c0daf8d3b5
Merge pull request #10316 from docker/dependabot/go_modules/github.com/stretchr/testify-1.8.2
build(deps): bump github.com/stretchr/testify from 1.8.1 to 1.8.2
2023-02-27 11:31:43 +01:00
dependabot[bot]
7bb60d091c
build(deps): bump github.com/stretchr/testify from 1.8.1 to 1.8.2
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.1 to 1.8.2.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.1...v1.8.2)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-27 10:04:52 +00:00
Milas Bowman
da1ca578b5 watch: ignore ephemeral files & minor output tweaks
Big change here is to import the ephemeral ignore set from Tilt.

The `.git` directory is also ignored for now: this restriction
should probably be lifted and made configurable in the future,
but it's not generally important to watch and triggers a LOT of
events (e.g. Git creates `index.lock` files that will appear and
disappear rapidly as terminals/IDEs/etc interact with Git, even
for read-only operations).

The Tilt-provided ephemeral file set has been slowly devised over
time based on temporary files that can cause trouble. We can also
look at a more robust/configurable solution here in the future,
but thse provide a reasonable out-of-the-box configuration for
the moment.

There's also some small tweaks to the output to add missing
newlines in a few edge cases and such.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-02-24 14:34:51 -05:00
Milas Bowman
267cde91df
Merge pull request #10302 from glours/update-golang-x-net
bump golang/x/net to v0.7.0 (CVE-2022-41723)
2023-02-21 14:35:03 -05:00
Guillaume Lours
18af72af87
bump golang/x/net to v0.7.0 (CVE-2022-41723)
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-02-21 18:32:48 +01:00
Nicolas De Loof
e831ea826b add support for restart for depends_on
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-18 12:55:29 +01:00
Milas Bowman
8d56db5e1d
Merge pull request #10287 from docker/dependabot/go_modules/github.com/containerd/containerd-1.6.18
build(deps): bump github.com/containerd/containerd from 1.6.17 to 1.6.18
2023-02-17 11:23:29 -05:00
dependabot[bot]
1edc64ef93
build(deps): bump github.com/containerd/containerd from 1.6.17 to 1.6.18
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.17 to 1.6.18.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.17...v1.6.18)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-17 15:13:16 +00:00
Milas Bowman
156e54a09e
Merge pull request #10291 from docker/dependabot/go_modules/github.com/docker/buildx-0.10.3
build(deps): bump github.com/docker/buildx from 0.10.2 to 0.10.3
2023-02-17 10:11:40 -05:00
Milas Bowman
762cf9d998
Merge pull request #10252 from glours/dry-run-exec-support
support dry-run for exec command
2023-02-17 10:05:31 -05:00
Nicolas De Loof
f3e543fd6a apply config options for pseudo-subcommands
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-17 12:11:18 +01:00
dependabot[bot]
9732608ec2
build(deps): bump github.com/docker/buildx from 0.10.2 to 0.10.3
Bumps [github.com/docker/buildx](https://github.com/docker/buildx) from 0.10.2 to 0.10.3.
- [Release notes](https://github.com/docker/buildx/releases)
- [Commits](https://github.com/docker/buildx/compare/v0.10.2...v0.10.3)

---
updated-dependencies:
- dependency-name: github.com/docker/buildx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-17 10:00:59 +00:00
Nicolas De Loof
24ff098252 compact TUI to monitor layers download progress
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-16 17:55:59 +01:00
Milas Bowman
593c4263f3 ci: bump to Go 1.20.1 and latest deps
* Go v1.20.1
* golangci-lint v1.51.1
* compose-go v1.10.0
* buildx v0.10.2
* BuildKit v0.11.3
* moby v23.0.1

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-02-16 07:26:18 +01:00
Nicolas De Loof
313b82e94c ignore services without a build section
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-14 15:18:44 +01:00
Nicolas De Loof
5e3e2171d4 sort service --hash output by service name
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-14 12:17:00 +01:00
Nicolas De Loof
9ac0392baf introduce --timeout on up
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-14 12:16:41 +01:00
Nicolas De Loof
0612b34c68 introduce --no-deps on restart
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-14 11:30:15 +01:00
Nicolas De Loof
92e0cd4047 also restart dependent services after a service has been restarted
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-14 11:30:15 +01:00
Laura Brehm
1a410ffe30
Merge pull request #10279 from docker/dependabot/go_modules/go.uber.org/goleak-1.2.1
build(deps): bump go.uber.org/goleak from 1.1.12 to 1.2.1
2023-02-14 11:22:59 +01:00
dependabot[bot]
282a29e67e
build(deps): bump go.uber.org/goleak from 1.1.12 to 1.2.1
Bumps [go.uber.org/goleak](https://github.com/uber-go/goleak) from 1.1.12 to 1.2.1.
- [Release notes](https://github.com/uber-go/goleak/releases)
- [Changelog](https://github.com/uber-go/goleak/blob/master/CHANGELOG.md)
- [Commits](https://github.com/uber-go/goleak/compare/v1.1.12...v1.2.1)

---
updated-dependencies:
- dependency-name: go.uber.org/goleak
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-14 10:01:06 +00:00
Nicolas De Loof
256ec49974 exclude unstable labels from config hash
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-13 17:02:28 +01:00
Nicolas De Loof
9765f171cd
store exec details to offer better dry-run status on ExecStart
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-13 11:59:01 +01:00
Nicolas De Loof
b19df5c96c add support for excludes and rebuild
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-10 17:24:48 +01:00
Nicolas De Loof
7a42ba7eec use CGO to enable fsevent on OSX
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-10 17:24:48 +01:00
Milas Bowman
5b043c4d59 ci: don't use -race on Windows
I misunderstood the cause of the symptom in #10261 - thought that
we'd explicitly turned off CGO for Windows with some of the build
changes recently, but we don't even have `gcc` on the CI node, so
it's actually just `-race` entirely that's the trouble.

For right now, going the easy route and disabling it. We can look
at getting a C toolchain on the Windows machine later.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-02-10 15:51:48 +01:00
Milas Bowman
d93da187f2
Merge pull request #10261 from milas/ci-win-e2e
ci: use CGO for tests to enable race detector
2023-02-09 15:52:56 -05:00
Milas Bowman
15f7104cd3 ci: use CGO for tests to enable race detector
```
go: -race requires cgo; enable cgo by setting CGO_ENABLED=1
```

We're explicitly using CGO on macOS now for FSEvents support and
purposefully NOT using CGO on other platforms since we don't need
it.

The race detector (`-race`) requires it, however, so for the e2e
make task, it should alway be on.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-02-09 13:29:51 -05:00
Guillaume Lours
eb1c798912 support dry-run for rm command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-02-09 17:34:10 +01:00
Guillaume Lours
78b9404767 support dry-run for stop command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-02-09 17:34:10 +01:00
Guillaume Lours
25be264ed8 support dry-run for exec command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-02-08 11:21:47 +01:00
Guillaume Lours
e6e2f7839f
Merge pull request #10251 from docker/dependabot/go_modules/go.opentelemetry.io/otel-1.13.0
build(deps): bump go.opentelemetry.io/otel from 1.12.0 to 1.13.0
2023-02-08 10:24:18 +01:00
dependabot[bot]
7532f76986 build(deps): bump go.opentelemetry.io/otel from 1.12.0 to 1.13.0
Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.12.0 to 1.13.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.12.0...v1.13.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-08 10:12:42 +01:00
Guillaume Lours
70ab9f8f33 bump docker engine and cli version to 23.0.0 with buildkit(v0.11.2) and buildx (v0.10.2)
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-02-08 10:11:50 +01:00
Guillaume Lours
7daa2a5325
Merge pull request #10250 from ndeloof/nil_build_args
prevent assignment to entry in nil map
2023-02-07 21:13:29 +01:00
Nicolas De Loof
93bffd9a7f
prevent assignment to entry in nil map
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-07 20:50:15 +01:00
Guillaume Lours
9a4e74c70c
Merge pull request #10209 from ndeloof/wait_containers
use containers we expect to start for wait condition
2023-02-07 16:46:04 +01:00
Nicolas De Loof
52478f0c6e wait on service containers as dependencies to be deterministic
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-07 16:36:45 +01:00
Nicolas De Loof
b5f0a4eefa use containers we expect to start for wait condition
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-07 16:36:45 +01:00
Guillaume Lours
e908f41ec8
Merge pull request #10239 from glours/bump-golang-1.20
bump golang to 1.20
2023-02-06 17:07:40 +01:00
Nicolas De Loof
0f5b5ccbd0 detect replacement container is created and inform printer so it attach and don't stop
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-06 11:23:13 +01:00
Guillaume Lours
a2d36b6c6c bump golang to 1.20
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-02-06 10:19:29 +01:00
Guillaume Lours
b3ec110612
Merge pull request #10242 from jongwooo/ci/replace-deprecated-command-with-environment-file
ci: Replace deprecated command with environment file
2023-02-04 10:38:15 +01:00
jongwooo
3077234292 ci: Replace deprecated command with environment file
Signed-off-by: jongwooo <jongwooo.han@gmail.com>
2023-02-04 13:17:24 +09:00
Guillaume Lours
23585b9e6d
Merge pull request #10235 from glours/dry-run-cp-support
support dry-run for cp command
2023-02-03 22:57:26 +01:00
Guillaume Lours
fdc1738143 add log when copying files/directories between host and containers (both way)
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-02-03 22:44:26 +01:00
Guillaume Lours
2336d9fe35 support dry-run for cp command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-02-03 22:44:26 +01:00
Milas Bowman
bf0ed9a4d4
Merge pull request #10226 from benmoss/add-remote-builder
Add remote buildx driver
2023-02-03 15:03:49 -05:00
Nicolas De Loof
1640f155e9 initial support for sync
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-02 14:59:30 +01:00
Nicolas De Loof
e63cbfba0e use tilt watcher to track filesystem changes
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-02 14:59:30 +01:00
Nicolas De Loof
25576289c8 adjust code and dependencies
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-02 14:59:30 +01:00
Nick Santos
7d6ee74e62 cleanup deprecated ioutil functions (#5919)
Signed-off-by: Nick Santos <nick.santos@docker.com>

Signed-off-by: Nick Santos <nick.santos@docker.com>
2023-02-02 14:59:30 +01:00
Nick Santos
c08e07714a watch: optimization to help avoid inotify nodes for large file trees (#5769)
fixes https://github.com/tilt-dev/tilt/issues/5764
2023-02-02 14:59:30 +01:00
Matt Landis
cf31462398 tests: make test fixtures responsible for tearing themselves down (#5512) 2023-02-02 14:59:30 +01:00
Ken Sipe
1b71e3efb3 lint: fix local-prefixes for goimports (#5453)
Fix local-prefixes on linters imports then resolved imports to be as expected

Signed-off-by: Ken Sipe <kensipe@gmail.com>
2023-02-02 14:59:30 +01:00
Milas Bowman
4d822676ce ci: add exportloopref linter and upgrade to golangci-lint v1.43.0 (#5281)
`exportloopref` - detects captures of loop variable without
re-assignment

NOTE: There can be false negatives with this linter to avoid being
            overly strict and annoying!

Also upgraded `golangci-lint` to latest (v1.43.0 published 2021-11-03).
2023-02-02 14:59:30 +01:00
Milas Bowman
6fc0b6ff27 build: ensure file handles properly closed (#5298)
I've been running the test suite (`./internal/engine` in particular)
with `-count X` a lot recently to catch timing-related test failures.

After running enough times, the tests start failing due to too many
open files, so I did an audit and found a few places where files or
readers weren't always being closed.
2023-02-02 14:59:30 +01:00
Nick Sieger
ab84b6ac5b Fix local go_lintfix errors (#5191)
* lint: add make lintfix and run it

Fixes all errors like:
```
File is not `goimports`-ed with -local github.com/tilt-dev/tilt (goimports)
```

* git: change to use TrimSuffix

* build: remove unnecessary cast
2023-02-02 14:59:30 +01:00
Milas Bowman
7161778ccf watch: use WalkDir to speed up file listing (#4684)
`WalkDir` is new in Go 1.16 and avoids calling `os.Lstat` on
every visited file and directory. In most cases, we don't need
that info, so this will help reduce I/O when listing files,
which can be helpful for particularly big monorepos.
2023-02-02 14:59:30 +01:00
Nick Santos
1f5bfe8882 test: clean up test loggers a bit (#4580) 2023-02-02 14:59:30 +01:00
Milas Bowman
f79c75ab10 test: fix lint errors on Darwin (macOS) (#4247)
Unused code linter isn't particularly smart about platform build
tags, so since this func is only used by the "naive" (non-macOS)
file watcher, it needs to live with that or it gets flagged as
dead code when linting on macOS.
2023-02-02 14:59:30 +01:00
Nick Santos
e62993a854 test: enable unused check, remove dead code (#4208) 2023-02-02 14:59:30 +01:00
Nick Santos
28251e8be5 watch: improve error messages when you run out of inotify instances (#3960) 2023-02-02 14:59:30 +01:00
Nick Santos
c7ba7d9de5 dockerignore: convert ignore patterns to absolute paths [ch9237] (#3743)
In most places in Tilt, we try to use absolute paths everywhere.
So this makes things more consistent with the rest of Tilt, and lets us be
a bit more flexible in how we handle subdirs and parent dirs in ignores.

Fixes https://github.com/tilt-dev/tilt/issues/3740
2023-02-02 14:59:30 +01:00
Nick Santos
8b39322365 watch: fix a dumb errcheck (#3622) 2023-02-02 14:59:30 +01:00
Nick Santos
b3615d64e2 watch: increase the windows watch i/o buffer (#3620)
fixes https://github.com/tilt-dev/tilt/issues/3556
2023-02-02 14:59:30 +01:00
Nick Santos
1a1d1707ed change org name from windmilleng to tilt-dev (#3346) 2023-02-02 14:59:30 +01:00
Nick Santos
fd3e0bbe2b watch: use the recursive watcher on windows (#3306) 2023-02-02 14:59:30 +01:00
Nick Santos
d2d4d05264 Revert "watch: fix inotify tests on windows" (#3147)
This reverts commit 74ac7997b1c8f497babbbd499ff1f047563d699a.
2023-02-02 14:59:30 +01:00
Nick Santos
dda0362b6e watch: fix inotify tests on windows (#3140) 2023-02-02 14:59:30 +01:00
Nick Santos
ddc88ec41b circleci: run make shorttest on windows. flag off a large swath of broken tests (#3132) 2023-02-02 14:59:30 +01:00
Matt Landis
92c6a65a03 tilt: enable errcheck on tests (#2877) 2023-02-02 14:59:30 +01:00
Dan Miller
00b3caecbb ci: enable staticcheck, fix problems that were surfaced (#2809) 2023-02-02 14:59:30 +01:00
Dan Miller
17087447e9 logger: move to pkg (#2031) 2023-02-02 14:59:30 +01:00
Nick Santos
ec781687fd watch: add retry counts to fsync (#2023) 2023-02-02 14:59:30 +01:00
Nick Santos
b22dde9f18 dockerignore: improve MatchesEntireDir (#1865) 2023-02-02 14:59:30 +01:00
Nick Santos
a31350ede1 watch: move more of the directory-skipping logic into the interface (#1864) 2023-02-02 14:59:30 +01:00
Nick Santos
d744c97f13 watch: add a simple check when there are no exclusions (#1863) 2023-02-02 14:59:30 +01:00
Nick Santos
37647bc600 watch: skip setup if nothing is being watched (#1861) 2023-02-02 14:59:30 +01:00
Nick Santos
21e5d564af watch: FileEvents must always be absolute (#1841)
there were a lot of confused tests that were using relative paths, then trying to workaround this
2023-02-02 14:59:30 +01:00
Nick Santos
390d5cf165 watch: add tests for ignores and number of watches (#1838) 2023-02-02 14:59:30 +01:00
Nick Santos
7f6e189dbc watch: change the watcher interface to better match how we actually use it (#1835) 2023-02-02 14:59:30 +01:00
Dan Miller
b5ccea7b0e watch: record num watches in expvars (#1795) 2023-02-02 14:59:30 +01:00
Matt Landis
47551895f3 makefile: fix goimports -local (#1763) 2023-02-02 14:59:30 +01:00
Nick Santos
5e0f1eec16 watch: fix spurious errors while watching (#1726) 2023-02-02 14:59:30 +01:00
Dan Bentley
f82e2de57e watch: don't watch each individual file (#1613) 2023-02-02 14:59:30 +01:00
Matt Landis
9c7f7bc0fa live_update: error if syncing from outside of docker context (#1396) 2023-02-02 14:59:30 +01:00
Nick Santos
6defe7cac6 watch: tfw you have a test that asserts broken file-watch behavior 😢 (#1354) 2023-02-02 14:59:30 +01:00
Dan Miller
0482f9276a watch: add watch function that traverses up directory structure recursively (#1013) 2023-02-02 14:59:30 +01:00
Nick Santos
e8a34c8d1e watch: remove inotify-specific bits of watcher_linux (#890)
the tests on windows don't pass yet, but at least it compiles
2023-02-02 14:59:30 +01:00
Nick Santos
9e261c18b3 watch: fix a bug when a file and its ancestor both have direct watches (#863) 2023-02-02 14:59:30 +01:00
Nick Santos
1fd7ca5440 testing: update internal/watch to use the tempdir fixture (#862) 2023-02-02 14:59:30 +01:00
Maia McCormick
139edc403f cleanup: wrap errors properly (#772)
* cleanup: wrap errors properly

* fix build error

* asdfg linux

* fix test
2023-02-02 14:59:30 +01:00
Dan Miller
38b3f3b678 watch: use sinceWhen and HistoryDone to avoid spurious events (#557)
Here's our new watch strategy on Darwin in a nutshell:

1. Create an fsevents stream for events "since" the last event ID that
we saw globally.
2. Add a path that we want to watch
3. Add that path to a map of paths that we're watching _directly_.
4. Restart the event stream to pick up the new path.
5. Ignore all events for all watches until we've seen a `HistoryDone`
event.
6. Ignore the first `ItemCreated` event for paths we're watching that
are also directories
7. Otherwise, forward along all events.
2023-02-02 14:59:30 +01:00
Nick Santos
c5bce8bd42 watch: fix a spurious error (#344) 2023-02-02 14:59:30 +01:00
Nick Santos
c8a358a455 watch: try a slightly different ignore strategy (#174) 2023-02-02 14:59:30 +01:00
Nick Santos
a6701652d2 watch: fix more data races on darwin (#166) 2023-02-02 14:59:30 +01:00
Nick Santos
4562b0bf95 watch: a new strategy for handling spurious events, hoping to fix race conditions (#163) 2023-02-02 14:59:30 +01:00
Nick Santos
4801d2b1a4 watch: fix a flaky test by ignoring spurious events correctly (#162) 2023-02-02 14:59:30 +01:00
Nick Santos
3850a34114 watch: fix a segfault on linux (#148) 2023-02-02 14:59:30 +01:00
Nick Santos
664e6f6f23 watch: stop skipping tests (#145) 2023-02-02 14:59:30 +01:00
Nick Santos
d4f074b32f watch: simplify the fileEvent interface to only contain paths (#144) 2023-02-02 14:59:30 +01:00
Dan Miller
a3b012d89f add errcheck (#93) 2023-02-02 14:59:30 +01:00
Matt Landis
a755c84ea0 tilt: copy watch code from tesseract 2023-02-02 14:59:30 +01:00
Ben Moss
ef34a38ac0
Add remote buildx driver
Signed-off-by: Ben Moss <ben@mossity.com>
2023-02-01 10:30:07 -05:00
Guillaume Lours
f24d3458c6
Merge pull request #10217 from glours/dry-run-pause-support
Dry run pause support
2023-01-31 14:56:27 +01:00
Nicolas De Loof
41e056341b rename convert to config to align with compose v1 UX
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-30 22:23:53 +01:00
Guillaume Lours
a54d488303
Merge pull request #10215 from docker/dependabot/go_modules/go.opentelemetry.io/otel-1.12.0
build(deps): bump go.opentelemetry.io/otel from 1.11.2 to 1.12.0
2023-01-30 16:03:43 +01:00
dependabot[bot]
c0b4dd8606 build(deps): bump go.opentelemetry.io/otel from 1.11.2 to 1.12.0
Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.11.2 to 1.12.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.11.2...v1.12.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-30 15:52:18 +01:00
Guillaume Lours
6754c6b68a add dry-run support of pause and unpause commands
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-01-30 10:36:36 +01:00
Guillaume Lours
a93f09efac
Merge pull request #10210 from glours/dry-run-kill-support
Dry run kill support
2023-01-30 10:35:33 +01:00
Guillaume Lours
bbf3ec1999
Merge pull request #10216 from docker/dependabot/go_modules/github.com/containerd/containerd-1.6.16
build(deps): bump github.com/containerd/containerd from 1.6.15 to 1.6.16
2023-01-30 10:23:34 +01:00
dependabot[bot]
51bcfa37bd
build(deps): bump github.com/containerd/containerd from 1.6.15 to 1.6.16
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.15 to 1.6.16.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.15...v1.6.16)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-30 09:12:29 +00:00
Guillaume Lours
982a8ccb88 support dry-run for kill command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-01-30 09:27:17 +01:00
Guillaume Lours
790712fa92 update tty and plain text writers to support dry run mode
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-01-30 09:27:17 +01:00
Guillaume Lours
97752b23e8 refresh Maintainers list
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-01-28 06:37:17 +01:00
Laura Brehm
69c0a583be
Merge pull request #10208 from laurazard/add-scale-create 2023-01-27 15:26:01 +01:00
Guillaume Lours
8bb9a3336d
Merge pull request #10148 from maxcleme/feat/support_multiarch_push
Support for docker compose build --push
2023-01-26 17:05:41 +01:00
maxcleme
634a7d2a7b Support for docker compose build --push when using multiple platforms
Signed-off-by: maxcleme <maxime.clement@docker.com>
2023-01-26 16:54:41 +01:00
Guillaume Lours
cf12239547
Merge pull request #10207 from ndeloof/tail_n
alias -n for --tail to align with docker CLI
2023-01-26 14:06:29 +01:00
Laura Brehm
a288332fbd
Update docs to add --scale argument to compose create
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-01-26 13:03:49 +01:00
Laura Brehm
9d53ed8f63
Add --scale to compose create, refactor scale option
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-01-26 13:03:34 +01:00
AhmedGrati
df70735295 Fix: Handle concurrent threads using mutex on the rainbowColor function
Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
2023-01-26 12:53:56 +01:00
AhmedGrati
d8bf175cd4 Remove unecessary files
Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
2023-01-26 12:53:56 +01:00
AhmedGrati
4816f40b90 Fix: remove the infinite goroutine
Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
2023-01-26 12:53:56 +01:00
AhmedGrati
ed5a2e83c7 Remove unecessary files
Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
2023-01-26 12:53:56 +01:00
AhmedGrati
fa8d075d88 Fix: remove the infinite goroutine
Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
2023-01-26 12:53:56 +01:00
Nicolas De Loof
33c3f4dfad
alias -n for --tail to align with docker CLI
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-26 10:00:58 +01:00
Nicolas De Loof
aa31387355 cleanup TUI lines after switching to "compact" mode
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-26 07:56:49 +01:00
Laura Brehm
d47f0f31c2 Update docs to mention COMPOSE_PARALLEL_LIMITS and ways to configure parallelism
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-01-24 17:01:15 +01:00
Guillaume Lours
ac8ab8634a
Merge pull request #10195 from ndeloof/ps_docs
fix docs to reflect docker compose ps being aligned with docker ps
2023-01-24 11:21:20 +01:00
Nicolas De Loof
4721c01702 fix docs to reflect docker compose ps being aligned with docker ps
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-24 11:11:20 +01:00
Nicolas De loof
5919fcb4cd Revert "Fix Goroutine leak in v2/command/formatter" 2023-01-24 10:48:27 +01:00
Guillaume Lours
4671e69a96
Merge pull request #10192 from AhmedGrati/10157-fix-goroutine-leak
Fix Goroutine leak in v2/command/formatter
2023-01-23 14:33:14 +01:00
AhmedGrati
3a21e1e319 Fix Linting Issues
Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
2023-01-23 10:50:56 +01:00
AhmedGrati
b670aefb94 Feat: Clean inifinite Goroutine
Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
2023-01-22 22:03:52 +01:00
Guillaume Lours
d5d9f67547
Merge pull request #10173 from glours/dry-run
Skeleton for dry-run under alpha command
2023-01-20 15:37:52 +01:00
Guillaume Lours
a2899d5ff0
Merge pull request #10181 from laurazard/fix-log-f
Fix issue where `compose logs` doesn't exit when all running containers have been stopped
2023-01-20 14:11:31 +01:00
Laura Brehm
220626ec5e
Only account running containers for logs
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-01-20 13:30:05 +01:00
Guillaume Lours
6c795d60bf
Merge pull request #10186 from glours/bump-compose-go-1.9.0
bump compose-go to version v1.9.0
2023-01-20 11:23:04 +01:00
Guillaume Lours
291e1bd618
bump compose-go to version v1.9.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-01-20 10:58:46 +01:00
Nicolas De Loof
e94eb056b4 allow a TTY to be allocated with -t
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-19 16:53:09 +01:00
Nicolas De Loof
c15bf1955a debounce refresh requests with quietperiod
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-18 22:12:54 +01:00
Laura Brehm
0b1c86726e Add tests for filtering containers not created by Compose
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-01-17 19:00:02 +01:00
Laura Brehm
82ef998511 Ignore containers created outside compose
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-01-17 19:00:02 +01:00
Guillaume Lours
fb36f7fffd directly embed the orignal APIClient in the DryRunClient
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-01-16 11:11:35 +01:00
Guillaume Lours
3fac506a30 identify functions which need to be ovorridden for dry run feature
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-01-16 11:11:35 +01:00
Guillaume Lours
eb59b0e265 add alpha command to test dry-run
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-01-16 11:11:35 +01:00
Guillaume Lours
5081ab0507 create custom CLI when dry-run mode active
update documentation

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-01-16 11:11:35 +01:00
Guillaume Lours
13ef440d6a add DryRun API Client with delagation pattern
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-01-16 11:11:35 +01:00
Guillaume Lours
fbf845c5f8 add dry-run flag
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-01-16 11:11:35 +01:00
Guillaume Lours
5a2b7b83cd use compose service methods when exist instead of directly service.dockerCli
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-01-13 21:02:00 +01:00
Nicolas De Loof
8c07fa4d25 mark alpha command as experimental
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-12 14:44:18 +01:00
Laura Brehm
db267d86c1
Merge pull request #10169 from laurazard/fix-terminal-height
Adjust terminal height calc
2023-01-12 11:21:34 +01:00
Laura Brehm
9daf41892f
Adjust terminal height calc
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-01-12 11:20:05 +01:00
Laura Brehm
2aa88b5c9e
Merge pull request #10149 from TColl/typo-fix
fix typo
2023-01-12 10:56:28 +01:00
Nicolas De Loof
bb9cf32245 introduce experimental watch command (skeletton)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-12 10:52:58 +01:00
Laura Brehm
7212aaff2e
Merge pull request #10166 from matthewarmand/run-remove-orphans
Add remove-orphans functionality to run
2023-01-12 10:18:47 +01:00
Laura Brehm
69a09624c9 Skip child events when printer events > terminal height
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-01-12 09:52:25 +01:00
Tom Collingwood
f2088bb917 fix typo
Signed-off-by: Tom Collingwood <tomcollingwood@yahoo.co.uk>
2023-01-11 19:07:29 +00:00
Matt Armand
dadad01e63 Update docs programatically like you're supposed to
Signed-off-by: Matt Armand <marmand68@gmail.com>
2023-01-11 13:20:30 -05:00
Matt Armand
1adc9f54d5 fix docs yaml
Signed-off-by: Matt Armand <marmand68@gmail.com>
2023-01-11 12:24:15 -05:00
Matt Armand
4cebce3a5c This option lives in the create options, not the run options
Signed-off-by: Matt Armand <marmand68@gmail.com>
2023-01-11 12:07:51 -05:00
Matt Armand
bd8e57447a Add remove-orphans functionality to run, because it recommends that in error messages
Signed-off-by: Matt Armand <marmand68@gmail.com>
2023-01-11 10:31:56 -05:00
Laura Brehm
4ad87463c5 Add 🥒 GHA workflow
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-01-11 14:13:10 +01:00
Laura Brehm
62b3e7409e
Merge pull request #10124 from laurazard/fix-cucumber-tests
Fix Cucumber 🥒 tests
2023-01-11 13:00:04 +01:00
Nicolas De Loof
cc912c625d introduce --remove-orphans in compose create command
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-11 07:16:50 +01:00
Laura Brehm
cc7e69c02d
Merge pull request #10142 from docker/dependabot/go_modules/github.com/containerd/containerd-1.6.15
build(deps): bump github.com/containerd/containerd from 1.6.14 to 1.6.15
2023-01-10 12:44:46 +00:00
Nicolas De Loof
3e12a7cb23 pass proxy config as build args - same as docker/buildx#959
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-10 12:15:13 +01:00
Ulysses Souza
0c1979979f Remove unused kube tag
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2023-01-09 14:52:11 +01:00
Guillaume Lours
00c60da331
Merge pull request #10151 from freeformz/ffz/NoShareMap
Don't share the options map
2023-01-09 12:13:48 +01:00
Edward Muller
73ebbffb08 Don't share the options map
Without this I get an exception when building multiple images in a
compose run.

```
fatal error: concurrent map writes

goroutine 16 [running]:
github.com/docker/compose/v2/pkg/compose.(*composeService).build.func1({0x2cba4e0, 0xc00019b2c0}, {0xc000233150?, 0xd?})
        github.com/docker/compose/v2/pkg/compose/build.go:95 +0x652
github.com/docker/compose/v2/pkg/compose.(*graphTraversal).run.func1()
        github.com/docker/compose/v2/pkg/compose/dependencies.go:127 +0x63
golang.org/x/sync/errgroup.(*Group).Go.func1()
        golang.org/x/sync@v0.1.0/errgroup/errgroup.go:75 +0x64
created by golang.org/x/sync/errgroup.(*Group).Go
        golang.org/x/sync@v0.1.0/errgroup/errgroup.go:72 +0xa5
...
```

I'm not sure why the map is currently shared, but with this patch
applied my docker-compose build run works.

Signed-off-by: Edward Muller <emuller@fastly.com>
2023-01-09 12:01:57 +01:00
Guillaume Lours
fbbc0dedcf
Merge pull request #10145 from ndeloof/ps_filter
don't filter by services if no filter was set
2023-01-09 12:01:28 +01:00
Nicolas De Loof
b326a9da1d
don't filter by services if no filter was set
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-09 11:49:08 +01:00
Nicolas De Loof
f1313f3a09 use a simpler prompt implementation when we lack a terminal
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-09 10:28:16 +01:00
fsl
a226d014b8 fix CVE-2022-27664 and CVE-2022-32149 high-risk vulnerability
Signed-off-by: fsl <1171313930@qq.com>
2023-01-06 19:32:12 +01:00
dependabot[bot]
7e2af3aa81
build(deps): bump github.com/containerd/containerd from 1.6.14 to 1.6.15
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.14 to 1.6.15.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.14...v1.6.15)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-06 09:06:22 +00:00
Nicolas De Loof
96bbda98f8 add support for uts namespace
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-06 08:15:52 +01:00
Guillaume Lours
f6f29a4438
Merge pull request #10133 from ndeloof/build_concurrency
limit build concurrency according to --parallel
2023-01-05 09:57:13 +01:00
Nicolas De Loof
aa5cdf2bf9 add support for COMPOSE_PARALLEL_LIMIT (parity with Compose v1)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-04 12:42:49 +01:00
Nicolas De Loof
d5e4f00644 introduce --no-attach to ignore some service output
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-03 18:43:40 +01:00
Nicolas De Loof
8b4ac37f9c introduce --ignore-buildable to ignore buildable images on pull
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-03 18:43:23 +01:00
Nicolas De Loof
b96e27e0e7 limit build concurrency according to --parallel
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-01-03 12:01:30 +01:00
Guillaume Lours
dcbd68a102
Merge pull request #10136 from gtardif/fix_race_delete_orphan_containers
Ignore not only auto-removed containers but also "removal in progress" for orphan containers
2023-01-03 11:30:04 +01:00
Guillaume Tardif
37d15d7e6b Ignore not only auto-removed containers but also "removal in progress" for orphan containers
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
2023-01-03 11:09:41 +01:00
Laura Brehm
dde7eea212
Update expected Cucumber compose ps output to match changes
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-12-30 15:07:58 +00:00
Laura Brehm
a224780795 Set pullChanged when setting --pull on compose up
Add e2e tests

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-12-30 13:56:06 +01:00
Ákos Takács
ffce33ec11 Fix empty file when using compose config in case of smaller source files
"docker compose config --output out.yml" resulted an empty file
when the generated output was smaller than 4097 bytes.
bufio.Writer doesn't seem necessary since only one write operation will happen.
This way there is no need for a new bufio.Writer that could be flushed.

Thanks for @thaJeztah for the idea of using os.WriteFile

Issue https://github.com/docker/compose/issues/10121

Signed-off-by: Ákos Takács <takacs.akos@it-sziget.hu>
2022-12-30 13:51:36 +01:00
Laura Brehm
1d9657aee2
Merge pull request #10127 from docker/dependabot/go_modules/github.com/docker/cli-docs-tool-0.5.1
build(deps): bump github.com/docker/cli-docs-tool from 0.5.0 to 0.5.1
2022-12-29 13:42:43 +00:00
Laura Brehm
8a3248d0cd
Update documentation
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-12-29 13:32:16 +00:00
dependabot[bot]
52e7f0fb3e
build(deps): bump github.com/docker/cli-docs-tool from 0.5.0 to 0.5.1
Bumps [github.com/docker/cli-docs-tool](https://github.com/docker/cli-docs-tool) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/docker/cli-docs-tool/releases)
- [Commits](https://github.com/docker/cli-docs-tool/compare/v0.5.0...v0.5.1)

---
updated-dependencies:
- dependency-name: github.com/docker/cli-docs-tool
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-29 09:06:01 +00:00
Guillaume Lours
fd353ffa94 add support of privileged attribut in service.build section
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-12-23 09:32:48 +01:00
Guillaume Lours
0307c16daf
Merge pull request #10116 from glours/add-buildx-plugin-e2e
cleanup framework.go from uncessary debug logs
2022-12-21 21:39:23 +01:00
Guillaume Lours
adf8e75317 cleanup framework.go from uncessary debug logs
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-12-21 21:28:06 +01:00
Guillaume Lours
6c537cc0f4
Merge pull request #10113 from glours/add-buildx-plugin-e2e
add buildx plugin to e2e configuration directory
2022-12-21 21:21:01 +01:00
Nicolas De Loof
9f7ad18d62 reduce cyclomatic complexity
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-21 21:12:06 +01:00
Nicolas De Loof
40ebcd6203 fix security opts support (seccomp and unconfined)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-21 21:12:06 +01:00
Nicolas De Loof
9bd9f1765c check service names based on project, not running containers
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-21 21:11:44 +01:00
Guillaume Lours
5dcadc05d9
debut output for CI
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-12-21 21:09:49 +01:00
Guillaume Lours
c72f161afb
change the way finding the just built compose binary
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-12-21 19:47:39 +01:00
Guillaume Lours
86a648bd51
e2e tests display Compose version used to run the test
currently the version displayed is the one installed and not the one use for the tests

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-12-21 18:38:24 +01:00
Guillaume Lours
27a3241934
rely on CI timeout
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-12-21 16:11:56 +01:00
Guillaume Lours
935968fe2c
add buildx plugin to e2e configuration directory
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-12-21 15:27:34 +01:00
Nicolas De Loof
91371fef7a remove flaky TestLocalComposeLogsFollow
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-21 08:45:41 +01:00
Nicolas De Loof
986bc44549 service hash MUST exclude replicas
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-21 08:45:41 +01:00
Nicolas De Loof
24f83271f2 don't assume os.Stdout and rely on dockerCLI.streams
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-20 23:52:25 +01:00
Nicolas De Loof
dacf24374d
dump stdout to help diagnose flaky test
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-20 23:50:58 +01:00
Guillaume Lours
bab3050984
Merge pull request #10107 from ndeloof/logging_driver_none
don't fail `logs` when driver:none is set
2022-12-20 16:42:52 +01:00
Nicolas De Loof
22d2e83896
don't fail logs when driver:none is set
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-20 16:23:47 +01:00
Guillaume Lours
9f5f0b6f03
Merge pull request #10106 from ndeloof/cgroupns
update compose-go
2022-12-20 14:18:15 +01:00
Nicolas De Loof
b4b7319901
introduce support for cgroup namespace
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-20 14:06:33 +01:00
Guillaume Lours
ab791877ef
Merge pull request #10105 from docker/dependabot/go_modules/github.com/containerd/containerd-1.6.14
build(deps): bump github.com/containerd/containerd from 1.6.12 to 1.6.14
2022-12-20 10:17:46 +01:00
dependabot[bot]
aae5ddca27
build(deps): bump github.com/containerd/containerd from 1.6.12 to 1.6.14
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.12 to 1.6.14.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.12...v1.6.14)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-20 09:06:44 +00:00
Guillaume Lours
7cf6d5ec4e
Merge pull request #10104 from ndeloof/logs_race_condition
fix race condition on compose logs
2022-12-20 09:54:57 +01:00
Nicolas De Loof
0ab5079c1a
fix race condition on compose logs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-20 09:21:31 +01:00
Tiger Wang
89ef8198f3 update projectOptions to be public by renaming it to ProjectOptions
Signed-off-by: Tiger Wang <tigerwang@outlook.com>
2022-12-20 08:53:27 +01:00
Nicolas De Loof
b8bbdcd872 detect dependency failed to start
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-19 16:26:39 +01:00
Guillaume Lours
9d12eec148
Merge pull request #10100 from ndeloof/cpus
set CPU quota
2022-12-19 15:15:41 +01:00
Nicolas De Loof
d0e95ccac3
set CPU quota
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-19 15:05:09 +01:00
Guillaume Lours
1e682a40ac
Merge pull request #10099 from laurazard/use-defaultplatform-create
Use `DOCKER_DEFAULT_PLATFORM` to determine platform when creating container
2022-12-19 14:17:49 +01:00
Laura Brehm
7bc27d441b
Use DOCKER_DEFAULT_PLATFORM to determine platform when creating container
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-12-19 11:58:03 +00:00
Nicolas De Loof
c1ce53c972 fix regression running pull --ignore-pull-failures
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-19 11:56:03 +01:00
Nicolas De Loof
e42673daed only list running containers when --all=false
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-16 21:46:55 +01:00
Milas Bowman
c37182b2c5
Merge pull request #10090 from milas/fix-wcow-volume
volume: fix WCOW volume mounts
2022-12-16 13:43:04 -05:00
Milas Bowman
ffb95449a2 volume: fix WCOW volume mounts
Do not use the older `Volumes` field in the API; instead rely on
the more robust `Mounts`. For Linux containers, it seems that it's
fine to set both of these. For Windows containers (WCOW), however,
there appears to be a Moby bug that causes it to normalize the
anonymous (`Volumes`) variant to lowercase, which can result in
duplicative volume definitions and an error when trying to start
the container.

Fixes #9577.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-12-16 09:52:34 -05:00
Guillaume Lours
0eaa249222
Merge pull request #10084 from ndeloof/secret_uid
apply uid/gid when creating secret from environment
2022-12-15 16:26:19 +01:00
Nicolas De Loof
5c1484ece6 apply uid/gid when creating secret from environment
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-15 15:54:04 +01:00
Guillaume Lours
0fedddb008
Merge pull request #10083 from ndeloof/nodeps
use recently introduced `withSelectedServicesOnly` to reduce code duplication
2022-12-15 15:51:29 +01:00
Guillaume Lours
aa0720f7e5
Merge pull request #10062 from ndeloof/9554
load project from files when explicitly set by user
2022-12-15 15:50:36 +01:00
Nicolas De Loof
84984864c8 load project from explicit --files when set
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-15 15:38:41 +01:00
Nicolas De Loof
8566daa96e use recently introduced withSelectedServicesOnly to reduce code duplication
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-15 15:38:18 +01:00
Guillaume Lours
1b1f783e99
Merge pull request #10076 from ndeloof/timestamp
introduce --timestamp option on compose up
2022-12-15 15:36:56 +01:00
Nicolas De Loof
84ea395d5d introduce --timestamp option on compose up
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-15 12:14:22 +01:00
Gabriel Féron
1cb5536a2e Address review comments
Signed-off-by: Gabriel Féron <g@leirbag.net>
2022-12-15 11:42:14 +01:00
Gabriel Féron
e4850d9c48 Add --include-deps to push command
Signed-off-by: Gabriel Féron <g@leirbag.net>
2022-12-15 11:42:14 +01:00
Nicolas De Loof
8c39b5b7fd align --format flag and UX with docker cli
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-14 22:53:43 +01:00
Nicolas De Loof
bc568eeb9b align compose ps output with docker ps
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-14 22:53:43 +01:00
Sebastiaan van Stijn
a501ab3a2f use StatusError from docker/cli, not "dockerd"
This package is a leftover from when the "docker" cli and the "dockerd"
cli both lived in the same repository. The package in docker/docker will
be (re)moved soon, so replace it with the implementation in docker/cli,
which is the right one :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-14 22:53:18 +01:00
Nicolas De Loof
d4a4dcf4ee resolve --env-file as absolute path
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-14 09:43:32 +01:00
Nicolas De Loof
05e987dd0a fix parsing of repository:tag
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-14 09:23:07 +01:00
Nicolas De Loof
0368f19030 distinguish stdout and stderr in up logs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-13 14:42:42 +01:00
Nicolas De Loof
3ee2ab87bb ContainerStart must run sequentially for engine to assing distinct ports within configured range
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-12 16:08:50 +01:00
Nicolas De Loof
8f991a20db Fix corner case when there's no container to attach to
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-09 10:02:56 +01:00
Nicolas De Loof
0234e13454 Don't stop pull for images that can be built
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-08 21:20:04 +01:00
Joyce Brum
c342891f3e Squashed commit of the following:
commit 72293cbe879bcd1fff610eace6929922c4a4d668
Author: Joyce Brum <joycebrum@google.com>
Date:   Thu Nov 3 10:20:52 2022 -0300

    fix: upgrade scorecard action to 2.0.6

    Signed-off-by: Joyce Brum <joycebrum@google.com>

commit 39451ef36f4ce71053c59c3a238d95752be05136
Author: Joyce <joycebrumu.u@gmail.com>
Date:   Wed Sep 14 17:52:59 2022 -0300

    Change to the original repository

    Signed-off-by: Joyce <joycebrumu.u@gmail.com>
    Signed-off-by: Joyce Brum <joycebrum@google.com>

commit ddcccaa14b8ef928a4bc8ba38429d8a442806ae9
Author: Joyce <joycebrumu.u@gmail.com>
Date:   Wed Sep 14 17:51:26 2022 -0300

    Add scorecard badge

    Signed-off-by: Joyce <joycebrumu.u@gmail.com>
    Signed-off-by: Joyce Brum <joycebrum@google.com>

commit 8ac265f0ee197e30862c0510b01dce2bc350e129
Author: Joyce <joycebrumu.u@gmail.com>
Date:   Wed Sep 14 17:49:49 2022 -0300

    Configure Scorecard action 2.0.3

    Signed-off-by: Joyce <joycebrumu.u@gmail.com>

Signed-off-by: Joyce Brum <joycebrum@google.com>
2022-12-08 21:11:39 +01:00
Guillaume Lours
40fb42e0c9
Merge pull request #10055 from docker/dependabot/go_modules/github.com/containerd/containerd-1.6.12
build(deps): bump github.com/containerd/containerd from 1.6.10 to 1.6.12
2022-12-08 20:08:34 +01:00
dependabot[bot]
8ef3494711 build(deps): bump github.com/containerd/containerd from 1.6.10 to 1.6.12
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.10 to 1.6.12.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.10...v1.6.12)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-08 19:56:57 +01:00
Guillaume Lours
be74c90f50
Merge pull request #10059 from glours/remve-e2e-go.mod
remove go.* from e2e tests directory
2022-12-08 19:56:34 +01:00
Guillaume Lours
cc247fdb84 remove go.* from e2e tests directory
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-12-08 19:06:22 +01:00
nitin mewar
a4ac6ab694 added table of contents inside readme
Signed-off-by: nitin mewar <nitinmewar28@gmail.com>
2022-12-08 17:02:38 +01:00
Milas Bowman
a5823b12f9
Merge pull request #10048 from thaJeztah/update_go_1.19.4
update to go1.19.4
2022-12-07 17:13:35 -05:00
Milas Bowman
b27ace6c55
Merge pull request #10051 from ndeloof/9897
fix race condition collecting pulled images IDs
2022-12-07 17:12:39 -05:00
Nicolas De Loof
a73dce44b3 fix race condition collecting pulled images IDs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-07 21:33:44 +01:00
Nicolas De Loof
804d7163a7 detect required service are gone to stop watching
explicit API to stop the log printer

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-07 21:07:27 +01:00
Sebastiaan van Stijn
cc60026c7b
update to go1.19.4
Includes security fixes for net/http (CVE-2022-41717, CVE-2022-41720),
and os (CVE-2022-41720).

These minor releases include 2 security fixes following the security policy:

- os, net/http: avoid escapes from os.DirFS and http.Dir on Windows

  The os.DirFS function and http.Dir type provide access to a tree of files
  rooted at a given directory. These functions permitted access to Windows
  device files under that root. For example, os.DirFS("C:/tmp").Open("COM1")
  would open the COM1 device.
  Both os.DirFS and http.Dir only provide read-only filesystem access.

  In addition, on Windows, an os.DirFS for the directory \(the root of the
  current drive) can permit a maliciously crafted path to escape from the
  drive and access any path on the system.

  The behavior of os.DirFS("") has changed. Previously, an empty root was
  treated equivalently to "/", so os.DirFS("").Open("tmp") would open the
  path "/tmp". This now returns an error.

  This is CVE-2022-41720 and Go issue https://go.dev/issue/56694.

- net/http: limit canonical header cache by bytes, not entries

  An attacker can cause excessive memory growth in a Go server accepting
  HTTP/2 requests.

  HTTP/2 server connections contain a cache of HTTP header keys sent by
  the client. While the total number of entries in this cache is capped,
  an attacker sending very large keys can cause the server to allocate
  approximately 64 MiB per open connection.

  This issue is also fixed in golang.org/x/net/http2 vX.Y.Z, for users
  manually configuring HTTP/2.

  Thanks to Josselin Costanzi for reporting this issue.

  This is CVE-2022-41717 and Go issue https://go.dev/issue/56350.

View the release notes for more information:
https://go.dev/doc/devel/release#go1.19.4

And the milestone on the issue tracker:
https://github.com/golang/go/issues?q=milestone%3AGo1.19.4+label%3ACherryPickApproved

Full diff: https://github.com/golang/go/compare/go1.19.3...go1.19.4

The golang.org/x/net fix is in 1e63c2f08a

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-07 10:22:50 +01:00
Guillaume Lours
6b4ad0d1db
Merge pull request #10047 from thaJeztah/cleanup_output
Cleanup tips from output
2022-12-06 23:37:38 +01:00
Sebastiaan van Stijn
87a0a57f70 Cleanup tips from output
The scan tip has been shown for two years, and most users will know
about it by now. Presenting the message also involved checking if the
plugin was installed, and wether or not the message was shown before,
which also caused some overhead, so cleaning up the output a bit.

The corresponding DOCKER_SCAN_SUGGEST environment-variable is also
removed with this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-06 23:29:03 +01:00
Guillaume Lours
c80d52aded
Merge pull request #10049 from glours/fix-flaky-tests
check only running containers in after down tests of profiles e2e tests
2022-12-06 23:28:51 +01:00
Guillaume Lours
95bc6c58b7
check only running containers in after down tests of profiles e2e tests
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-12-06 23:17:14 +01:00
Laura Brehm
be30c67633
Merge pull request #10045 from docker/dependabot/go_modules/go.opentelemetry.io/otel-1.11.2
build(deps): bump go.opentelemetry.io/otel from 1.11.1 to 1.11.2
2022-12-06 13:24:33 +00:00
Laura Brehm
57a1e1e0df
Update e2e mod deps
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-12-06 13:13:17 +00:00
dependabot[bot]
02305756b3
build(deps): bump go.opentelemetry.io/otel from 1.11.1 to 1.11.2
Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.11.1 to 1.11.2.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.11.1...v1.11.2)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-06 09:07:31 +00:00
Guillaume Lours
12dad4f8d0
Merge pull request #10030 from ndeloof/max_concurrency
introduce --parallel to limit concurrent engine calls
2022-12-06 09:45:57 +01:00
Nicolas De Loof
a0acc20d88
introduce --parallel to limit concurrent engine calls
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-06 08:15:50 +01:00
Milas Bowman
053f20edab
port: improve error-handling if port not found (#10039)
This method looked slightly incomplete. If the port wasn't found,
it'd return `err`, but that was always `nil`, so we'd print out
`:0`.

Now, we construct a nice error message with the targeted port and
the ones we found.

The `--protocol` flag is also now case-insensitive to prevent any
weirdness/confusion there.

Co-authored-by: Nick Sieger <nicksieger@gmail.com>
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-12-05 22:11:45 +00:00
Guillaume Lours
6ed9a7928f
Merge pull request #10037 from milas/go-1.19.3
ci: upgrade to Go 1.19.3 & bump deps
2022-12-02 17:40:50 +01:00
Milas Bowman
9b8d520b7d ci: upgrade to Go 1.19.3 & bump deps
Upgrade to Go 1.19.3 (from 1.19.2) and bump a couple dependencies.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-12-02 11:24:46 -05:00
Milas Bowman
113fb6732d
schema: add support for tmpfs.mode in mount definition (#10031)
See compose-spec/compose-go#325 for the acutal spec change. This
propagates it to the Engine API object and adds an E2E test via
Cucumber 🥒

Fixes #9873.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-12-02 11:21:53 -05:00
Milas Bowman
b9e5f9e917
test: speed up Cucumber stop test (#10032)
Evidently `ping` doesn't respond to `SIGTERM`, so use `init` to
get Tini supervising it. This changes the exit code to 143 since
it's not hitting the 10s timeout and getting a `SIGKILL` (137).

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-12-02 09:34:06 -05:00
i-ky
c74a77e895 Make use of Containers.filter() and isService()
Signed-off-by: i-ky <gl.ivanovsky@gmail.com>
2022-12-02 12:16:35 +01:00
i-ky
7f975fa40b Fix replacing "service:x" with "container:y"
Signed-off-by: i-ky <gl.ivanovsky@gmail.com>
2022-12-02 12:16:35 +01:00
Guillaume Lours
7cf5940f4a
Merge pull request #10035 from ndeloof/9323
use StringToBool to detect COMPOSE_IGNORE_ORPHANS
2022-12-01 10:06:21 +01:00
Nicolas De Loof
7369127650
use StringToBool to detect COMPOSE_IGNORE_ORPHANS
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-12-01 09:38:57 +01:00
windforce17
2e7644ff21 use api.Separator to print right image names
Signed-off-by: windforce17 <wzcboss@qq.com>
2022-12-01 09:20:09 +01:00
Nicolas De Loof
8f2b747104 use DistributionInspect to resolve image digest
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-11-30 21:18:18 +01:00
Nicolas De Loof
9ac4f69918 move image digests resolution to backend
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-11-30 21:18:18 +01:00
NitishKumar06
2bef9769e5 Broken Link fixed in compose docs
Signed-off-by: NitishKumar06 <justnitish06@gmail.com>
2022-11-30 17:33:58 +01:00
Guillaume Lours
707d55c77f add file header and cleanup profiles e2e tests
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-30 13:21:16 +01:00
Guillaume Lours
5edd783032 add e2e tests to check profile activation via targeted service
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-30 13:21:16 +01:00
Guillaume Lours
6fbef29619 add e2e tests to check no profile usages
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-30 13:21:16 +01:00
Guillaume Lours
7fe43a8b4a add e2e tests using explicitly profiles
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-30 13:21:16 +01:00
Guillaume Lours
24ec0b2d09 pass services list to projectOrName function to add profiles for targeted services
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-30 13:21:16 +01:00
Nicolas De Loof
ed38fe0da8 only stop services started by up on interruption
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-11-30 08:07:20 +01:00
Umar Faruq Chowdhury
06e71371ff
docs: fix grammatical issues (#9997)
Signed-off-by: Umar Chowdhury <umarfchy@gmail.com>
Co-authored-by: Milas Bowman <milasb@gmail.com>
2022-11-29 10:52:22 -05:00
Nicolas De Loof
fb5b90ed47 implement support for oom_score_adj
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-11-25 09:03:12 +01:00
Guillaume Lours
10a5d998e6 useDockerDefaultOrServicePlatform fct should return service.platform if defined
and present in the build.platforms list (or if the list is empty)

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-25 09:03:03 +01:00
Nicolas De Loof
c3e5e49957 configure buildx for plain output if --ansi=never has been set
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-11-24 16:02:04 +01:00
Guillaume Lours
770281e9d5
Merge pull request #10016 from glours/fix-docs-pr-creation-workflow
change the default branch of the doc repository
2022-11-23 17:03:59 +01:00
Guillaume Lours
4bf98c7053
change the default branch of the doc repository
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-23 16:28:16 +01:00
Laura Brehm
8c5d7baa7d
Merge pull request #9995 from docker/dependabot/go_modules/github.com/containerd/containerd-1.6.10
build(deps): bump github.com/containerd/containerd from 1.6.9 to 1.6.10
2022-11-21 18:33:29 +01:00
Laura Brehm
d7a24e9c81
Update e2e module deps
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-11-21 18:22:15 +01:00
Guillaume Lours
02818ba6c7
Merge pull request #9998 from glours/display-engine-warnings
display creation warnings from the engine
2022-11-21 15:17:26 +01:00
Guillaume Lours
481ae0aa7d
Merge pull request #9999 from glours/pull-use-default-platform
use platform defined by DOCKER_DEFAULT_PLATFORM when pulling and no service platform defined
2022-11-18 14:27:41 +01:00
Laura Brehm
88c3aaf1bf
Merge pull request #10007 from laurazard/add-build-run
Add `--build` to `compose run`
2022-11-17 20:00:57 +01:00
Nicolas De Loof
19d6ca9c5d ignore error parsing container number label, just warn
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-11-17 15:18:28 +01:00
Laura Brehm
6fe03e935e
Update docs
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-11-17 12:29:19 +01:00
Laura Brehm
35d31cc500
Add --build option to compose run
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-11-17 00:57:35 +01:00
Guillaume Lours
7c5675c306
use platform defined by DOCKER_DEFAULT_PLATFORM when pulling and no service platform defined
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-16 13:51:44 +01:00
Guillaume Lours
ea32fc99e1
Merge pull request #9984 from glours/build-image-depends-on
check if a missing image won't be build via a service declared in depends_on section
2022-11-16 13:04:53 +01:00
Guillaume Lours
a077e8a24b display creation warnings from the engine
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-15 18:12:14 +01:00
Guillaume Lours
c53539e1cc
Merge pull request #9906 from glours/profiles-priority
use COMPOSE_PROFILES value only if no command line arg profiles used
2022-11-15 18:03:11 +01:00
Guillaume Lours
8c1e2af3e1 add e2e tests to check build dependency between services
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-15 14:43:53 +01:00
Guillaume Lours
a9e070206e check if a missing image won't be build via a service declared in depends_on section
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-15 14:43:53 +01:00
Guillaume Lours
32f29b833f add --no-consistency flag to convert command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-15 10:31:59 +01:00
Guillaume Lours
533fc61634 use COMPOSE_PROFILES value only if no command line arg profiles used
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-15 10:13:17 +01:00
Guillaume Lours
386c3554e5
Merge pull request #9992 from glours/dont-stale-proposal-issues
exclude issues with the `kind/feature` label from stale bot process
2022-11-15 10:12:47 +01:00
dependabot[bot]
bfb9e11fc2
build(deps): bump github.com/containerd/containerd from 1.6.9 to 1.6.10
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.9 to 1.6.10.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.9...v1.6.10)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-15 09:04:55 +00:00
Guillaume Lours
09e742b33b
exclude issues with the kind/feature label from stale bot process
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-11-14 11:31:03 +01:00
Guillaume Lours
754376916c
Merge pull request #9982 from milas/bump-deps
ci: update dependencies to latest
2022-11-08 15:46:46 +01:00
Milas Bowman
306ae161e1 ci: upgrade to compose-go v1.7.0
https://github.com/compose-spec/compose-go/releases/tag/v1.7.0

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-11-08 09:24:13 -05:00
Milas Bowman
fd4aecefee ci: update dependencies to latest
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-11-08 09:07:27 -05:00
Sebastiaan van Stijn
34e945a598
ci: remove uses of deprecated gotest.tools v2 (#9935)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-07 14:07:41 -05:00
Laura Brehm
df9e605b31
Merge pull request #9947 from glours/manage-resources-reservations
add support of deploy.reservation.memory
2022-11-02 16:09:14 +01:00
Laura Brehm
6e2e19d621
Merge pull request #9949 from docker/dependabot/go_modules/github.com/containerd/containerd-1.6.9
build(deps): bump github.com/containerd/containerd from 1.6.8 to 1.6.9
2022-11-02 00:02:31 +01:00
Laura Brehm
e189942133
Update e2e module dependencies
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-11-01 22:19:25 +01:00
dependabot[bot]
369e912586
build(deps): bump github.com/containerd/containerd from 1.6.8 to 1.6.9
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.8 to 1.6.9.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.8...v1.6.9)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-28 10:15:30 +00:00
Guillaume Lours
71b4976e74
Merge pull request #9936 from thaJeztah/update_deps
go.mod: update docker-credential-helpers v0.7.0
2022-10-28 12:13:20 +02:00
Guillaume Lours
bd96d032df
Merge branch 'v2' into update_deps
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-10-28 12:02:00 +02:00
Guillaume Lours
5a1f64532d
Merge pull request #9944 from glours/map-spec-restart-policy-to-engine
map deploy.restart_policy.condition to engine values
2022-10-25 09:04:42 +02:00
Guillaume Lours
7ba9aac5da add support of deploy.reservation.memory
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-10-24 22:52:34 +02:00
Laura Brehm
f7961cc722
Merge pull request #9945 from docker/dependabot/go_modules/github.com/stretchr/testify-1.8.1
build(deps): bump github.com/stretchr/testify from 1.8.0 to 1.8.1
2022-10-24 18:36:24 +02:00
Laura Brehm
6d64242f71
Update deps for e2e module
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-10-24 17:20:35 +02:00
Guillaume Lours
eaf27d9dfe
map deploy.restart_policy.condition to engine values
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-10-24 11:38:49 +02:00
dependabot[bot]
36a9183950
build(deps): bump github.com/stretchr/testify from 1.8.0 to 1.8.1
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.0...v1.8.1)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-24 09:27:35 +00:00
Sebastiaan van Stijn
f472ce3493
Merge pull request #9940 from thaJeztah/go1.18_compat
go.mod: docker 5aac513617f072b15322b147052cbda0d451d389 / v22.06-dev
2022-10-21 21:37:27 +02:00
Sebastiaan van Stijn
533abc3b1d
go.mod: docker 5aac513617f072b15322b147052cbda0d451d389 / v22.06-dev
This restores compatibility with go1.18, which was broken since commit;
c062238ea4

cmd.Environ() is new in go1.19, and not needed for this specific case.
Without this, trying to use this package in code that uses go1.18 will fail;

    builder/remotecontext/git/gitutils.go:216:23: cmd.Environ undefined (type *exec.Cmd has no field or method Environ)

Changing to use `os.Environ()` instead restores compatibility with go1.18

Full diff: f9cb47a052...5aac513617

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-21 20:33:34 +02:00
Guillaume Lours
e8ea3ad29f
Merge pull request #9934 from glours/bump-engine-version
update docker engine API to apply fix of CVE-2022-39253
2022-10-21 16:39:46 +02:00
Guillaume Lours
197c16904a update docker engine API to apply fix of CVE-2022-39253
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-10-21 16:25:08 +02:00
Sebastiaan van Stijn
c630c8d295
go.mod: update docker-credential-helpers v0.7.0
to match the version used by the cli (the cli doesn't use go.mod, so go modules
doesn't automatically pick that up);

1d6c6e2367/vendor.mod (L14)

Used code doesn't change, but we want to keep the older github.com/danieljoos/wincred v1.1.0
out of the dependency tree :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-21 15:48:25 +02:00
Sebastiaan van Stijn
41cf5ee3dc
go.mod: remove replace for runc
BuildKit and Buildx no longer require this replace rule (it probably only was
needed in buildkit, which used this version to compile).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-21 15:48:25 +02:00
Sebastiaan van Stijn
b7053cad8e
go mod: tidy and group "require" blocks, update comments
The file had multiple "requires" blocks, which made it harder to find which
dependencies were used. Some direct modules also were in the "indirect" block.

While updating, also updated some comments.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-21 15:48:19 +02:00
Laura Brehm
b37a6c7f23
Merge pull request #9937 from docker/dependabot/go_modules/go.opentelemetry.io/otel-1.11.1
build(deps): bump go.opentelemetry.io/otel from 1.11.0 to 1.11.1
2022-10-21 13:31:08 +02:00
Laura Brehm
717ace9990
Update e2e module deps
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-10-21 13:14:47 +02:00
dependabot[bot]
8bdfc62785
build(deps): bump go.opentelemetry.io/otel from 1.11.0 to 1.11.1
Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.11.0 to 1.11.1.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.11.0...v1.11.1)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-21 09:36:57 +00:00
Laura Brehm
2978f1a0bc
Merge pull request #9933 from laurazard/skip-flaky-test
Skip flaky test in CI `merge` workflow
2022-10-20 18:41:24 +02:00
Laura Brehm
dd13299ede
Skip flaky test in CI
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-10-20 18:30:27 +02:00
Guillaume Lours
32ae036fd0
Merge pull request #9925 from glours/update-docker-dependencies
bump docker dependencies version
2022-10-18 17:47:21 +02:00
Guillaume Lours
3f0550f884
log the error object instead of the string message only
Co-authored-by: Nick Sieger <nicksieger@gmail.com>
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-10-18 17:34:16 +02:00
Guillaume Lours
18ce1f41b7
replace deprecated functions
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-10-18 16:57:53 +02:00
Guillaume Lours
3bf29d401c bump docker dependencies version
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-10-18 16:26:54 +02:00
Laura Brehm
c384905d70
Merge pull request #9926 from laurazard/fix-makefile-modules-target
Fix Makefile target `validate-go-mod`
2022-10-18 16:09:43 +02:00
Laura Brehm
7424a3d3c1
Fix Makefile target validate-go-mod to only run correct bakefile target
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-10-18 15:38:41 +02:00
Laura Brehm
7c0b8a4c96
Merge pull request #9912 from docker/dependabot/go_modules/go.opentelemetry.io/otel-1.11.0
build(deps): bump go.opentelemetry.io/otel from 1.10.0 to 1.11.0
2022-10-18 13:53:07 +02:00
Laura Brehm
6b7e9466c4
Update e2e module deps
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-10-18 13:41:47 +02:00
Ulysses Souza
a6dd996988
Merge pull request #9823 from ulyssessouza/add-codecov
Add Codecov
2022-10-17 15:56:59 +02:00
Ulysses Souza
91eae4f035 Add Codecov
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-10-17 15:32:51 +02:00
Tiago Silva
8b89721476
port: fix container name in error message (#9909)
The error message is using V1 separator hardcoded, it should be using the configured separator value.

Signed-off-by: Tiago Silva <Tiago.MB.Silva@edu.azores.gov.pt>
2022-10-13 14:47:35 -04:00
Guillaume Lours
3892e9cbc4
Merge pull request #9887 from milas/issue-template
github: switch to issue template form
2022-10-13 20:43:33 +02:00
Milas Bowman
f43a1e3ece github: add feature request template
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-10-13 14:31:11 -04:00
Milas Bowman
fa1ae635d1 github: switch to issue template form
Migrate the existing template into the new format and streamline
it a bit.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-10-13 14:31:11 -04:00
dependabot[bot]
afc0263f5c
build(deps): bump go.opentelemetry.io/otel from 1.10.0 to 1.11.0
Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.10.0 to 1.11.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.10.0...v1.11.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-13 09:33:25 +00:00
Laura Brehm
b15df818c7
Merge pull request #9908 from docker/dependabot/go_modules/github.com/spf13/cobra-1.6.0
build(deps): bump github.com/spf13/cobra from 1.5.0 to 1.6.0
2022-10-12 18:23:35 +02:00
Laura Brehm
bb002a7688
Update e2e mod dependencies
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-10-12 18:12:11 +02:00
dependabot[bot]
2ccd57e01a
build(deps): bump github.com/spf13/cobra from 1.5.0 to 1.6.0
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.5.0...v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-12 10:00:55 +00:00
Nick Sieger
1c14d30777
Merge pull request #9168 from KoditkarVedant/9089-add-support-to-docker-compose-push-quiet-option
Add support to push images quietly via compose cli 🤫
2022-10-11 17:05:17 -04:00
Nick Sieger
8bd487ac43
docs: update with result of make docs
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-10-11 15:19:24 -05:00
Vedant Koditkar
1d4cb32001
Add support to push images quietly via compose cli
Signed-off-by: Vedant Koditkar <vedant.koditkar@outlook.com>
2022-10-11 15:19:23 -05:00
Laura Brehm
19d1ab77eb
Merge pull request #9905 from docker/dependabot/go_modules/gotest.tools/v3-3.4.0
build(deps): bump gotest.tools/v3 from 3.3.0 to 3.4.0
2022-10-10 15:32:42 +02:00
Laura Brehm
a01f62f5dc
Bump e2e module deps
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-10-10 15:23:04 +02:00
dependabot[bot]
045f5ad758
build(deps): bump gotest.tools/v3 from 3.3.0 to 3.4.0
Bumps [gotest.tools/v3](https://github.com/gotestyourself/gotest.tools) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/gotestyourself/gotest.tools/releases)
- [Commits](https://github.com/gotestyourself/gotest.tools/compare/v3.3.0...v3.4.0)

---
updated-dependencies:
- dependency-name: gotest.tools/v3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 09:33:24 +00:00
Guillaume Lours
b6b58d26c1 don't fail when trying to remove an orphan container during down command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-10-06 16:44:37 +02:00
Guillaume Lours
55b1b9976b
Merge pull request #9894 from thaJeztah/bump_go_1.19.2
Update to go 1.19.2 to address CVE-2022-2879, CVE-2022-2880, CVE-2022-41715
2022-10-04 23:10:38 +02:00
Sebastiaan van Stijn
34441c8e4a
Update to go 1.19.2 to address CVE-2022-2879, CVE-2022-2880, CVE-2022-41715
From the mailing list:

We have just released Go versions 1.19.2 and 1.18.7, minor point releases.

These minor releases include 3 security fixes following the security policy:

- archive/tar: unbounded memory consumption when reading headers

  Reader.Read did not set a limit on the maximum size of file headers.
  A maliciously crafted archive could cause Read to allocate unbounded
  amounts of memory, potentially causing resource exhaustion or panics.
  Reader.Read now limits the maximum size of header blocks to 1 MiB.

  Thanks to Adam Korczynski (ADA Logics) and OSS-Fuzz for reporting this issue.

  This is CVE-2022-2879 and Go issue https://go.dev/issue/54853.

- net/http/httputil: ReverseProxy should not forward unparseable query parameters

  Requests forwarded by ReverseProxy included the raw query parameters from the
  inbound request, including unparseable parameters rejected by net/http. This
  could permit query parameter smuggling when a Go proxy forwards a parameter
  with an unparseable value.

  ReverseProxy will now sanitize the query parameters in the forwarded query
  when the outbound request's Form field is set after the ReverseProxy.Director
  function returns, indicating that the proxy has parsed the query parameters.
  Proxies which do not parse query parameters continue to forward the original
  query parameters unchanged.

  Thanks to Gal Goldstein (Security Researcher, Oxeye) and
  Daniel Abeles (Head of Research, Oxeye) for reporting this issue.

  This is CVE-2022-2880 and Go issue https://go.dev/issue/54663.

- regexp/syntax: limit memory used by parsing regexps

  The parsed regexp representation is linear in the size of the input,
  but in some cases the constant factor can be as high as 40,000,
  making relatively small regexps consume much larger amounts of memory.

  Each regexp being parsed is now limited to a 256 MB memory footprint.
  Regular expressions whose representation would use more space than that
  are now rejected. Normal use of regular expressions is unaffected.

  Thanks to Adam Korczynski (ADA Logics) and OSS-Fuzz for reporting this issue.

  This is CVE-2022-41715 and Go issue https://go.dev/issue/55949.

View the release notes for more information: https://go.dev/doc/devel/release#go1.19.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-04 21:27:06 +02:00
Guillaume Lours
139a6945cb
Merge pull request #9886 from milas/ci-docs-repo
ci: update docs repo path
2022-09-29 19:20:49 +02:00
Milas Bowman
97a9d02dda ci: update docs repo path
The Docker docs now live at `docker/docs` instead of
`docker/docker.github.io`.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-09-29 13:09:25 -04:00
Laura Brehm
25c4bcef85
Merge pull request #9824 from laurazard/cucumber-test
🥒 Cucumber PoC 🥒
2022-09-27 23:38:44 +02:00
Laura Brehm
4607dac19c
Adjust modules sync validating script
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-27 15:47:00 +02:00
Milas Bowman
616777eb4a
deps: fix race condition during graph traversal (#9878)
Keep track of visited nodes to prevent visiting a service multiple
times. This is possible when a service depends on multiple others,
as an attempt could be made to visit it from multiple parents.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-09-27 09:01:13 -04:00
Laura Brehm
c1f475d7bd
Add validate-modules target to CI matrix
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-27 02:36:15 +02:00
Laura Brehm
c6109b2e5c
Add Makefile, buildx target to ensure root and e2e go.mod are kept in sync
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-27 02:35:57 +02:00
Laura Brehm
fffe7fff57
Create new e2e module to separate out test dependencies, move cucumber tests
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-27 02:13:52 +02:00
Laura Brehm
0a5f4e62e4
Removed tests that were replaced by Cucumber features
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-27 02:13:52 +02:00
Laura Brehm
d88f6805e7
Update go.mod replace
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-27 02:13:52 +02:00
Laura Brehm
266ab22d53
Rename start cucumber feature
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-27 02:13:51 +02:00
Laura Brehm
a7476c8eeb
Convert cascade_stop_test.go into a cucumber feature stop.feature
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-27 02:13:51 +02:00
Laura Brehm
15ebff00b1
Cucumber test setup/fixtures
(run with `go test -v -run ^TestCucumberFeatures$ github.com/docker/compose/v2/pkg/e2e/cucumber`)

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-27 02:13:47 +02:00
Alex
f44ca01fcf
ci: limit job permissions from default (#9874)
Signed-off-by: Alex <aleksandrosansan@gmail.com>
2022-09-26 15:41:24 -04:00
Guillaume Lours
19a1454c2d
Merge pull request #9868 from bkielbasa/v2
add more information when `service.platform` isn't part of `service.build.platforms`
2022-09-26 21:12:45 +02:00
Bartłomiej Klimczak
aa297a9969
remove unnecessary code
Signed-off-by: Bartłomiej Klimczak <bartlomiej.klimczak88@gmail.com>
2022-09-26 20:54:33 +02:00
Bartłomiej Klimczak
0d0a02cc6b
add more information when service.platform isn't part of service.build.platforms
Signed-off-by: Bartłomiej Klimczak <bartlomiej.klimczak88@gmail.com>
2022-09-26 20:44:59 +02:00
Guillaume Lours
3c641ed265
Merge pull request #9876 from milas/compose-go-1.6.0
ci: upgrade to compose-go v1.6.0
2022-09-26 19:42:19 +02:00
Milas Bowman
f41eec4e09 ci: upgrade to compose-go v1.6.0
https://github.com/compose-spec/compose-go/releases/tag/v1.6.0

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-09-26 19:23:30 +02:00
Ulysses Souza
140dc519d3
cli: add shell completion function (#9269)
Integrates PR #9462 with additional fixes/changes.

Additional changes will be required to utilize this.

Co-authored-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-09-26 13:21:45 -04:00
Guillaume Lours
279225896a
run: clean service command if entrypoint is overridden (#9836)
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-09-26 12:08:14 -04:00
Milas Bowman
a95cc4074a
Remove support for DOCKER_HOST in .env files (#9871)
Revert "Merge pull request #9817 from ulyssessouza/apply-newly-loaded-envvars"

This reverts commit 126cb988c6f0c00a2a9887b8a39dc0907daec289, reversing
changes made to b80222fb077436f2d4fcc62b3765d3a493891632.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-09-26 09:26:01 -04:00
Guillaume Lours
b4420c372b
Merge pull request #9866 from glours/issue-service-platform-on-up
keep the platform defined, in priority, via DOCKER_DEFAULT_PLATFORM o…
2022-09-26 10:32:43 +02:00
Guillaume Lours
ce3700d334 keep the platform defined, in priority, via DOCKER_DEFAULT_PLATFORM or the service.plaform one if no build platforms provided
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-09-22 13:46:24 +02:00
Guillaume Lours
e2a3fe9427
Merge pull request #9862 from glours/use-docker-export-if-no-build-platforms
configure default builder export when no build.platforms defined
2022-09-22 13:46:00 +02:00
Laura Brehm
94465d57cc
Merge pull request #9863 from docker/gha-win-mac-runners
Add `merge` GitHub Actions workflow to run tests on Windows and macOS runners
2022-09-21 16:39:27 +02:00
Laura Brehm
0dc64723c9
Restore -s in uname OS detection logic in Makefile
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-21 10:19:00 -04:00
Laura Brehm
8891d9e2b5
Streamline GHA workflow
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-21 08:59:09 -04:00
Laura Brehm
6cd68a4bf2
Upgrade actions/setup-go to v3
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-20 11:33:31 -04:00
Laura Brehm
a1984ca1de
Skip some tests in CI due to flakiness
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-20 11:33:31 -04:00
Laura Brehm
118b4f07e5
Increase E2E test timeouts to reduce flakiness
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-20 11:33:31 -04:00
Laura Brehm
8714f983ac
Temporarily disable broken E2E tests on Windows
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-20 11:33:31 -04:00
Laura Brehm
6bc50cb457
Rework Makefile for better Windows support
Fixes error when attempting to run `uname` on Windows, and add `.exe` to built binary on `make` if on Windows

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-20 11:33:31 -04:00
Laura Brehm
937fa2dc8f
Add GitHub Action workflow to run tests on Mac/Windows runners
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-20 11:33:28 -04:00
Guillaume Lours
71ab6c9eef
configure default builder export when no build.platforms defined
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-09-20 15:27:41 +02:00
Guillaume Lours
db88241698
Merge pull request #9854 from glours/fix-docker-default-platform--without-build-platform
keep the platform defined via DOCKER_DEFAULT_PLATFORM during build if no build platforms provided
2022-09-20 10:00:10 +02:00
Laura Brehm
723078c593
Remove /rebase GitHub Action since it's no longer necessary
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-19 17:50:41 -04:00
Guillaume Lours
a1c50ef2c9
keep the platform defined via DOCKER_DEFAULT_PLATFORM during build if no build platforms provided
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-09-16 22:19:31 +02:00
Laura Brehm
2977f4c897
Merge pull request #9849 from laurazard/fix-volumesfrom-overwriting
Keep `depends_on` condition when service has `volumes_from`
2022-09-15 10:45:48 -04:00
Laura Brehm
cfdec21a7f
Fix linting issues
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-15 10:04:06 -04:00
Laura Brehm
b564cc5a17
Don't overwrite existing dependency condition
(when service has `volumes_from` another service with dependency condition)

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-15 09:53:52 -04:00
Laura Brehm
43c444e890
Add unit tests for PrepareVolumes
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-15 09:53:14 -04:00
Guillaume Lours
b25a66bbd7
Merge pull request #9847 from glours/fix-service-platform--without-build-platform
keep the platform defined at service level during build if no build patforms provided
2022-09-15 10:49:42 +02:00
Guillaume Lours
0e975262da
keep the platform defined at service level during build if no build platforms provided
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-09-15 08:30:52 +02:00
Guillaume Lours
c4d79e60b6
Merge pull request #9840 from glours/bump-compose-go-v1.5.1
update compose-go version to v1.5.1
2022-09-14 11:45:30 +02:00
Guillaume Lours
ddc4896b10
update compose-go version to v1.5.1
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-09-14 11:02:58 +02:00
Guillaume Lours
9b863549ee
Merge pull request #9819 from milas/down-image-rm
build: label built images for reliable cleanup on `down`
2022-09-14 10:52:45 +02:00
Milas Bowman
801678686c add license to file
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-09-13 18:29:42 +01:00
Milas Bowman
403d691abf small cleanup + godoc
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-09-13 18:29:33 +01:00
Milas Bowman
b49b9ffe7e Merge remote-tracking branch 'upstream/v2' into down-image-rm 2022-09-13 18:00:41 +01:00
Milas Bowman
680763f8b7 down: refactor image pruning
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-09-13 17:23:44 +01:00
Guillaume Lours
1ed37ef7bd
Merge pull request #9812 from milas/go-1.19.1
ci: upgrade to Go 1.19.1
2022-09-13 17:29:34 +02:00
Milas Bowman
42169db166 Merge remote-tracking branch 'upstream/v2' into go-1.19.1 2022-09-13 14:46:15 +01:00
Risky Feryansyah
d05f5f5fa7
pull: improve output for services with both image+build (#9829)
When an image pull fails but the service has a `build` section, it
will be built, so it's not an unrecoverable error. It's now logged as
a warning - in situations where the image will _never_ exist in a
registry, `pull_policy: never` can & should be used, which will
prevent the error and avoid unnecessary pull attempts.

Signed-off-by: Risky Feryansyah Pribadi <riskypribadi24@gmail.com>
2022-09-13 14:38:13 +01:00
Guillaume Lours
5cc2c27abb
Merge pull request #9828 from Taha-Chaudhry/v2
Update README.md
2022-09-13 15:31:33 +02:00
Guillaume Lours
7b7189fe00
Merge pull request #9835 from docker/dependabot/go_modules/go.opentelemetry.io/otel-1.10.0
build(deps): bump go.opentelemetry.io/otel from 1.9.0 to 1.10.0
2022-09-13 11:53:45 +02:00
dependabot[bot]
de1d969c37
build(deps): bump go.opentelemetry.io/otel from 1.9.0 to 1.10.0
Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.9.0 to 1.10.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.9.0...v1.10.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-13 09:42:35 +00:00
dependabot[bot]
ab984d91af
build(deps): bump github.com/AlecAivazis/survey/v2 from 2.3.5 to 2.3.6 (#9830)
Bumps [github.com/AlecAivazis/survey/v2](https://github.com/AlecAivazis/survey) from 2.3.5 to 2.3.6.
- [Release notes](https://github.com/AlecAivazis/survey/releases)
- [Commits](https://github.com/AlecAivazis/survey/compare/v2.3.5...v2.3.6)

---
updated-dependencies:
- dependency-name: github.com/AlecAivazis/survey/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-13 10:27:14 +01:00
Taha-Chaudhry
e413c2137a
Update README.md
Grammar corrections

Signed-off-by: Taha-Chaudhry <46199675+Taha-Chaudhry@users.noreply.github.com>
2022-09-11 17:28:35 +03:00
Milas Bowman
61845dd781
logs: filter to services from current Compose file (#9811)
* logs: filter to services from current Compose file

When using the file model, only attach to services
referenced in the active Compose file.

For example, let's say you have `compose-base.yaml`
and `compose.yaml`, where the former only has a
subset of the services but are both run as part of
the same named project.

Project based command:
```
docker compose -p myproj logs
```
This should return logs for active services based
on the project name, regardless of Compose file
state on disk.

File based command:
```
docker compose --file compose-base.yaml logs
```
This should return logs for ONLY services that are
defined in `compose-base.yaml`. Any other services
are considered 'orphaned' within the context of the
command and should be ignored.

See also #9705.

Fixes #9801.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-09-08 16:26:00 -04:00
Lucas Berg
7a8d157871
convert: do not escape $ into $$ when using the --no-interpolate option (#9703)
Signed-off-by: Lucas Berg <root.lucasberg@gmail.com>
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
Co-authored-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-09-08 16:25:23 -04:00
Laura Brehm
88df5ede42
Merge pull request #9797 from laurazard/start-only-services
Only attempt to start specified services on `compose start [services]`
2022-09-08 13:00:20 -04:00
Laura Brehm
a7cc406187
Cleanup E2E tests
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-08 12:49:42 -04:00
Ulysses Souza
126cb988c6
Merge pull request #9817 from ulyssessouza/apply-newly-loaded-envvars
Apply newly loaded envvars to "DockerCli" and "APIClient"
2022-09-08 18:35:51 +02:00
Laura Brehm
4c474fe029
Add unit tests to graph building logic in dependencies.go
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-08 12:32:04 -04:00
Laura Brehm
209293e449
Restrict compose project to selected services and dependencies on compose start
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-08 12:31:55 -04:00
Ulysses Souza
79af3cdd85 Apply newly loaded envvars to "DockerCli" and "APIClient"
Re-evaluate DockerCli and APIClient after reading the environment file.
I can contain DOCKER_HOST and/or DOCKER_CONTEXT so the DockerCli passed by docker/cli has to be re-evaluated.
Also checks for DOCKER_CERT_PATH and DOCKER_TLS_VERIFY.

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-09-08 18:23:18 +02:00
Guillaume Lours
b80222fb07
Merge pull request #9821 from docker/dependabot/go_modules/go.opentelemetry.io/otel-1.9.0
build(deps): bump go.opentelemetry.io/otel from 1.4.1 to 1.9.0
2022-09-08 13:40:37 +02:00
dependabot[bot]
ff53411d9d
build(deps): bump go.opentelemetry.io/otel from 1.4.1 to 1.9.0
Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.4.1 to 1.9.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.4.1...v1.9.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-08 10:09:55 +00:00
Guillaume Lours
0ac0e29294
Merge pull request #9729 from glours/add-platforms-build
Add platforms build
2022-09-08 11:42:16 +02:00
Milas Bowman
bc806da712 build: label built images for reliable cleanup on down
When running `compose down`, the `--rmi` flag can be passed,
which currently supports two values:
 * `local`: remove any _implicitly-named_ images that Compose
            built
 * `all`  : remove any named images (locally-built or fetched
            from a remote repo)

Removing images in the `local` case can be problematic, as it's
historically been done via a fair amount of inference over the
Compose model. Additionally, when using the "project-model"
(by passing `--project-name` instead of using a Compose file),
we're even more limited: if no containers for the project are
running, there's nothing to derive state from to perform the
inference on.

As a first pass, we started labeling _containers_ with the name
of the locally-built image associated with it (if any) in #9715.
Unfortunately, this still suffers from the aforementioned problems
around using actual state (i.e. the containers might no longer
exist) and meant that when operating in file mode (the default),
things did not behave as expected: the label is not available
in the project since it only exists at runtime.

Now, with these changes, Compose will label any images it builds
with project metadata. Upon cleanup during `down`, the engine
image API is queried for related images and matched up with the
services for the project. As a fallback for images built with
prior versions of Compose, the previous approach is still taken.

See also:
 * https://github.com/docker/compose/issues/9655
 * https://github.com/docker/compose/pull/9715

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-09-07 17:57:29 -04:00
Milas Bowman
f72a604cbd ci: upgrade golangci-lint
Need a compatible version for 1.19

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-09-06 17:59:11 -04:00
Milas Bowman
e81168197a ci: upgrade to Go 1.19.1
Go released 1.18.6 + 1.19.1 today which fix a couple
CVEs. (`golang.org/x/net` also has a related fix.)

This jumps from 1.18.5 -> 1.19.1 since it was on the
to-do list regardless :)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-09-06 17:46:07 -04:00
Laura Brehm
361194472e
Cleanup E2E tests
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-09-06 20:28:35 +02:00
Guillaume Lours
e7b488bb94
Merge pull request #9810 from RiskyFeryansyahP/patch-nil-custom-label
patch: build.go access custom labels directly cause panic
2022-09-06 17:59:03 +02:00
Risky Feryansyah Pribadi
07eb8a598d patch: build.go access custom labels directly cause panic
Signed-off-by: Risky Feryansyah Pribadi <riskypribadi24@gmail.com>
2022-09-06 22:46:55 +07:00
Guillaume Lours
8a9eae3190
Merge pull request #9809 from docker/dependabot/go_modules/github.com/cnabio/cnab-to-oci-0.3.7
build(deps): bump github.com/cnabio/cnab-to-oci from 0.3.6 to 0.3.7
2022-09-06 11:39:25 +02:00
dependabot[bot]
48744dbe47
build(deps): bump github.com/cnabio/cnab-to-oci from 0.3.6 to 0.3.7
Bumps [github.com/cnabio/cnab-to-oci](https://github.com/cnabio/cnab-to-oci) from 0.3.6 to 0.3.7.
- [Release notes](https://github.com/cnabio/cnab-to-oci/releases)
- [Commits](https://github.com/cnabio/cnab-to-oci/compare/v0.3.6...v0.3.7)

---
updated-dependencies:
- dependency-name: github.com/cnabio/cnab-to-oci
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-06 09:27:51 +00:00
Guillaume Lours
44c55e89c0 always use 'docker' export entry when building with 'up' or 'run' commands
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-09-02 15:44:55 +02:00
Guillaume Lours
e016faac33 don't push images at the end of multi-arch build (and simplify e2e tests)
support DOCKER_DEFAULT_PLATFORM when 'compose up --build'
add tests to check behaviour when DOCKER_DEFAULT_PLATFORM is defined

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-09-02 15:44:55 +02:00
Guillaume Lours
8ed2d8ad07 add a test with multiple service builds using platforms in the same compose file
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-09-02 15:44:55 +02:00
Guillaume Lours
537f023a3b fix panic when using 'compose up --build'
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2022-09-02 15:44:55 +02:00
Guillaume Lours
8b1b70833e add support of platforms in build section
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-09-02 15:44:55 +02:00
Guillaume Lours
06ae6d82cb
Merge pull request #9802 from docker/dependabot/go_modules/github.com/docker/go-units-0.5.0
build(deps): bump github.com/docker/go-units from 0.4.0 to 0.5.0
2022-09-01 11:40:04 +02:00
dependabot[bot]
84392d52c4
build(deps): bump github.com/docker/go-units from 0.4.0 to 0.5.0
Bumps [github.com/docker/go-units](https://github.com/docker/go-units) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/docker/go-units/releases)
- [Commits](https://github.com/docker/go-units/compare/v0.4.0...v0.5.0)

---
updated-dependencies:
- dependency-name: github.com/docker/go-units
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-01 09:28:50 +00:00
Abdullah Shahid Khan
c87efed6a4
api: fix typo on Push godoc (#9798)
Signed-off-by: Abdullah Shahid Khan <69131903+Sh9hid@users.noreply.github.com>
2022-08-31 11:18:25 -04:00
Ulysses Souza
36926c41c6
Merge pull request #9715 from ulyssessouza/fix-down-rmi
Fix `down` with `--rmi`
2022-08-30 17:55:42 +02:00
Milas Bowman
24bf9789a6
ci: reduce noise from dependabot on Docker deps (#9770)
There's a complex dependency situation with `docker/docker`,
`docker/cli`, and `docker/buildkit`. Upgrading them usually
needs to happen in unison to ensure compatible versions
between them, particularly because `docker/buildx` is not
1.0, so has no guarantees re: compatibility, and `docker/docker`
& `docker/cli` use CalVer rather than SemVer, so also have
different compatibility guarantees than necessarily expected
by Go tooling.

Patch versions are still considered for these to ensure we
don't miss important bugfixes.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-08-30 08:50:23 -04:00
Laura Brehm
cc4f194295
Add E2E tests for starting/stopping single services
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-08-30 12:55:51 +02:00
Ulysses Souza
55cf579e02 Fix down with --rmi
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-08-29 19:48:23 +02:00
Laura Brehm
1a7c1dfe7d
Merge pull request #9794 from laurazard/fix-exitcode-stop-event
Correctly capture exit code when service has dependencies
2022-08-29 16:26:30 +02:00
Laura Brehm
8301dc8314
Only capture exit codes from exit events
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-08-28 21:01:40 +02:00
Laura Brehm
0d2beddf20
Add E2E tests for up --exit-code-from
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-08-27 17:44:08 +02:00
CrazyMax
69651136cf
Makefile: mutualize local and Dockerfile build opts (#9776)
Ensure that everything works nicely for `docker-ce-packaging`
as well as local development.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-08-26 16:06:24 -04:00
Milas Bowman
f3e0c386d2
Revert "Apply newly loaded envvars to DockerCli and APIClient" (#9792)
Revert "Merge pull request #9745 from ulyssessouza/apply-newly-loaded-envvars"

This reverts commit 6fe34c45cad8790da99f195f3269eca0e8f0fc0b, reversing
changes made to 10cfd551e3f1e6428dbcf16f480a1fdbaaf92986.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-08-26 16:03:45 -04:00
Nick Sieger
88406491c9
Merge pull request #9786 from nicksieger/individual-checksums
ci: bring back individual checksum files
2022-08-24 09:39:09 -05:00
Nick Sieger
63b126622d
ci: bring back individual checksum files
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-08-24 09:26:56 -05:00
dependabot[bot]
23deefd20c
build(deps): bump github.com/moby/buildkit from 0.10.3 to 0.10.4 (#9780)
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.10.3 to 0.10.4.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.10.3...v0.10.4)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-23 11:50:52 -04:00
Laura Brehm
e5eb00f618
Merge pull request #9781 from laurazard/pull-image-latest
Pull image regardless of whether it exists locally if `tag=latest`
2022-08-23 17:49:41 +02:00
Nick Sieger
2f2460b40e
Merge pull request #9784 from nicksieger/fix-release-checksums
ci: fix checksums checking
2022-08-23 10:19:18 -05:00
Nick Sieger
3aceaa1694
Merge pull request #9783 from mikesir87/9782-remove-confusing-error-output
Remove error message showing exit code when using --exit-code-from
2022-08-23 10:13:37 -05:00
Nick Sieger
c07de59a98
ci: fix checksums checking
Create checksums.txt in a different directory so it doesn't affect the check.

Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-08-23 10:05:54 -05:00
Laura Brehm
235734823e
Pull image regardless of whether it exists locally if tag=latest
... and pull policy is `missing` or `if_not_present`

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-08-23 16:57:40 +02:00
Michael Irwin
d23c261c7d
Remove error message showing exit code when using --exit-code-from
Signed-off-by: Michael Irwin <mikesir87@gmail.com>

Resolves #9782
2022-08-23 10:47:54 -04:00
Nick Sieger
157d38aa69
Merge pull request #9777 from nicksieger/compose-9773-pull-always
pull: always pull when policy not specified
2022-08-22 13:10:14 -05:00
Nick Sieger
5723dee316
pull: only skip pull when policy is missing/if_not_present
Fixes #9773.

Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-08-22 09:22:20 -05:00
Ulysses Souza
6eb34031f6
Merge pull request #9769 from ulyssessouza/wakeup
Wake up!
2022-08-19 17:27:48 +02:00
Ulysses Souza
9e7ae6cb30 Wake up!
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-08-19 17:18:28 +02:00
Laura Brehm
f880b4129c
Merge pull request #9173 from KoditkarVedant/8768-avoid-pulling-same-image-multiple-times
Avoid pulling same images multiple times 
2022-08-19 16:28:55 +02:00
Laura Brehm
832eee0e8f
Merge pull request #9764 from laurazard/apply-model-kill
Apply compose model on `compose kill`, add `--remove-orphans`
2022-08-19 16:15:45 +02:00
Vedant Koditkar
a1d19119d2 Fix breaking test
Signed-off-by: Vedant Koditkar <vedant.koditkar@outlook.com>
2022-08-19 15:25:22 +05:30
Vedant Koditkar
b96b5449e5 Merge branch 'v2' into 8768-avoid-pulling-same-image-multiple-times 2022-08-19 13:08:36 +05:30
Laura Brehm
a226fe9daf
Update docs for new compose kill --remove-orphans option
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-08-19 04:29:51 +02:00
Laura Brehm
fcfcc1524e
Apply compose model on compose kill, add --remove-orphans
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-08-19 04:26:08 +02:00
Ulysses Souza
6fe34c45ca
Merge pull request #9745 from ulyssessouza/apply-newly-loaded-envvars
Apply newly loaded envvars to "DockerCli" and "APIClient"
2022-08-18 22:49:21 +02:00
Ulysses Souza
10cfd551e3
Merge pull request #9761 from ulyssessouza/refactor-osenv-precedence
Give environment variables precedence back to OS over .env
2022-08-18 22:48:36 +02:00
Ulysses Souza
0b4cb85c84 Code formatting
Just moving it up to make clearer

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-08-18 22:41:02 +02:00
Ulysses Souza
3f4f4e5975 Give environment variables precedence back to OS over .env
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-08-18 22:39:21 +02:00
Ulysses Souza
86c925fbd3 Reset the DockerCli and APIClient after loading the environment file
This forces a re-evaluation of the environment variables.

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-08-18 16:42:56 +02:00
Nick Sieger
a64a5a61a7
Merge pull request #9759 from nicksieger/issue-9591
Don't wait for disabled dependency
2022-08-17 13:21:12 -05:00
Nick Sieger
09e6b0292a
up/start/run: don't wait for disabled service
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-08-17 12:32:10 -05:00
Nick Sieger
3c561e7017
create: pull all services logic out of loop; add DependsOn deps
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-08-17 11:48:45 -05:00
dependabot[bot]
8ad63f7150
build(deps): bump github.com/mattn/go-isatty from 0.0.14 to 0.0.16 (#9754)
Bumps [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) from 0.0.14 to 0.0.16.
- [Release notes](https://github.com/mattn/go-isatty/releases)
- [Commits](https://github.com/mattn/go-isatty/compare/v0.0.14...v0.0.16)

---
updated-dependencies:
- dependency-name: github.com/mattn/go-isatty
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-17 09:57:13 -04:00
Guillaume Lours
10532201a2
Merge pull request #9751 from crazy-max/new-archs
build windows/arm64 and linux/riscv64 binaries
2022-08-15 09:32:52 +02:00
CrazyMax
3022b6479f build windows/arm64 and linux/riscv64 binaries
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-08-15 09:24:14 +02:00
Guillaume Lours
abc73ed3d6
Merge pull request #9750 from crazy-max/fix-checksums
ci: fix checksums file
2022-08-15 09:23:50 +02:00
CrazyMax
0ec04058cd
ci: fix checksums file
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-08-14 22:29:57 +02:00
Vedant Koditkar
293cf21c58 Merge branch '8768-avoid-pulling-same-image-multiple-times' of github.com:KoditkarVedant/compose into 8768-avoid-pulling-same-image-multiple-times 2022-08-14 16:52:17 +05:30
Vedant Koditkar
25f4cb2ee6 Use compose to pull image twice
Signed-off-by: Vedant Koditkar <vedant.koditkar@outlook.com>
2022-08-14 16:51:29 +05:30
Vedant Koditkar
817e875cbf
Merge branch 'v2' into 8768-avoid-pulling-same-image-multiple-times 2022-08-13 12:19:49 +05:30
Guillaume Lours
8d12042f39
Merge pull request #9748 from crazy-max/log-filter
root: filter out commandConn.Close* warning message
2022-08-13 07:33:42 +02:00
CrazyMax
f5a1bb875d
root: filter out commandConn.Close* warning message
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-08-12 23:49:02 +02:00
Guillaume Lours
3e5b8659eb
Merge pull request #9747 from crazy-max/fix-readme
readme: fix badges
2022-08-12 23:39:55 +02:00
Vedant Koditkar
79ed1290a6 Use alpine:3.13.12 to be unique across the test cases
Signed-off-by: Vedant Koditkar <vedant.koditkar@outlook.com>
2022-08-13 02:59:44 +05:30
CrazyMax
51ef754387
readme: fix badges
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-08-12 23:29:13 +02:00
Guillaume Lours
58c477f916
Merge pull request #9744 from crazy-max/cross
Better sandboxed workflow and enhanced cross compilation
2022-08-12 22:38:14 +02:00
Vedant Koditkar
4853ace155 Fix package name
Signed-off-by: Vedant Koditkar <vedant.koditkar@outlook.com>
2022-08-13 02:06:28 +05:30
Vedant Koditkar
de49bea774 Try changing package used to avoid any race condition in tests
Signed-off-by: Vedant Koditkar <vedant.koditkar@outlook.com>
2022-08-12 23:06:51 +05:30
CrazyMax
5ec20296e4
Better sandboxed workflow and enhanced cross compilation
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-08-12 15:05:58 +02:00
Guillaume Lours
e8389306ae
Merge pull request #9736 from docker/dependabot/go_modules/github.com/containerd/containerd-1.6.8
build(deps): bump github.com/containerd/containerd from 1.6.7 to 1.6.8
2022-08-11 00:09:33 +02:00
dependabot[bot]
3fc020c20a build(deps): bump github.com/containerd/containerd from 1.6.7 to 1.6.8
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.7 to 1.6.8.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.7...v1.6.8)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-10 23:57:37 +02:00
Vedant Koditkar
0db6dfee03 make compose pull tests more expressive
Signed-off-by: Vedant Koditkar <vedant.koditkar@outlook.com>
2022-08-10 21:48:27 +05:30
Milas Bowman
27227a8824
lint: add nolintlint and clean up nolint directives (#9738)
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-08-09 16:43:58 -04:00
Milas Bowman
12ad0fddab
lint: run gofmt from Go 1.19 (#9728)
Fix comment formatting.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-08-08 11:36:57 -04:00
Vedant Koditkar
e623b5ca1e Merge branch 'v2' into 8768-avoid-pulling-same-image-multiple-times 2022-08-06 17:58:10 +05:30
Guillaume Lours
359133b800
Merge pull request #9720 from glours/respect-pull-policy-build
don't apply default pull policy from command line if one is define in service configuration
2022-08-05 16:50:24 +02:00
Guillaume Lours
c47079e795 don't apply default pull policy from command line if one is define in service configuration
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-08-05 12:01:32 +02:00
Guillaume Lours
bf4ca6219a
Merge pull request #9721 from glours/update-docker-cli
update Docker CLI version use in CI to v20.10.17
2022-08-05 12:00:51 +02:00
Guillaume Lours
ae08f57928
Merge pull request #9723 from docker/dependabot/go_modules/github.com/containerd/containerd-1.6.7
build(deps): bump github.com/containerd/containerd from 1.6.6 to 1.6.7
2022-08-05 11:37:29 +02:00
dependabot[bot]
ca990146e9
build(deps): bump github.com/containerd/containerd from 1.6.6 to 1.6.7
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.6 to 1.6.7.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.6...v1.6.7)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-05 09:27:47 +00:00
Guillaume Lours
143a40a618 update Docker CLI version use in CI to v20.10.17
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-08-05 10:46:36 +02:00
Guillaume Lours
7c405706b4
Merge pull request #9722 from glours/fix-linting-ci-task
fix version of golangci-lint to v1.47.3, issue with v1.48.0 for now
2022-08-05 10:46:21 +02:00
Guillaume Lours
e65ada3984
fix version of golangci-lint to v1.47.3, issue with v1.48.0 for now
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-08-05 10:37:11 +02:00
Laura Brehm
bb04677b0f
Merge pull request #9714 from docker/dependabot/go_modules/github.com/cnabio/cnab-to-oci-0.3.6
build(deps): bump github.com/cnabio/cnab-to-oci from 0.3.5 to 0.3.6
2022-08-04 13:17:35 +02:00
dependabot[bot]
7572bec674
build(deps): bump github.com/cnabio/cnab-to-oci from 0.3.5 to 0.3.6
Bumps [github.com/cnabio/cnab-to-oci](https://github.com/cnabio/cnab-to-oci) from 0.3.5 to 0.3.6.
- [Release notes](https://github.com/cnabio/cnab-to-oci/releases)
- [Commits](https://github.com/cnabio/cnab-to-oci/compare/v0.3.5...v0.3.6)

---
updated-dependencies:
- dependency-name: github.com/cnabio/cnab-to-oci
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-04 09:34:56 +00:00
Milas Bowman
1ee44a0acb
config: use correct YAML marshal func (#9712)
The `compose-spec/compose-go` lib is written with `gopkg.in/yaml.v2`
as a target.

When marshalling via CLI (`compose convert` / `compose config`), we
were using a _different_ YAML lib, which was a fork of `go-yaml`,
which is what `gopkg.in/yaml.v2` is based off of.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-08-03 20:41:43 +00:00
Khoa Le
8d4846f210
docs: remove extra whitespaces in help text (#9710)
Remove superfluous whitespaces

Signed-off-by: Khoa Le <ltkhoa2711@gmail.com>
2022-08-03 16:37:15 -04:00
Sebastiaan van Stijn
92f32b5c79
ci: use latest stable dockerfile syntax & rename docs Dockerfile (#9711)
* update dockerfiles to use latest stable syntax

Some Dockerfiles were pinned to a minor release, which meant they
wouldn't be updated to get the latest stable syntax (and fixes),
and one Dockerfile used the "labs" variant to use the HEREDOC syntax,
which has now been promoted to the stable syntax.

* docs: rename Dockerfile

There's no other Dockerfiles in the same path, so the "docs"
prefix was redundant.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-08-03 16:36:13 -04:00
Laura Brehm
ca05ffe36e
Merge pull request #9375 from ndeloof/project_or_name
if command is ran with a compose file, apply the compose model
2022-08-03 18:47:49 +02:00
Laura Brehm
c586ca4d0e Change projectOrName() to check COMPOSE_PROJECT_NAME env var
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-08-03 18:39:39 +02:00
Laura Brehm
be495ab8e6 Filter compose ps output by provided compose model
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-08-02 22:33:26 +02:00
Laura Brehm
d2a6c2c200 Add E2E tests for compose stop with compose file
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-08-02 22:33:26 +02:00
Nicolas De Loof
f6e96dd783 if command is ran with a compose file, apply the compose model, not just project name
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-08-02 22:33:26 +02:00
Milas Bowman
765c071c89
up: do not stop dependency containers (#9701)
This keeps parity with v1, where only the containers explicitly
passed to `up` are torn down when `Ctrl-C` is hit, so any
dependencies that got launched (or orphan containers hanging
around) should not be touched.

Fixes #9696.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-08-02 15:25:59 -04:00
Guillaume Lours
3dfdad61df
Merge pull request #9709 from milas/bump-deps
build: upgrade BuildKit & docker/distribution
2022-08-02 21:02:02 +02:00
ikedam
bbaaa6a9de
config: case-insensitive env vars on Windows (#9438)
Signed-off-by: IKEDA Yasuyuki <devld@ikedam.jp>
2022-08-02 14:56:09 -04:00
Milas Bowman
ddd9d4b6e4 build: upgrade BuildKit & docker/distribution
Housekeeping - bumping dependencies to latest version
available.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-08-02 14:52:08 -04:00
Guillaume Lours
d0d06d414d
Merge pull request #9708 from milas/golang-1.18.5
build: bump to Go 1.18.5
2022-08-02 19:49:15 +02:00
Milas Bowman
b1e4cde2da build: bump to Go 1.18.5
Can give 1.19 a bit of time before we upgrade ;)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-08-02 13:40:37 -04:00
Guillaume Lours
9e48afb830
Merge pull request #9706 from thaJeztah/improve_usage_consistency
update usage strings for consistency
2022-08-02 17:54:49 +02:00
Sebastiaan van Stijn
9db79856be
update usage strings for consistency
This updates the format of various usage strings to be more consistent
with other parts of the CLI.

- Use `[OPTIONS]` to indicate where command-specific options should be added
- Use `[SERVICE...]` to indicate zero-or-more services
- Remove some usage strings for specific options (e.g. `-e NAME=VAL`), as that
  option is part of the already mentioned `[OPTIONS]` and we don't provide usage
  for each possible option that can be passed.
- Remove `[--]`, which (I think) was needed for the Python implementation, but is
  a general feature to stop processing flag-options.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-08-02 13:32:29 +02:00
Laura Brehm
5ead5d1cd6
Merge pull request #9689 from glours/remove-close-workflow
remove unused workflows, especially the pr-closed which always failed
2022-08-02 11:38:00 +02:00
Guillaume Lours
7289e87a38
Merge pull request #9700 from glours/bump-compose-go-1.4.0
update to compose-go v1.4.0 as previous version introduced breaking changes
2022-08-01 17:57:02 +02:00
Guillaume Lours
052469104f
switch tests back to '_' separator for networks and volumes
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-08-01 17:25:43 +02:00
Guillaume Lours
bff44ff466
update to compose-go v1.4.0 as previous version introduced breaking changes
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-08-01 16:57:57 +02:00
Laura Brehm
57f98eff03
Merge pull request #9692 from floatingstatic/linklocal
Fix LinkLocalIPs in V2
2022-08-01 16:11:00 +02:00
Guillaume Lours
1eeb12fe1e
Merge pull request #9698 from laurazard/dont-load-composefile-version
Overwrite parent commands PreRun code for `compose version`
2022-08-01 12:14:14 +02:00
Laura Brehm
c9876f4c66 Overwrite parent commands PreRun code for compose version
.. to avoid trying (and failing) to load a compose file if the COMPOSE_FILE env var is set such as `COMPOSE_FILE=foo compose version`

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-08-01 11:44:05 +02:00
Guillaume Lours
4bd12e1aa3
Merge pull request #9639 from ikedam/linkToBuilding
Link to BUILDING.md for testing instructions
2022-07-30 11:46:38 +02:00
IKEDA Yasuyuki
d789b2e426 Improve descriptions about tests in CONTRIBUTING.md
Signed-off-by: IKEDA Yasuyuki <devld@ikedam.jp>
2022-07-30 17:18:39 +09:00
Jeremiah Millay
8d84a12333 Fix LinkLocalIPs in V2
Signed-off-by: Jeremiah Millay <jmillay@fastly.com>
2022-07-29 21:19:34 +02:00
Ulysses Souza
9a131a0734
Merge pull request #9690 from ulyssessouza/fix-bump-compose-go-1.3.0
Fix go.mod on  replace for compose-go
2022-07-29 20:59:36 +02:00
Ulysses Souza
c98e8ac3e1 Fix go.mod on replace for compose-go
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-29 20:49:10 +02:00
Kenny Millington
1d678b70d9
config: ignore image for config hash generation (#9350)
Do not set Image so it does not impact the config-hash

Signed-off-by: Kenny Millington <kenny@kennynet.co.uk>
2022-07-29 14:01:52 -04:00
Guillaume Lours
2e7b4074f4
Merge pull request #9688 from ulyssessouza/bump-compose-go-1.3.0
Bump compose-go -> 1.3.0
2022-07-29 19:53:31 +02:00
Ulysses Souza
953cebcd3b Bump compose-go -> 1.3.0
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-29 19:45:05 +02:00
Guillaume Lours
6d613c8cb2
Merge pull request #9636 from ulyssessouza/dotenvfile-priority
Environment variables priority
2022-07-29 19:42:50 +02:00
Guillaume Lours
ce740b1ff6
remove unused workflows, especially the pr-closed which always failed
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-29 19:30:36 +02:00
Ulysses Souza
78ad5252b5
Merge pull request #9687 from glours/use-dash-in-image-name
use '-' as separator by default for image name
2022-07-29 19:12:32 +02:00
Guillaume Lours
150fd4b8cf
use '-' as separator by default for image name
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-29 18:55:22 +02:00
Guillaume Lours
b49bd7c6ce
Merge pull request #9179 from ndeloof/no_build_image
as --no-build is set, set service image to default image name
2022-07-29 17:50:01 +02:00
Nicolas De Loof
abf5f736c7
as --no-build is set, set service image to default image name
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-29 17:41:53 +02:00
Guillaume Lours
236cd0c9d2
Merge pull request #9414 from ras0219/9403-npipe
Fixes #9403: Exclude Named Pipes from volumeMounts
2022-07-29 15:41:33 +02:00
Pierre Roux
38a18790ed
cmd: consistent handling no-args commands (#9660)
Enforce args rejection for commands without args:
* ls
* version

Additionally, docs for `restart` are fixed.

Signed-off-by: piroux <pierre.roux01@gmail.com>
2022-07-29 09:30:11 -04:00
Robert Schumacher
f69dec2da8 Fixes #9403: Remove Named Pipes from volumeMounts
If named pipe mounts are added to the volumeMounts mapping, the docker daemon will report an error that it cannot be mapped.

Signed-off-by: Robert Schumacher <ras0219@outlook.com>
2022-07-29 02:17:32 +02:00
Ulysses Souza
e9c8cfcef3 Fix environment variables priority between environment and .env
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-28 12:57:44 +02:00
Ulysses Souza
bac398aa9f Fix .env and --envfile priorities
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-28 12:13:37 +02:00
Guillaume Lours
def189fae1
Merge pull request #9677 from glours/use-google-addlicence
use Google addlicense instead of kunalkushwaha/ltag
2022-07-28 11:45:13 +02:00
Laura Brehm
085d8e9bb7
Merge pull request #9474 from ndeloof/pull_no_pull
introduce --pull
2022-07-27 11:35:46 +02:00
Guillaume Lours
e83d940a3c
add pull & build config to project before create
add pull flag to create and up documentation

Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-27 11:25:53 +02:00
Nicolas De Loof
9976077e24 introduce --pull
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-07-27 11:24:00 +02:00
Guillaume Lours
70ccc98f17
Merge pull request #9676 from glours/update-cli-docs-tool
update cli-doc-tool and update the doc with this new version
2022-07-27 10:50:38 +02:00
Josh Wilson
6fae6a41f9 Update emacs ignore patterns (#5903)
Currently the emacs ignore patterns include `**/.#*` (lock files), but
doesn't include `**/#*#` (autosave files;
https://www.emacswiki.org/emacs/AutoSave, not to be confused with
`**/*~` backup files which are ignored.)

Add autosave files.
2022-07-26 08:57:40 -05:00
Guillaume Lours
4eb56fd840
use Google addlicense instead of kunalkushwaha/ltag
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-26 15:13:34 +02:00
Guillaume Lours
0e6adb2884
update cli-doc-tool and update the doc with this new version
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-26 14:58:08 +02:00
Guillaume Lours
ce1829a46a
Merge pull request #9675 from glours/update-gh-workflow
use env variable for golang version and updates gh actions from v2 to v3
2022-07-26 11:41:15 +02:00
Guillaume Lours
dae4231810
remove usage of GO111MODULE option in gh actions
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-26 10:42:38 +02:00
Guillaume Lours
a4c2c4a832
use env variable for golang version and updates gh actions from v2 to v3
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-25 23:20:35 +02:00
Guillaume Lours
60621dca1a
Merge pull request #9670 from crazy-max/docs-workflow-fork
ci(docs): use push-to-fork when creating pr
2022-07-22 18:03:41 +02:00
CrazyMax
e1e8c37885 ci(docs): use push-to-fork when creating pr
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-07-22 17:54:14 +02:00
Guillaume Lours
dcf086c3c8
Merge pull request #9673 from glours/fix-linter-unused-arg-issue-build
remove unused sessionConfig param for addSecretsConfig function
2022-07-22 17:53:51 +02:00
Guillaume Lours
c4b9ec6301
remove unused sessionConfig param for addSecretsConfig function
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-22 17:37:42 +02:00
Guillaume Lours
0b2281348b
Merge pull request #9664 from ulyssessouza/bump-compose-go-1.2.9
Bump compose-go -> v1.2.9
2022-07-19 17:15:48 +02:00
Ulysses Souza
1d6f2a3dc3 Bump compose-go -> v1.2.9
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-19 17:05:23 +02:00
Guillaume Lours
81ac8657f5
Merge pull request #9663 from docker/dependabot/go_modules/github.com/sirupsen/logrus-1.9.0
build(deps): bump github.com/sirupsen/logrus from 1.8.1 to 1.9.0
2022-07-19 16:56:13 +02:00
Guillaume Lours
75bbd245c7
Merge pull request #9647 from glours/add-test-named-networks
add 2 named networks with close name in the networks test suite to gu…
2022-07-19 16:55:26 +02:00
dependabot[bot]
3ff744a7b0
build(deps): bump github.com/sirupsen/logrus from 1.8.1 to 1.9.0
Bumps [github.com/sirupsen/logrus](https://github.com/sirupsen/logrus) from 1.8.1 to 1.9.0.
- [Release notes](https://github.com/sirupsen/logrus/releases)
- [Changelog](https://github.com/sirupsen/logrus/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sirupsen/logrus/compare/v1.8.1...v1.9.0)

---
updated-dependencies:
- dependency-name: github.com/sirupsen/logrus
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-19 09:26:47 +00:00
Guillaume Lours
d85751f6d4
Merge pull request #9641 from glours/fix-volumes_from
keep the container reference when volumes_from target a container and not a service
2022-07-15 18:29:14 +02:00
Ulysses Souza
58dcfcdfbc
Merge pull request #9643 from ulyssessouza/add-gocritic-linter
Add gocritic to linters
2022-07-13 21:26:50 +02:00
Ulysses Souza
fc723acb3b Fix nolint issues
Reference -> https://golangci-lint.run/usage/false-positives/#nolint-directive

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-13 19:33:06 +02:00
Ulysses Souza
96cbb1cbcf Add "style" tag to gocritic
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-13 19:33:06 +02:00
Ulysses Souza
d42adf6efb Add "opinionated" tag to gocritic
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-13 19:33:06 +02:00
Ulysses Souza
a81f23a199 Add "diagnostic" tag to gocritic
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-13 19:33:06 +02:00
Ulysses Souza
2e96829607 Add gocritic to linters
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-13 19:33:03 +02:00
Guillaume Lours
966cbb59ac
add 2 named networks with close name in the networks test suite to guarantee the good distinction on network names
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-13 15:09:38 +02:00
Guillaume Lours
923e01d151
Merge pull request #9645 from thaJeztah/bump_go_1.18.4
update go to 1.18.4
2022-07-13 12:50:15 +02:00
Sebastiaan van Stijn
d54cd0445e
update go to 1.18.4
go1.18.4 (released 2022-07-12) includes security fixes to the compress/gzip,
encoding/gob, encoding/xml, go/parser, io/fs, net/http, and path/filepath
packages, as well as bug fixes to the compiler, the go command, the linker,
the runtime, and the runtime/metrics package. See the Go 1.18.4 milestone on the
issue tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.18.4+label%3ACherryPickApproved

This update addresses:

CVE-2022-1705, CVE-2022-1962, CVE-2022-28131, CVE-2022-30630, CVE-2022-30631,
CVE-2022-30632, CVE-2022-30633, CVE-2022-30635, and CVE-2022-32148.

Full diff: https://github.com/golang/go/compare/go1.18.3...go1.18.4

From the security announcement;
https://groups.google.com/g/golang-announce/c/nqrv9fbR0zE

We have just released Go versions 1.18.4 and 1.17.12, minor point releases. These
minor releases include 9 security fixes following the security policy:

- net/http: improper sanitization of Transfer-Encoding header

  The HTTP/1 client accepted some invalid Transfer-Encoding headers as indicating
  a "chunked" encoding. This could potentially allow for request smuggling, but
  only if combined with an intermediate server that also improperly failed to
  reject the header as invalid.

  This is CVE-2022-1705 and https://go.dev/issue/53188.

- When `httputil.ReverseProxy.ServeHTTP` was called with a `Request.Header` map
  containing a nil value for the X-Forwarded-For header, ReverseProxy would set
  the client IP as the value of the X-Forwarded-For header, contrary to its
  documentation. In the more usual case where a Director function set the
  X-Forwarded-For header value to nil, ReverseProxy would leave the header
  unmodified as expected.

  This is https://go.dev/issue/53423 and CVE-2022-32148.

  Thanks to Christian Mehlmauer for reporting this issue.

- compress/gzip: stack exhaustion in Reader.Read

  Calling Reader.Read on an archive containing a large number of concatenated
  0-length compressed files can cause a panic due to stack exhaustion.

  This is CVE-2022-30631 and Go issue https://go.dev/issue/53168.

- encoding/xml: stack exhaustion in Unmarshal

  Calling Unmarshal on a XML document into a Go struct which has a nested field
  that uses the any field tag can cause a panic due to stack exhaustion.

  This is CVE-2022-30633 and Go issue https://go.dev/issue/53611.

- encoding/xml: stack exhaustion in Decoder.Skip

  Calling Decoder.Skip when parsing a deeply nested XML document can cause a
  panic due to stack exhaustion. The Go Security team discovered this issue, and
  it was independently reported by Juho Nurminen of Mattermost.

  This is CVE-2022-28131 and Go issue https://go.dev/issue/53614.

- encoding/gob: stack exhaustion in Decoder.Decode

  Calling Decoder.Decode on a message which contains deeply nested structures
  can cause a panic due to stack exhaustion.

  This is CVE-2022-30635 and Go issue https://go.dev/issue/53615.

- path/filepath: stack exhaustion in Glob

  Calling Glob on a path which contains a large number of path separators can
  cause a panic due to stack exhaustion.

  Thanks to Juho Nurminen of Mattermost for reporting this issue.

  This is CVE-2022-30632 and Go issue https://go.dev/issue/53416.

- io/fs: stack exhaustion in Glob

  Calling Glob on a path which contains a large number of path separators can
  cause a panic due to stack exhaustion.

  This is CVE-2022-30630 and Go issue https://go.dev/issue/53415.

- go/parser: stack exhaustion in all Parse* functions

  Calling any of the Parse functions on Go source code which contains deeply
  nested types or declarations can cause a panic due to stack exhaustion.

  Thanks to Juho Nurminen of Mattermost for reporting this issue.

  This is CVE-2022-1962 and Go issue https://go.dev/issue/53616.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-13 12:40:24 +02:00
Guillaume Lours
9fdd7d81b3
Merge pull request #9640 from glours/fix-close-network-name-issue
Fix issue with close networks name on up and down command
2022-07-13 10:46:13 +02:00
Guillaume Lours
f30f9d9692
keep the container reference when volumes_from target a container and not a service
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-12 13:17:46 +02:00
Guillaume Lours
6c8ff02c07
Merge pull request #9579 from paroque28/patch-1
build.go: initialize CustomLabels map if nil
2022-07-12 12:44:49 +02:00
Pablo Rodriguez Quesada
eb06e1ca56
build.go: Access customLabels directly instead of by reference
Accesing the map directly instead of the copy value, otherwise the label doesn't get set.

Signed-off-by: Pablo Rodriguez <pablo.aarch64@gmail.com>
2022-07-11 08:52:23 -06:00
Guillaume Lours
50aa9750ee
check the exact network's name before creating or stopping it
NetworkList API doesn't return the extact name match, so we can retrieve more than one network with a request

Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-11 12:17:22 +02:00
IKEDA Yasuyuki
630c600929 Link to BUILDING.md for testing instructions
Signed-off-by: IKEDA Yasuyuki <devld@ikedam.jp>
2022-07-09 12:05:22 +09:00
Guillaume Lours
5bc4016e70
Merge pull request #9626 from Oriun/patch-1
Fix typo in compose pull documentation
2022-07-08 13:55:00 +02:00
Guillaume Lours
ea1ac9d7b7
Merge pull request #9631 from docker/dependabot/go_modules/github.com/cnabio/cnab-to-oci-0.3.5
build(deps): bump github.com/cnabio/cnab-to-oci from 0.3.4 to 0.3.5
2022-07-07 12:11:04 +02:00
dependabot[bot]
b8a53cd2a5
build(deps): bump github.com/cnabio/cnab-to-oci from 0.3.4 to 0.3.5
Bumps [github.com/cnabio/cnab-to-oci](https://github.com/cnabio/cnab-to-oci) from 0.3.4 to 0.3.5.
- [Release notes](https://github.com/cnabio/cnab-to-oci/releases)
- [Commits](https://github.com/cnabio/cnab-to-oci/compare/v0.3.4...v0.3.5)

---
updated-dependencies:
- dependency-name: github.com/cnabio/cnab-to-oci
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-07 10:01:05 +00:00
Guillaume Lours
7969667097
Merge pull request #9623 from glours/add-build-and-run-e2e-targets
add new targets to build Compose binary before running e2e tests
2022-07-05 16:45:43 +02:00
Guillaume Lours
40063b4faa
Merge pull request #9615 from glours/use-env-secret-on-build
add support of environment secret during build step
2022-07-05 16:36:40 +02:00
Emmanuel Nuiro
f06ab29a84 Fix typo in docker_compose_pull
Signed-off-by: Emmanuel Nuiro <emmanuel@nuiro.me>
2022-07-04 22:29:06 +02:00
Emmanuel Nuiro
7f5c166ec9 Fix typo in compose pull documentation
There was an invalid character between the two backticks at the end of the last snippet, causing the styling to break on the online documentation.

Signed-off-by: Emmanuel Nuiro <emmanuel@nuiro.me>
2022-07-04 21:45:53 +02:00
Vedant Koditkar
960453fa22 Merge branch 'v2' into 8768-avoid-pulling-same-image-multiple-times 2022-07-04 22:00:04 +05:30
Guillaume Lours
978b2f8265
add new targets to build Compose binary before running e2e tests
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-04 15:53:08 +02:00
Guillaume Lours
83744f7e99
Merge pull request #9619 from Jeldo/Fix-syntax-error-on-golangci-run-configuration
Fix golangci syntax error in run configuration
2022-07-04 14:40:11 +02:00
Guillaume Lours
5a1fea8272
Merge pull request #9507 from TheodosiouTh/tc/simplify-flag-conversion
TC: Use switch case to simplify flag conversion and avoid multiple if statements
2022-07-04 09:19:21 +02:00
TaeyoungKwak
94f50b520c Fix golangci syntax error in run configuration
Signed-off-by: TaeyoungKwak <astrokwak@gmail.com>
2022-07-03 01:45:52 +09:00
Guillaume Lours
4debb133a7
add support of environment secret during build step
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-01 11:21:49 +02:00
ThedosiouTh
115ac6d529 Use switch/case instead of static map for simplicity
Signed-off-by: ThedosiouTh <thanosthd@gmail.com>
2022-06-30 18:50:24 +03:00
ThedosiouTh
8648f30351 TC: Add missing tests for argumetns
Signed-off-by: ThedosiouTh <thanosthd@gmail.com>
2022-06-30 18:50:24 +03:00
ThedosiouTh
9542bdf445 TC: fix naming
Signed-off-by: ThedosiouTh <thanosthd@gmail.com>
2022-06-30 18:50:24 +03:00
ThedosiouTh
40f0dbd971 TC: Use map to simplify flag conversion and avoid multilple if statements
Signed-off-by: ThedosiouTh <thanosthd@gmail.com>
2022-06-30 18:50:24 +03:00
Guillaume Lours
ff2bf78570
Merge pull request #9612 from milas/e2e-start-stop
e2e: add more start/stop test cases
2022-06-30 17:31:09 +02:00
Milas Bowman
4aa8c4a1e5 e2e: add more start/stop test cases
* Starting a service that's already running
* Stopping a service that's already stopped
* Starting/stopping multiple services (by name) at once

Also renamed a test that was about `up` behavior but was
misleadingly labeled start/stop.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-30 09:52:14 -04:00
Milas Bowman
06649442eb
Merge pull request #9609 from milas/e2e-pause
e2e: split out `pause` tests and add more cases
2022-06-30 08:42:59 -04:00
Guillaume Lours
19f316eec3
Merge pull request #9611 from docker/dependabot/go_modules/github.com/stretchr/testify-1.8.0
build(deps): bump github.com/stretchr/testify from 1.7.5 to 1.8.0
2022-06-30 11:38:58 +02:00
dependabot[bot]
1074074df2
build(deps): bump github.com/stretchr/testify from 1.7.5 to 1.8.0
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.5 to 1.8.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.5...v1.8.0)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-30 09:31:44 +00:00
Guillaume Lours
cd940693aa
Merge pull request #9049 from ndeloof/9044
(re)start should not impact one-off containers
2022-06-29 10:43:10 +02:00
Laura Brehm
96b152f705 Update logic to keep compose stop and restart from affecting one-offs
Also add e2e tests.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-06-29 00:58:02 +02:00
Milas Bowman
8e7b6582d4
Merge pull request #9595 from abhinavnair/replace-ioutil
Replace deprecated ioutil pkg with os & io
2022-06-28 15:08:57 -04:00
Nick Sieger
391d2e02ff
Merge pull request #9592 from nicksieger/fix-panic-empty-string-arg
fix: panic caused by empty string argument
2022-06-28 14:07:04 -05:00
Milas Bowman
26014d49a5 e2e: split out pause tests and add more cases
Pause/unpause was being partially tested under the start/stop test.
This removes it from that test and adds dedicated pause + unpause
tests.

Note that the tests assert on current behavior, though it's been
noted where that is undesirable due to divergence from the Docker
CLI. Will change the behavior + update tests in a subsequent PR.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-28 15:06:17 -04:00
Nick Sieger
fd5e8b8c28
fix: panic caused by empty string argument
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-06-28 10:18:38 -05:00
Guillaume Lours
cc2dc868c2
Merge pull request #9583 from crazy-max/docs-workflow
ci: release workflow to open a PR on docs repo with latest changes
2022-06-28 14:26:21 +02:00
Guillaume Lours
908a59af4c
Merge pull request #9607 from docker/dependabot/go_modules/github.com/hashicorp/go-version-1.6.0
build(deps): bump github.com/hashicorp/go-version from 1.5.0 to 1.6.0
2022-06-28 11:35:38 +02:00
dependabot[bot]
7e6daa8d01
build(deps): bump github.com/hashicorp/go-version from 1.5.0 to 1.6.0
Bumps [github.com/hashicorp/go-version](https://github.com/hashicorp/go-version) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/hashicorp/go-version/releases)
- [Changelog](https://github.com/hashicorp/go-version/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/go-version/compare/v1.5.0...v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-version
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-28 09:28:44 +00:00
Abhinav Nair
a783cc4574
Blacklist ioutil pkg in golangci-lint
This is to prevent anyone from accidentally importing the pkg

Signed-off-by: Abhinav Nair <11939846+abhinavnair@users.noreply.github.com>
2022-06-28 09:20:29 +08:00
Laura Brehm
3ccf4349e7
Merge pull request #9572 from laurazard/dont-wait-for-oneshots
Use appropriate dependency condition for one-shot containers when running `compose up --wait`
2022-06-26 14:48:49 +02:00
Laura Brehm
74fd14ec65 Use alpine instead of ubuntu for E2E compose file, no need to include version
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-06-26 14:41:23 +02:00
Abhinav Nair
11f2f2dbc4
Replace deprecated ioutil pkg with os & io
As of Go 1.16, the same functionality is now provided by package io or
package os, and those implementations should be preferred in new code.

So replacing all usage of ioutil pkg with io & os.

Signed-off-by: Abhinav Nair <11939846+abhinavnair@users.noreply.github.com>
2022-06-25 14:06:10 +08:00
Guillaume Lours
2cd9c0df5a
Merge pull request #9587 from milas/build-order-classic
build: respect dependency order for classic builder
2022-06-24 22:24:22 +02:00
Milas Bowman
ec0efec839 test: add copyright notice
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-24 16:16:53 -04:00
CrazyMax
0a53d93338
ci: release workflow to open a PR on docs repo with latest changes
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-06-24 18:40:08 +02:00
Guillaume Lours
dbf52d3f45
Merge pull request #9590 from docker/dependabot/go_modules/github.com/stretchr/testify-1.7.5
build(deps): bump github.com/stretchr/testify from 1.7.4 to 1.7.5
2022-06-24 11:36:32 +02:00
dependabot[bot]
f972803104
build(deps): bump github.com/stretchr/testify from 1.7.4 to 1.7.5
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.4 to 1.7.5.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.4...v1.7.5)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-24 09:28:09 +00:00
Guillaume Lours
4aa3e246b7
Merge pull request #9585 from milas/net-ambiguity
networks: prevent issues due to duplicate names
2022-06-24 11:08:52 +02:00
Guillaume Lours
a8a52f297a
Merge pull request #9582 from docker/dependabot/go_modules/github.com/cnabio/cnab-to-oci-0.3.4
build(deps): bump github.com/cnabio/cnab-to-oci from 0.3.3 to 0.3.4
2022-06-23 18:02:16 +02:00
Guillaume Lours
ee8fed8abf
Merge pull request #9581 from docker/dependabot/go_modules/github.com/spf13/cobra-1.5.0
build(deps): bump github.com/spf13/cobra from 1.4.0 to 1.5.0
2022-06-23 17:54:40 +02:00
Guillaume Lours
4331b1ded1
Merge pull request #9580 from docker/dependabot/go_modules/github.com/stretchr/testify-1.7.4
build(deps): bump github.com/stretchr/testify from 1.7.2 to 1.7.4
2022-06-23 17:53:52 +02:00
dependabot[bot]
41dcb43dee
build(deps): bump github.com/cnabio/cnab-to-oci from 0.3.3 to 0.3.4
Bumps [github.com/cnabio/cnab-to-oci](https://github.com/cnabio/cnab-to-oci) from 0.3.3 to 0.3.4.
- [Release notes](https://github.com/cnabio/cnab-to-oci/releases)
- [Commits](https://github.com/cnabio/cnab-to-oci/compare/v0.3.3...v0.3.4)

---
updated-dependencies:
- dependency-name: github.com/cnabio/cnab-to-oci
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-23 14:54:35 +00:00
Milas Bowman
68cf8d5ca0
Merge pull request #9588 from milas/compose-go-v1.2.8
deps: upgrade to compose-go v1.2.8
2022-06-23 10:53:26 -04:00
Milas Bowman
94d6dff89d deps: upgrade to compose-go v1.2.8
https://github.com/compose-spec/compose-go/releases/tag/v1.2.8

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-23 10:45:45 -04:00
Milas Bowman
5f89365c8f network: make test mock consistent throughout
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-22 16:34:59 -04:00
Milas Bowman
b2cd089bae build: respect dependency order for classic builder
When using the "classic" (non-BuildKit) builder, ensure that
services are iterated in dependency order for a build so that
it's possible to guarantee the presence of a base image that's
been added as a dependency with `depends_on`. This is a very
common pattern when using base images with Compose.

A fix for BuildKit is blocked currently until we can rely on a
newer version of the engine (see docker/compose#9324)[^1].

[^1]: https://github.com/docker/compose/issues/9232#issuecomment-1060389808

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-22 16:24:30 -04:00
Milas Bowman
0f747419b6 networks: prevent issues due to duplicate names
Within the Docker API/engine, networks have unique IDs, and the
name is a friendly label/alias, which notably does NOT have any
guarantees around uniqueness (see moby/moby#18864 [^1]).

During day-to-day interactive/CLI Compose usage, this is rarely
an issue, as Compose itself isn't creating networks concurrently
across goroutines. However, if multiple Compose instances are
executed simultaneously (e.g. as part of a test suite that runs
in parallel), this can easily occur.

When it does happen, it's very confusing for users and resolving
it via the `docker` CLI is not straightforward either [^2].

There's two primary changes here:
 * Pass `CheckDuplicates: true` to the Docker API when creating
   networks to reduce the likelihood of Compose creating duplicates
   in the first place
 * On `down`, list networks using a name filter and then remove
   them all by ID, as the Docker API will return an error if the
   name alias is used and maps to more than one network

Hopefully, this provides a better UX, since the issue should be
less likely to occur, and if it does, it can now be resolved via
standard Compose workflow commands.

[^1]: https://github.com/moby/moby/issues/18864
[^2]: https://stackoverflow.com/questions/63776518/error-2-matches-found-based-on-name-network-nameofservice-default-is-ambiguo

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-22 12:27:30 -04:00
dependabot[bot]
6df222f37d
build(deps): bump github.com/spf13/cobra from 1.4.0 to 1.5.0
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.4.0...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-21 09:26:36 +00:00
dependabot[bot]
aa851b0e27
build(deps): bump github.com/stretchr/testify from 1.7.2 to 1.7.4
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.2 to 1.7.4.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.2...v1.7.4)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-21 09:26:26 +00:00
Guillaume Lours
e5dcb8a8f8
Merge pull request #9568 from milas/e2e-init-output
e2e: improve test output on failures
2022-06-18 20:59:56 +02:00
Laura Brehm
fd8538f780 Use appropriate dependency condition for one-shot containers when running compose up --wait
Also add e2e tests to ensure `compose up --wait` does not get stuck forever waiting for one-shot containers

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-06-18 01:20:40 +02:00
Milas Bowman
ab25aabfb9
Merge pull request #9311 from quite/no-ansi-be-kind
Don't use ansi even when deprecated option is requested
2022-06-16 17:15:19 -04:00
Milas Bowman
7f441eb013 e2e: improve test output on failures
This is mostly marking a bunch of the run methods as helpers so
that the internal assertions they do will show the line number of
the calling test instead.

There's also some small tweaks around the plugin initialization to
help with the output in the event that it fails to make it easier
to debug what went wrong.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 17:05:43 -04:00
Guillaume Lours
4270987d7c
Merge pull request #9567 from milas/e2e-cmd
e2e: ensure all Compose cmds standalone compatible
2022-06-16 23:02:14 +02:00
Milas Bowman
3248b7b335 e2e: use Compose for exec test
This was using `docker exec` on Compose containers instead of
`docker compose exec` (and `docker-compose exec` for standalone).

Thanks to @glours for catching!

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 16:44:21 -04:00
Milas Bowman
4ea3ba77b2
Merge pull request #9559 from venthur/fix_spell
fixed some spelling mistakes
2022-06-16 15:56:44 -04:00
Milas Bowman
9622395c8a e2e: ensure all Compose cmds standalone compatible
The E2E tests can be run in plugin (`docker compose`) or standalone
(`docker-compose`) mode. Existing logic was in place to ensure that
the helper method is always used, which will invoke the right one
based on how tests are being executed.

However, this logic was too easy to (unintentionally) bypass given
the myriad of ways that commands can be run. The check has been
made stricter and pushed to a lower-level to more aggressively
catch instances.

As a result, a bunch of calls to `RunDockerCmd` are now updated
to be `RunDockerComposeCmd`, which will ensure that the invocation
is correct based on test mode.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 15:51:54 -04:00
Guillaume Lours
bec4ea4ab0
Merge pull request #9566 from milas/e2e-ps-stdout
e2e: fix spurious `ps` failures
2022-06-16 18:07:22 +02:00
Guillaume Lours
3f10753178
Merge pull request #9563 from milas/e2e-env
e2e: isolate test command env from system env
2022-06-16 18:05:39 +02:00
Milas Bowman
152c2d9a33 e2e: fix spurious ps failures
Use the command `stdout` instead of combined `stdout` + `stderr`
for assertions to avoid failures from any CLI logging such as
warnings, which will be on `stderr`.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 11:28:29 -04:00
Milas Bowman
a261682ca8 e2e: fix per-command env overrides
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 11:27:39 -04:00
Nick Sieger
71b89c2c1b
Merge pull request #9564 from docker/nicksieger/9562
down: fix COMPOSE_REMOVE_ORPHANS env name and add test
2022-06-16 09:01:00 -05:00
Milas Bowman
ccd87311e8 e2e: always set HOME + USER for cmd env
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 09:44:40 -04:00
Nick Sieger
49fb4ca25f
down: fix COMPOSE_REMOVE_ORPHANS env name and add test
Fixes #9562.

Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-06-16 08:40:40 -05:00
Milas Bowman
3ae6c52e8a e2e: add extra tools needed for ddev test
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 09:38:25 -04:00
Milas Bowman
1c41df8f56 e2e: robustness changes for ddev test
The most important change here is to ensure that the correct Compose
standalone binary is used by `ddev`. Since it invokes Compose itself,
we need to ensure that `PATH` is set appropriately such that it finds
the binary we want to test rather than something from the system.

As part of this, the rest of the environment has been isolated, which
should make the test more reliable, and avoids polluting `~/.ddev`
with test artifacts by using a tmpdir as `HOME` for the test instead
of the user's real home folder.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 08:59:02 -04:00
Milas Bowman
ea8341865d e2e: isolate test command env from system env
When running Docker / Compose commands, do NOT inherit the system
environment to ensure that the tests are reproducible regardless
of host settings.

Additionally, per-command environment overrides are provided to
the command instead of using `os.SetEnv`, as this is not safe when
running tests in parallel (`testing.T::SetEnv` will actually error
if used in this way!)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 08:30:57 -04:00
Guillaume Lours
de0f23315b
Merge pull request #9561 from milas/e2e-subtests
e2e: fix subtests and block parallel unsafe tests
2022-06-16 11:15:30 +02:00
Milas Bowman
d9065050fd e2e: fix subtests and block parallel unsafe tests
The big mechanical change here is to NOT store `t` as a field on
the `CLI` object (which has been renamed as well to fix the odd
capitalization). The way the tests are structured meant that the
"subtests" were using the _parent_ `*testing.T` instance, which
causes various oddities including confusing messages on failure
about a child test causing a panic in the parent.

Additionally, a few tests have been blocked from running in
parallel because they are sharing `compose.yaml` fixtures and
can fail as a result (e.g. due to a port conflict on the host).
I'll fix these in follow-up PRs but want to focus on correctness
for the tests before optimizing them.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-15 16:27:30 -04:00
Nicolas De Loof
005fc25823 add support for setting secret from env variable
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-06-15 17:06:48 +02:00
Bastian Venthur
8a5d555de7 fixed some spelling mistakes
that's all :)

Signed-off-by: Bastian Venthur <venthur@debian.org>
2022-06-14 21:33:36 +02:00
Nick Sieger
a48f1e8c13
Merge pull request #9547 from docker/nicksieger/e2e-ps-unmarshal
e2e: unmarshal json into container summaries
2022-06-14 10:33:53 -05:00
Guillaume Lours
57975094cc
Merge pull request #9552 from glours/fix-deploy-cpus-issue
Fix deploy cpus issue and support pids limit
2022-06-14 11:41:35 +02:00
Laura Brehm
80b7a8d274 Only start direct dependencies of service on compose run ...
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-06-14 07:32:15 +02:00
Guillaume Lours
e111b651b3 add deploy.resourses.limits.pids to the managed resources
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-06-13 17:21:48 +02:00
Guillaume Lours
638d78516a parse deploy.resources.limit.cpus as float before converting
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-06-13 17:21:48 +02:00
Guillaume Lours
8862f95858
Merge pull request #9514 from ulyssessouza/fix-bindmounts
Fix bind mounts when in project volumes definition
2022-06-09 11:15:24 +02:00
Guillaume Lours
c2533e2341
Merge pull request #9546 from docker/dependabot/go_modules/github.com/containerd/containerd-1.6.6
Bump github.com/containerd/containerd from 1.6.2 to 1.6.6
2022-06-08 22:44:37 +02:00
dependabot[bot]
08d8fddb8d
Bump github.com/containerd/containerd from 1.6.2 to 1.6.6
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.2 to 1.6.6.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.2...v1.6.6)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-08 20:15:39 +00:00
Guillaume Lours
5bd1a9bda3
Merge pull request #9545 from docker/nicksieger/ps-e2e-test
e2e: add test for ps
2022-06-08 22:13:37 +02:00
Nick Sieger
ebb45b400c
e2e: unmarshal json into container summaries
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-06-08 15:13:31 -05:00
Guillaume Lours
78605e58b2
Merge pull request #9541 from docker/dependabot/go_modules/github.com/AlecAivazis/survey/v2-2.3.5
Bump github.com/AlecAivazis/survey/v2 from 2.3.2 to 2.3.5
2022-06-08 21:09:27 +02:00
Guillaume Lours
0ea3504fd5
Merge pull request #9544 from docker/dependabot/go_modules/github.com/docker/buildx-0.8.2
Bump github.com/docker/buildx from 0.8.1 to 0.8.2
2022-06-08 21:07:42 +02:00
Nick Sieger
c83133f73b
e2e: add test for ps
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-06-08 14:05:20 -05:00
Guillaume Lours
0f6366afac
Merge pull request #9539 from docker/nicksieger/9527
Fix ps ports output; includes unit test
2022-06-08 21:02:32 +02:00
dependabot[bot]
26554884db
Bump github.com/docker/buildx from 0.8.1 to 0.8.2
Bumps [github.com/docker/buildx](https://github.com/docker/buildx) from 0.8.1 to 0.8.2.
- [Release notes](https://github.com/docker/buildx/releases)
- [Commits](https://github.com/docker/buildx/compare/v0.8.1...v0.8.2)

---
updated-dependencies:
- dependency-name: github.com/docker/buildx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-08 19:00:51 +00:00
dependabot[bot]
a9d3bfdacd
Bump github.com/AlecAivazis/survey/v2 from 2.3.2 to 2.3.5
Bumps [github.com/AlecAivazis/survey/v2](https://github.com/AlecAivazis/survey) from 2.3.2 to 2.3.5.
- [Release notes](https://github.com/AlecAivazis/survey/releases)
- [Commits](https://github.com/AlecAivazis/survey/compare/v2.3.2...v2.3.5)

---
updated-dependencies:
- dependency-name: github.com/AlecAivazis/survey/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-08 19:00:49 +00:00
Guillaume Lours
0275fac355
Merge pull request #9538 from docker/dependabot/go_modules/github.com/stretchr/testify-1.7.2
Bump github.com/stretchr/testify from 1.7.0 to 1.7.2
2022-06-08 20:59:59 +02:00
Guillaume Lours
fc5d7a45e0
Merge pull request #9485 from docker/dependabot/go_modules/github.com/hashicorp/go-version-1.5.0
Bump github.com/hashicorp/go-version from 1.3.0 to 1.5.0
2022-06-08 20:59:21 +02:00
Guillaume Lours
9465e433fc
Merge pull request #9307 from docker/dependabot/go_modules/github.com/cnabio/cnab-to-oci-0.3.3
Bump github.com/cnabio/cnab-to-oci from 0.3.1-beta1 to 0.3.3
2022-06-08 20:59:13 +02:00
dependabot[bot]
5b02eadb74
Bump github.com/cnabio/cnab-to-oci from 0.3.1-beta1 to 0.3.3
Bumps [github.com/cnabio/cnab-to-oci](https://github.com/cnabio/cnab-to-oci) from 0.3.1-beta1 to 0.3.3.
- [Release notes](https://github.com/cnabio/cnab-to-oci/releases)
- [Commits](https://github.com/cnabio/cnab-to-oci/compare/v0.3.1-beta1...v0.3.3)

---
updated-dependencies:
- dependency-name: github.com/cnabio/cnab-to-oci
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-08 18:52:18 +00:00
dependabot[bot]
331930c37d
Bump github.com/stretchr/testify from 1.7.0 to 1.7.2
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.0 to 1.7.2.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.0...v1.7.2)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-08 18:52:16 +00:00
Guillaume Lours
6e15989ec8
Merge pull request #9262 from docker/dependabot/go_modules/github.com/theupdateframework/notary-0.7.0
Bump github.com/theupdateframework/notary from 0.6.1 to 0.7.0
2022-06-08 20:51:10 +02:00
Nick Sieger
b2c0d25005
ps: use DisplayablePorts from docker/cli
Fixes #9527.

Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-06-07 17:11:16 -05:00
Nick Sieger
3599fc8533
mocks: create mocks for compose api.Service
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-06-07 17:09:06 -05:00
Ulysses Souza
919f351b4b Fix bind mounts when in project volumes definition
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-06-02 16:37:24 +02:00
Guillaume Lours
d5528f3a54
Merge pull request #9520 from milas/bugfix-network-ambiguity
fix: prevent network name ambiguity
2022-06-02 12:44:12 +02:00
Guillaume Lours
c64dbbca6c
Merge pull request #9523 from laurazard/add-links-container-create
Add links to container create request.
2022-06-02 12:38:41 +02:00
Guillaume Lours
e90c6ba332
Merge pull request #9522 from ulyssessouza/bump-runc-1.1.2
Bump runc -> 1.1.2
2022-06-02 12:27:08 +02:00
Guillaume Lours
51b4651ea9
Merge pull request #9525 from thaJeztah/update_golang_1.18.3
update golang to 1.18.3
2022-06-02 10:03:29 +02:00
Sebastiaan van Stijn
d2639a8638
update golang to 1.18.3
go1.18.3 (released 2022-06-01) includes security fixes to the crypto/rand,
crypto/tls, os/exec, and path/filepath packages, as well as bug fixes to the
compiler, and the crypto/tls and text/template/parse packages. See the Go
1.18.3 milestone on our issue tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.18.3+label%3ACherryPickApproved

Hello gophers,

We have just released Go versions 1.18.3 and 1.17.11, minor point releases.

These minor releases include 4 security fixes following the security policy:

- crypto/rand: rand.Read hangs with extremely large buffers
  On Windows, rand.Read will hang indefinitely if passed a buffer larger than
  1 << 32 - 1 bytes.

  Thanks to Davis Goodin and Quim Muntal, working at Microsoft on the Go toolset,
  for reporting this issue.

  This is [CVE-2022-30634][CVE-2022-30634] and Go issue https://go.dev/issue/52561.
- crypto/tls: session tickets lack random ticket_age_add
  Session tickets generated by crypto/tls did not contain a randomly generated
  ticket_age_add. This allows an attacker that can observe TLS handshakes to
  correlate successive connections by comparing ticket ages during session
  resumption.

  Thanks to GitHub user nervuri for reporting this.

  This is [CVE-2022-30629][CVE-2022-30629] and Go issue https://go.dev/issue/52814.
- `os/exec`: empty `Cmd.Path` can result in running unintended binary on Windows

  If, on Windows, `Cmd.Run`, `cmd.Start`, `cmd.Output`, or `cmd.CombinedOutput`
  are executed when Cmd.Path is unset and, in the working directory, there are
  binaries named either "..com" or "..exe", they will be executed.

  Thanks to Chris Darroch, brian m. carlson, and Mikhail Shcherbakov for reporting
  this.

  This is [CVE-2022-30580][CVE-2022-30580] and Go issue https://go.dev/issue/52574.
- `path/filepath`: Clean(`.\c:`) returns `c:` on Windows

  On Windows, the `filepath.Clean` function could convert an invalid path to a
  valid, absolute path. For example, Clean(`.\c:`) returned `c:`.

  Thanks to Unrud for reporting this issue.

  This is [CVE-2022-29804][CVE-2022-29804] and Go issue https://go.dev/issue/52476.

[CVE-2022-30634]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-30634
[CVE-2022-30629]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-30629
[CVE-2022-30580]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-30580
[CVE-2022-29804]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29804

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-06-02 09:56:16 +02:00
Laura Brehm
81182fca53 Add links to container create request.
In v1, links were sent alongside the rest of the container create request, as part of `HostConfig`. In v2, links are usually set on the connect container to network request that happens after the create. However, this only happens if the service has one or more networks defined for it. If the services are configured to use the default bridge network, this request is not made and so links are never configured.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-06-02 02:51:25 +02:00
Ulysses Souza
6e7c949787 Bump runc -> 1.1.2
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-06-02 00:08:58 +02:00
Milas Bowman
7f32f02817 fix: prevent network name ambiguity
`NetworkInspect` will match a network ID by prefix. While rare,
it's possible that users might use a network name that is also
a valid network ID prefix for a pre-existing Docker network.
(In the reported case, the network was named `db`, for example.)

Fixes #9496.

Signed-off-by: Milas Bowman <milas@tilt.dev>
2022-06-01 15:28:42 -04:00
Guillaume Lours
335decceda
Merge pull request #9504 from docker/nicksieger/9427
fix: bring up services with deps with --no-deps
2022-05-31 23:39:19 +02:00
Nick Sieger
28c0fbfdc0
e2e: reproduce bug with links
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-05-31 16:32:29 -05:00
Nick Sieger
cacff89cef
fix: bring up services with deps with --no-deps
Don't fail on not finding dependent services because they were put in the
disabled slice.

Fixes #9427.

Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-05-31 16:19:21 -05:00
dependabot[bot]
9db90b35bb
Bump github.com/hashicorp/go-version from 1.3.0 to 1.5.0
Bumps [github.com/hashicorp/go-version](https://github.com/hashicorp/go-version) from 1.3.0 to 1.5.0.
- [Release notes](https://github.com/hashicorp/go-version/releases)
- [Changelog](https://github.com/hashicorp/go-version/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/go-version/compare/v1.3.0...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-version
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-19 09:30:59 +00:00
dependabot[bot]
674aa6a1e4
Bump github.com/theupdateframework/notary from 0.6.1 to 0.7.0
Bumps [github.com/theupdateframework/notary](https://github.com/theupdateframework/notary) from 0.6.1 to 0.7.0.
- [Release notes](https://github.com/theupdateframework/notary/releases)
- [Changelog](https://github.com/notaryproject/notary/blob/master/CHANGELOG.md)
- [Commits](https://github.com/theupdateframework/notary/compare/v0.6.1...v0.7.0)

---
updated-dependencies:
- dependency-name: github.com/theupdateframework/notary
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-17 15:22:26 +00:00
Daniel Lublin
710b637e4a Don't use ansi even when deprecated option is requested
Signed-off-by: Daniel Lublin <daniel@lublin.se>
2022-05-03 14:45:46 +02:00
Milas Bowman
dd5ea044bb ignore: add Go umask files to ephemeral set (#5740)
When creating files in Go, the stdlib will create (and then rapidly
delete) files ending with `-go-tmp-umask` to determine the umask
to use for permission purposes.

This can cause trouble with Live Update because the files tend to
vanish underneath it, for example.

Fixes #5117.
2022-04-27 16:42:51 -04:00
Vedant Koditkar
e24d274bbc Fix breaking TestComposePull test case
Signed-off-by: Vedant Koditkar <vedant.koditkar@outlook.com>
2022-03-05 23:46:08 +05:30
Vedant Koditkar
89dfb9140e Merge branch 'v2' into 8768-avoid-pulling-same-image-multiple-times 2022-03-05 21:53:55 +05:30
Vedant Koditkar
d62c9fe842 Avoid pulling same images multiple times
Signed-off-by: Vedant Koditkar <vedant.koditkar@outlook.com>
2022-02-14 17:16:48 +05:30
Milas Bowman
12de97b8d1 filewatch: use apiserver FileWatch model in EngineState (#4277)
This follows the "action-first" approach to use the apiserver model
for `FileWatch` and dispatch simple create/update/delete actions.
2021-03-09 13:05:32 -05:00
Iggy Jackson
62b5f78fd9 Add .kate-swp files to ignore pattern (#3380)
KDE's text editor, kate, uses a file similar to Vim's .swp files. Ignore
these files so we don't rebuild on every keypress.

Fixes #3378
2020-05-27 07:36:06 -07:00
Nick Santos
3f526c5c7b change org name from windmilleng to tilt-dev (#3346) 2020-05-15 10:34:39 -04:00
Matt Landis
12916b75a2 tilt: ignore a few more vim swap files (#2190) 2019-09-12 11:57:39 -04:00
Maia McCormick
e3948f6bae ignore: auto-ignore jetbrains .idea file (#2065) 2019-08-15 14:38:44 -04:00
Dan Miller
91a2bdd6de model: move to pkg (#2024) 2019-08-09 12:52:31 -04:00
Nick Santos
ce61e7bf18 ignore: improve the ephemeral temp file patterns [ch2663] (#1925) 2019-07-29 11:18:22 -04:00
605 changed files with 40543 additions and 10622 deletions

View File

@ -1,2 +1 @@
bin/
dist/

2
.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1,2 @@
# global rules
* @docker/compose-maintainers

View File

@ -1,64 +0,0 @@
<!--
If you are reporting a new issue, make sure that we do not have any duplicates
already open. You can ensure this by searching the issue list for this
repository. If there is a duplicate, please close your issue and add a comment
to the existing issue instead.
If you suspect your issue is a bug, please edit your issue description to
include the BUG REPORT INFORMATION shown below. If you fail to provide this
information within 7 days, we cannot debug your issue and will close it. We
will, however, reopen it if you later provide the information.
For more information about reporting issues, see
https://github.com/docker/compose-cli/blob/master/CONTRIBUTING.md#reporting-other-issues
---------------------------------------------------
GENERAL SUPPORT INFORMATION
---------------------------------------------------
The GitHub issue tracker is for bug reports and feature requests.
General support can be found at the following locations:
- Docker Support Forums - https://forums.docker.com
- Docker Community Slack - https://dockr.ly/slack
- Post a question on StackOverflow, using the Docker tag
---------------------------------------------------
BUG REPORT INFORMATION
---------------------------------------------------
Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST
-->
**Description**
<!--
Briefly describe the problem you are having in a few paragraphs.
-->
**Steps to reproduce the issue:**
1.
2.
3.
**Describe the results you received:**
**Describe the results you expected:**
**Additional information you deem important (e.g. issue happens only occasionally):**
**Output of `docker compose version`:**
```
(paste your output here)
```
**Output of `docker info`:**
```
(paste your output here)
```
**Additional environment details:**

55
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@ -0,0 +1,55 @@
name: 🐞 Bug
description: File a bug/issue
title: "[BUG] <title>"
labels: ['status/0-triage', 'kind/bug']
body:
- type: textarea
attributes:
label: Description
description: |
Briefly describe the problem you are having.
Include both the current behavior (what you are seeing) as well as what you expected to happen.
validations:
required: true
- type: markdown
attributes:
value: |
[Docker Swarm](https://www.mirantis.com/software/swarm/) uses a distinct compose file parser and
as such doesn't support some of the recent features of Docker Compose. Please contact Mirantis
if you need assistance with compose file support in Docker Swarm.
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
placeholder: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Compose Version
description: |
Paste output of `docker compose version` and `docker-compose version`.
render: Text
validations:
required: false
- type: textarea
attributes:
label: Docker Environment
description: Paste output of `docker info`.
render: Text
validations:
required: false
- type: textarea
attributes:
label: Anything else?
description: |
Links? References? Anything that will give us more context about the issue you are encountering!
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
validations:
required: false

11
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,11 @@
blank_issues_enabled: true
contact_links:
- name: Docker Community Slack
url: https://dockr.ly/slack
about: 'Use the #docker-compose channel'
- name: Docker Support Forums
url: https://forums.docker.com/c/open-source-projects/compose/15
about: 'Use the "Open Source Projects > Compose" category'
- name: 'Ask on Stack Overflow'
url: https://stackoverflow.com/questions/tagged/docker-compose
about: 'Use the [docker-compose] tag when creating new questions'

View File

@ -0,0 +1,13 @@
name: Feature request
description: Missing functionality? Come tell us about it!
labels:
- kind/feature
- status/0-triage
body:
- type: textarea
id: description
attributes:
label: Description
description: What is the feature you want to see?
validations:
required: true

View File

@ -3,4 +3,4 @@
**Related issue**
<!-- If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" -->
**(not mandatory) A picture of a cute animal, if possible in relation with what you did**
**(not mandatory) A picture of a cute animal, if possible in relation to what you did**

44
.github/SECURITY.md vendored Normal file
View File

@ -0,0 +1,44 @@
# Security Policy
The maintainers of Docker Compose take security seriously. If you discover
a security issue, please bring it to their attention right away!
## Reporting a Vulnerability
Please **DO NOT** file a public issue, instead send your report privately
to [security@docker.com](mailto:security@docker.com).
Reporter(s) can expect a response within 72 hours, acknowledging the issue was
received.
## Review Process
After receiving the report, an initial triage and technical analysis is
performed to confirm the report and determine its scope. We may request
additional information in this stage of the process.
Once a reviewer has confirmed the relevance of the report, a draft security
advisory will be created on GitHub. The draft advisory will be used to discuss
the issue with maintainers, the reporter(s), and where applicable, other
affected parties under embargo.
If the vulnerability is accepted, a timeline for developing a patch, public
disclosure, and patch release will be determined. If there is an embargo period
on public disclosure before the patch release, the reporter(s) are expected to
participate in the discussion of the timeline and abide by agreed upon dates
for public disclosure.
## Accreditation
Security reports are greatly appreciated and we will publicly thank you,
although we will keep your name confidential if you request it. We also like to
send gifts - if you're into swag, make sure to let us know. We do not currently
offer a paid security bounty program at this time.
## Supported Versions
This project docs not provide long-term supported versions, and only the current
release and `main` branch are actively maintained. Docker Compose v1, and the
corresponding [v1 branch](https://github.com/docker/compose/tree/v1) reached
EOL and are no longer supported.

View File

@ -4,3 +4,20 @@ updates:
directory: /
schedule:
interval: daily
ignore:
# docker + moby deps require coordination
- dependency-name: "github.com/docker/buildx"
# buildx is still 0.x
update-types: ["version-update:semver-minor"]
- dependency-name: "github.com/moby/buildkit"
# buildkit is still 0.x
update-types: [ "version-update:semver-minor" ]
- dependency-name: "github.com/docker/cli"
update-types: ["version-update:semver-major"]
- dependency-name: "github.com/docker/docker"
update-types: ["version-update:semver-major"]
- dependency-name: "github.com/containerd/containerd"
# containerd major/minor must be kept in sync with moby
update-types: [ "version-update:semver-major", "version-update:semver-minor" ]
# OTEL dependencies should be upgraded in sync with engine, cli, buildkit and buildx projects
- dependency-name: "go.opentelemetry.io/*"

4
.github/stale.yml vendored
View File

@ -1,7 +1,7 @@
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 180
daysUntilStale: 90
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
@ -12,7 +12,7 @@ onlyLabels: []
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- "enhancement ✨"
- "kind/feature"
# Set to true to ignore issues in a project (defaults to false)
exemptProjects: false

View File

@ -1,63 +0,0 @@
name: Publish Artifacts
on:
issue_comment:
types: [created]
jobs:
publish-artifacts:
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/generate-artifacts')
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.18.2
id: go
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
- name: Build cross platform compose-plugin binaries
run: make -f builder.Makefile cross
- name: Upload macos-amd64 binary
uses: actions/upload-artifact@v2
with:
name: docker-compose-darwin-amd64
path: ${{ github.workspace }}/bin/docker-compose-darwin-amd64
- name: Upload macos-arm64 binary
uses: actions/upload-artifact@v2
with:
name: docker-compose-darwin-arm64
path: ${{ github.workspace }}/bin/docker-compose-darwin-arm64
- name: Upload linux-amd64 binary
uses: actions/upload-artifact@v2
with:
name: docker-compose-linux-amd64
path: ${{ github.workspace }}/bin/docker-compose-linux-amd64
- name: Upload linux-ppc64le binary
uses: actions/upload-artifact@v2
with:
name: docker-compose-linux-ppc64le
path: ${{ github.workspace }}/bin/docker-compose-linux-ppc64le
- name: Upload windows-amd64 binary
uses: actions/upload-artifact@v2
with:
name: docker-compose-windows-amd64.exe
path: ${{ github.workspace }}/bin/docker-compose-windows-amd64.exe
- name: Update comment
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.comment.id }}
body: |
This PR can be tested using [binaries](https://github.com/docker/compose-cli/actions/runs/${{ github.run_id }}).
reactions: eyes

View File

@ -1,9 +1,15 @@
name: Continuous integration
name: ci
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- v2
- 'main'
tags:
- 'v*'
pull_request:
workflow_dispatch:
inputs:
@ -12,134 +18,316 @@ on:
required: false
default: "false"
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
lint:
name: Lint
prepare:
runs-on: ubuntu-latest
env:
GO111MODULE: "on"
outputs:
matrix: ${{ steps.platforms.outputs.matrix }}
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.18.2
id: go
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
- name: Validate go-mod, license headers and docs are up-to-date
run: make validate
- name: Run golangci-lint
env:
BUILD_TAGS: e2e
uses: golangci/golangci-lint-action@v2
with:
args: --timeout=180s
# only on main branch, costs too much for the gain on every PR
validate-cross-build:
name: Validate cross build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
env:
GO111MODULE: "on"
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.18.2
id: go
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
# Ensure we don't discover cross platform build issues at release time.
# Time used to build linux here is gained back in the build for local E2E step
- name: Build packages
run: make -f builder.Makefile cross
build-plugin:
name: Build and tests in plugin mode
runs-on: ubuntu-latest
env:
GO111MODULE: "on"
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.18.2
id: go
- name: Setup docker CLI
-
name: Checkout
uses: actions/checkout@v4
-
name: Create matrix
id: platforms
run: |
curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.3.tgz | tar xz
sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
- name: Test
run: make -f builder.Makefile test
- name: Build for local E2E
env:
BUILD_TAGS: e2e
run: make GIT_TAG=e2e-PR-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} -f builder.Makefile compose-plugin
- name: E2E Test in plugin mode
run: make e2e-compose
build-standalone:
name: Build and tests in standalone mode
runs-on: ubuntu-latest
env:
GO111MODULE: "on"
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.18.2
id: go
- name: Setup docker CLI
echo matrix=$(docker buildx bake binary-cross --print | jq -cr '.target."binary-cross".platforms') >> $GITHUB_OUTPUT
-
name: Show matrix
run: |
curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.3.tgz | tar xz
sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version
echo ${{ steps.platforms.outputs.matrix }}
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
validate:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- lint
- validate-go-mod
- validate-headers
- validate-docs
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Run
run: |
make ${{ matrix.target }}
- uses: actions/cache@v2
binary:
runs-on: ubuntu-latest
needs:
- prepare
strategy:
fail-fast: false
matrix:
platform: ${{ fromJson(needs.prepare.outputs.matrix) }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Prepare
run: |
platform=${MATRIX_PLATFORM}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
env:
MATRIX_PLATFORM: ${{ matrix.platform }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build
uses: docker/bake-action@v6
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
source: .
targets: release
provenance: mode=max
sbom: true
set: |
*.platform=${{ matrix.platform }}
*.cache-from=type=gha,scope=binary-${{ env.PLATFORM_PAIR }}
*.cache-to=type=gha,scope=binary-${{ env.PLATFORM_PAIR }},mode=max
-
name: Rename provenance and sbom
working-directory: ./bin/release
run: |
binname=$(find . -name 'docker-compose-*')
filename=$(basename "$binname" | sed -E 's/\.exe$//')
mv "provenance.json" "${filename}.provenance.json"
mv "sbom-binary.spdx.json" "${filename}.sbom.json"
find . -name 'sbom*.json' -exec rm {} \;
-
name: List artifacts
run: |
tree -nh ./bin/release
-
name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: compose-${{ env.PLATFORM_PAIR }}
path: ./bin/release
if-no-files-found: error
- name: Build for local E2E
test:
runs-on: ubuntu-latest
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Test
uses: docker/bake-action@v6
with:
targets: test
set: |
*.cache-from=type=gha,scope=test
*.cache-to=type=gha,scope=test
-
name: Gather coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-unit
path: bin/coverage/unit/
if-no-files-found: error
-
name: Unit Test Summary
uses: test-summary/action@v2
with:
paths: bin/coverage/unit/report.xml
if: always()
e2e:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
mode:
- plugin
- standalone
engine:
- 26
- 27
- 28
steps:
- name: Prepare
run: |
mode=${{ matrix.mode }}
engine=${{ matrix.engine }}
echo "MODE_ENGINE_PAIR=${mode}-${engine}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Install Docker ${{ matrix.engine }}
run: |
sudo systemctl stop docker.service
sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin
sudo apt-get install curl
curl -fsSL https://test.docker.com -o get-docker.sh
sudo sh ./get-docker.sh --version ${{ matrix.engine }}
- name: Check Docker Version
run: docker --version
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Docker Model
run: |
sudo apt-get install docker-model-plugin
docker model version
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: true
cache: true
- name: Build example provider
run: make example-provider
- name: Build
uses: docker/bake-action@v6
with:
source: .
targets: binary-with-coverage
set: |
*.cache-from=type=gha,scope=binary-linux-amd64
*.cache-from=type=gha,scope=binary-e2e-${{ matrix.mode }}
*.cache-to=type=gha,scope=binary-e2e-${{ matrix.mode }},mode=max
env:
BUILD_TAGS: e2e
run: make GIT_TAG=e2e-PR-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} -f builder.Makefile compose-plugin
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
uses: mxschmitt/action-tmate@8b4e4ac71822ed7e0ad5fb3d1c33483e9e8fb270 # v3.11
with:
limit-access-to-actor: true
github-token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
- name: E2E Test in standalone mode
- name: Test plugin mode
if: ${{ matrix.mode == 'plugin' }}
run: |
rm -rf ./bin/coverage/e2e
mkdir -p ./bin/coverage/e2e
make e2e-compose GOCOVERDIR=bin/coverage/e2e TEST_FLAGS="-v"
- name: Gather coverage data
if: ${{ matrix.mode == 'plugin' }}
uses: actions/upload-artifact@v4
with:
name: coverage-data-e2e-${{ env.MODE_ENGINE_PAIR }}
path: bin/coverage/e2e/
if-no-files-found: error
- name: Test standalone mode
if: ${{ matrix.mode == 'standalone' }}
run: |
rm -f /usr/local/bin/docker-compose
cp bin/docker-compose /usr/local/bin
cp bin/build/docker-compose /usr/local/bin
make e2e-compose-standalone
- name: e2e Test Summary
uses: test-summary/action@v2
with:
paths: /tmp/report/report.xml
if: always()
coverage:
runs-on: ubuntu-latest
needs:
- test
- e2e
steps:
# codecov won't process the report without the source code available
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: true
- name: Download unit test coverage
uses: actions/download-artifact@v4
with:
name: coverage-data-unit
path: coverage/unit
merge-multiple: true
- name: Download E2E test coverage
uses: actions/download-artifact@v4
with:
pattern: coverage-data-e2e-*
path: coverage/e2e
merge-multiple: true
- name: Merge coverage reports
run: |
go tool covdata textfmt -i=./coverage/unit,./coverage/e2e -o ./coverage.txt
- name: Store coverage report in GitHub Actions
uses: actions/upload-artifact@v4
with:
name: go-covdata-txt
path: ./coverage.txt
if-no-files-found: error
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.txt
release:
permissions:
contents: write # to create a release (ncipollo/release-action)
runs-on: ubuntu-latest
needs:
- binary
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: compose-*
path: ./bin/release
merge-multiple: true
-
name: Create checksums
working-directory: ./bin/release
run: |
find . -type f -print0 | sort -z | xargs -r0 shasum -a 256 -b | sed 's# \*\./# *#' > $RUNNER_TEMP/checksums.txt
shasum -a 256 -U -c $RUNNER_TEMP/checksums.txt
mv $RUNNER_TEMP/checksums.txt .
cat checksums.txt | while read sum file; do
if [[ "${file#\*}" == docker-compose-* && "${file#\*}" != *.provenance.json && "${file#\*}" != *.sbom.json ]]; then
echo "$sum $file" > ${file#\*}.sha256
fi
done
-
name: List artifacts
run: |
tree -nh ./bin/release
-
name: Check artifacts
run: |
find bin/release -type f -exec file -e ascii -- {} +
-
name: GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: ncipollo/release-action@58ae73b360456532aafd58ee170c045abbeaee37 # v1.10.0
with:
artifacts: ./bin/release/*
generateReleaseNotes: true
draft: true
token: ${{ secrets.GITHUB_TOKEN }}

51
.github/workflows/docs-upstream.yml vendored Normal file
View File

@ -0,0 +1,51 @@
# this workflow runs the remote validate bake target from docker/docs
# to check if yaml reference docs used in this repo are valid
name: docs-upstream
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- 'main'
- 'v[0-9]*'
paths:
- '.github/workflows/docs-upstream.yml'
- 'docs/**'
pull_request:
paths:
- '.github/workflows/docs-upstream.yml'
- 'docs/**'
jobs:
docs-yaml:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Upload reference YAML docs
uses: actions/upload-artifact@v4
with:
name: docs-yaml
path: docs/reference
retention-days: 1
validate:
uses: docker/docs/.github/workflows/validate-upstream.yml@main
needs:
- docs-yaml
with:
module-name: docker/compose

163
.github/workflows/merge.yml vendored Normal file
View File

@ -0,0 +1,163 @@
name: merge
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- 'main'
tags:
- 'v*'
permissions:
contents: read # to fetch code (actions/checkout)
env:
REPO_SLUG: "docker/compose-bin"
jobs:
e2e:
name: Build and test
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [desktop-windows, desktop-macos, desktop-m1]
# mode: [plugin, standalone]
mode: [plugin]
env:
GO111MODULE: "on"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
check-latest: true
- name: List Docker resources on machine
run: |
docker ps --all
docker volume ls
docker network ls
docker image ls
- name: Remove Docker resources on machine
continue-on-error: true
run: |
docker kill $(docker ps -q)
docker rm -f $(docker ps -aq)
docker volume rm -f $(docker volume ls -q)
docker ps --all
- name: Unit tests
run: make test
- name: Build binaries
run: |
make
- name: Check arch of go compose binary
run: |
file ./bin/build/docker-compose
if: ${{ !contains(matrix.os, 'desktop-windows') }}
-
name: Test plugin mode
if: ${{ matrix.mode == 'plugin' }}
run: |
make e2e-compose
-
name: Test standalone mode
if: ${{ matrix.mode == 'standalone' }}
run: |
make e2e-compose-standalone
bin-image:
runs-on: ubuntu-22.04
outputs:
digest: ${{ fromJSON(steps.bake.outputs.metadata).image-cross['containerimage.digest'] }}
steps:
-
name: Free disk space
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERPUBLICBOT_USERNAME }}
password: ${{ secrets.DOCKERPUBLICBOT_WRITE_PAT }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REPO_SLUG }}
tags: |
type=ref,event=tag
type=edge
bake-target: meta-helper
-
name: Build and push image
uses: docker/bake-action@v6
id: bake
with:
source: .
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: image-cross
push: ${{ github.event_name != 'pull_request' }}
sbom: true
provenance: mode=max
set: |
*.cache-from=type=gha,scope=bin-image
*.cache-to=type=gha,scope=bin-image,mode=max
desktop-edge-test:
runs-on: ubuntu-latest
needs: bin-image
steps:
-
name: Generate Token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.DOCKERDESKTOP_APP_ID }}
private-key: ${{ secrets.DOCKERDESKTOP_APP_PRIVATEKEY }}
owner: docker
repositories: |
${{ secrets.DOCKERDESKTOP_REPO }}
-
name: Trigger Docker Desktop e2e with edge version
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate_token.outputs.token }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'docker',
repo: '${{ secrets.DOCKERDESKTOP_REPO }}',
workflow_id: 'compose-edge-integration.yml',
ref: 'main',
inputs: {
"image-tag": "${{ needs.bin-image.outputs.digest }}"
}
})

View File

@ -1,11 +0,0 @@
name: PR cleanup
on:
pull_request:
types: [closed]
jobs:
delete_pr_artifacts:
runs-on: ubuntu-latest
steps:
- uses: stefanluptak/delete-old-pr-artifacts@v1
with:
workflow_filename: ci.yaml

View File

@ -1,19 +0,0 @@
name: Automatic Rebase
on:
issue_comment:
types: [created]
jobs:
rebase:
name: Rebase
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,51 +0,0 @@
name: Releaser
on:
workflow_dispatch:
inputs:
tag:
description: "Release Tag"
required: true
jobs:
upload-release:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.18.2
id: go
- name: Setup docker CLI
run: |
curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.3.tgz | tar xz
sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
run: make GIT_TAG=${{ github.event.inputs.tag }} -f builder.Makefile cross
- name: Compute checksums
run: cd bin; for f in *; do shasum --binary --algorithm 256 $f | tee -a checksums.txt > $f.sha256; done
- name: License
run: cp packaging/* bin/
- uses: ncipollo/release-action@v1
with:
artifacts: "bin/*"
generateReleaseNotes: true
draft: true
commit: "v2"
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.inputs.tag }}

63
.github/workflows/scorecards.yml vendored Normal file
View File

@ -0,0 +1,63 @@
name: Scorecards supply-chain security
on:
# Only the default branch is supported.
branch_protection_rule:
schedule:
- cron: '44 9 * * 4'
push:
branches: [ "main" ]
jobs:
analysis:
name: Scorecards analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Used to receive a badge.
id-token: write
# read permissions to all the other objects
actions: read
attestations: read
checks: read
contents: read
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
statuses: read
steps:
- name: "Checkout code"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.4.2
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # tag=v2.4.0
with:
results_file: results.sarif
results_format: sarif
# Publish the results for public repositories to enable scorecard badges. For more details, see
# https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories, `publish_results` will automatically be set to `false`, regardless
# of the value entered here.
publish_results: true
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # tag=v4.5.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@3096afedf9873361b2b2f65e1445b13272c83eb8 # tag=v2.20.00
with:
sarif_file: results.sarif

33
.github/workflows/stale.yml vendored Normal file
View File

@ -0,0 +1,33 @@
name: 'Close stale issues'
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
on:
schedule:
- cron: '0 0 * * 0,3' # at midnight UTC every Sunday and Wednesday
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
days-before-issue-stale: 150 # marks stale after 5 months
days-before-issue-close: 30 # closes 1 month after being marked with no action
stale-issue-label: "stale"
exempt-issue-labels: "kind/feature,kind/enhancement"

4
.gitignore vendored
View File

@ -1,3 +1,5 @@
bin/
dist/
/.vscode/
coverage.out
covdatafiles/
.DS_Store

View File

@ -1,38 +1,89 @@
version: "2"
run:
concurrency: 2
linters:
run:
concurrency: 2
skip-dirs:
- tests/composefiles
enable-all: false
disable-all: true
default: none
enable:
- deadcode
- copyloopvar
- depguard
- errcheck
- errorlint
- gocritic
- gocyclo
- gofmt
- goimports
- revive
- gosimple
- gomodguard
- govet
- ineffassign
- lll
- misspell
- nakedret
- nolintlint
- revive
- staticcheck
- structcheck
- typecheck
- testifylint
- unconvert
- unparam
- unused
- varcheck
linters-settings:
gocyclo:
min-complexity: 16
lll:
line-length: 200
settings:
depguard:
rules:
all:
deny:
- pkg: io/ioutil
desc: io/ioutil package has been deprecated
- pkg: github.com/docker/docker/errdefs
desc: use github.com/containerd/errdefs instead.
- pkg: golang.org/x/exp/maps
desc: use stdlib maps package
- pkg: golang.org/x/exp/slices
desc: use stdlib slices package
- pkg: gopkg.in/yaml.v2
desc: compose-go uses yaml.v3
gocritic:
disabled-checks:
- paramTypeCombine
- unnamedResult
- whyNoLint
enabled-tags:
- diagnostic
- opinionated
- style
gocyclo:
min-complexity: 16
gomodguard:
blocked:
modules:
- github.com/pkg/errors:
recommendations:
- errors
- fmt
versions:
- github.com/distribution/distribution:
reason: use distribution/reference
- gotest.tools:
version: < 3.0.0
reason: deprecated, pre-modules version
lll:
line-length: 200
revive:
rules:
- name: package-comments
disabled: true
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
issues:
# golangci hides some golint warnings (the warning about exported things
# withtout documentation for example), this will make it show them anyway.
exclude-use-default: false
exclude:
- should not use dot imports
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$

View File

@ -2,14 +2,17 @@
### Prerequisites
* Windows:
* [Docker Desktop](https://hub.docker.com/editions/community/docker-ce-desktop-windows)
* [Docker Desktop](https://docs.docker.com/desktop/setup/install/windows-install/)
* make
* go (see [go.mod](go.mod) for minimum version)
* macOS:
* [Docker Desktop](https://hub.docker.com/editions/community/docker-ce-desktop-mac)
* [Docker Desktop](https://docs.docker.com/desktop/setup/install/mac-install/)
* make
* go (see [go.mod](go.mod) for minimum version)
* Linux:
* [Docker 20.10 or later](https://docs.docker.com/engine/install/)
* make
* go (see [go.mod](go.mod) for minimum version)
### Building the CLI
@ -19,7 +22,8 @@ Once you have the prerequisites installed, you can build the CLI using:
make
```
This will output a `docker-compose` CLI plugin for your host machine in `./bin`.
This will output a `docker-compose` CLI plugin for your host machine in
`./bin/build`.
You can statically cross compile the CLI for Windows, macOS, and Linux using the
`cross` target.
@ -34,21 +38,57 @@ make test
If you need to update a golden file simply do `go test ./... -test.update-golden`.
### End to end tests
### End-to-end tests
To run e2e tests, the Compose CLI binary needs to be built. All the commands to run e2e tests propose a version
with the prefix `build-and-e2e` to first build the CLI before executing tests.
To run the end to end tests, run:
Note that this requires a local Docker Engine to be running.
#### Whole end-to-end tests suite
To execute both CLI and standalone e2e tests, run :
```console
make e2e
```
Or if you need to build the CLI, run:
```console
make build-and-e2e
```
#### Plugin end-to-end tests suite
To execute CLI plugin e2e tests, run :
```console
make e2e-compose
```
Note that this requires a local Docker Engine to be running.
Or if you need to build the CLI, run:
```console
make build-and-e2e-compose
```
#### Standalone end-to-end tests suite
To execute the standalone CLI e2e tests, run :
```console
make e2e-compose-standalone
```
Or if you need to build the CLI, run:
```console
make build-and-e2e-compose-standalone
```
## Releases
To create a new release:
* Check that the CI is green on the main branch for commit you want to release
* Run the release Github Actions workflow with a tag of the form vx.y.z following existing tags.
* Check that the CI is green on the main branch for the commit you want to release
* Run the release GitHub Actions workflow with a tag of form vx.y.z following existing tags.
This will automatically create a new tag, release and make binaries for
Windows, macOS, and Linux available for download on the

View File

@ -2,7 +2,7 @@
Want to hack on Docker? Awesome! We have a contributor's guide that explains
[setting up a Docker development environment and the contribution
process](https://docs.docker.com/opensource/project/who-written-for/).
process](https://docs.docker.com/contribute/).
This page contains information about reporting issues as well as some tips and
guidelines useful to experienced open source contributors. Finally, make sure
@ -11,23 +11,31 @@ start participating.
## Topics
* [Reporting Security Issues](#reporting-security-issues)
* [Design and Cleanup Proposals](#design-and-cleanup-proposals)
* [Reporting Issues](#reporting-other-issues)
* [Quick Contribution Tips and Guidelines](#quick-contribution-tips-and-guidelines)
* [Community Guidelines](#docker-community-guidelines)
- [Contributing to Docker](#contributing-to-docker)
- [Topics](#topics)
- [Reporting security issues](#reporting-security-issues)
- [Reporting other issues](#reporting-other-issues)
- [Quick contribution tips and guidelines](#quick-contribution-tips-and-guidelines)
- [Pull requests are always welcome](#pull-requests-are-always-welcome)
- [Talking to other Docker users and contributors](#talking-to-other-docker-users-and-contributors)
- [Conventions](#conventions)
- [Merge approval](#merge-approval)
- [Sign your work](#sign-your-work)
- [How can I become a maintainer?](#how-can-i-become-a-maintainer)
- [Docker community guidelines](#docker-community-guidelines)
- [Coding Style](#coding-style)
## Reporting security issues
The Docker maintainers take security seriously. If you discover a security
issue, please bring it to their attention right away!
Please **DO NOT** file a public issue, instead send your report privately to
Please **DO NOT** file a public issue, instead, send your report privately to
[security@docker.com](mailto:security@docker.com).
Security reports are greatly appreciated and we will publicly thank you for it.
Security reports are greatly appreciated and we will publicly thank you for them.
We also like to send gifts&mdash;if you're into Docker swag, make sure to let
us know. We currently do not offer a paid security bounty program, but are not
us know. We currently do not offer a paid security bounty program but are not
ruling it out in the future.
@ -39,11 +47,11 @@ and will thank you for it!
Check that [our issue database](https://github.com/docker/compose/labels/Docker%20Compose%20V2)
doesn't already include that problem or suggestion before submitting an issue.
If you find a match, you can use the "subscribe" button to get notified on
If you find a match, you can use the "subscribe" button to get notified of
updates. Do *not* leave random "+1" or "I have this too" comments, as they
only clutter the discussion, and don't help to resolve it. However, if you
have ways to reproduce the issue or have additional information that may help
resolving the issue, please leave a comment.
resolve the issue, please leave a comment.
When reporting issues, always include:
@ -51,13 +59,18 @@ When reporting issues, always include:
* The output of `docker context show`.
* The output of `docker info`.
Also include the steps required to reproduce the problem if possible and
Also, include the steps required to reproduce the problem if possible and
applicable. This information will help us review and fix your issue faster.
When sending lengthy log files, consider posting them as a gist
(https://gist.github.com).
Don't forget to remove sensitive data from your log files before posting (you
can replace those parts with "REDACTED").
_Note:_
Maintainers might request additional information to diagnose an issue,
if initial reporter doesn't answer within a reasonable delay (a few weeks),
issue will be closed.
## Quick contribution tips and guidelines
This section gives the experienced contributor some tips and guidelines.
@ -72,8 +85,7 @@ before anybody starts working on it.
We are always thrilled to receive pull requests. We do our best to process them
quickly. If your pull request is not accepted on the first try,
don't get discouraged! Our contributor's guide explains
[the review process we use for simple changes](https://docs.docker.com/opensource/workflow/make-a-contribution/).
don't get discouraged!
### Talking to other Docker users and contributors
@ -83,7 +95,7 @@ don't get discouraged! Our contributor's guide explains
<tr>
<td>Community Slack</td>
<td>
The Docker Community has a dedicated Slack chat to discuss features and issues. You can sign-up <a href="https://www.docker.com/docker-community" target="_blank">with this link</a>.
The Docker Community has a dedicated Slack chat to discuss features and issues. You can sign-up <a href="https://www.docker.com/community/" target="_blank">with this link</a>.
</td>
</tr>
<tr>
@ -106,7 +118,7 @@ don't get discouraged! Our contributor's guide explains
<td>Stack Overflow</td>
<td>
Stack Overflow has over 17000 Docker questions listed. We regularly
monitor <a href="https://stackoverflow.com/search?tab=newest&q=docker" target="_blank">Docker questions</a>
monitor <a href="https://stackoverflow.com/questions/tagged/docker" target="_blank">Docker questions</a>
and so do many other knowledgeable Docker users.
</td>
</tr>
@ -124,9 +136,10 @@ Fork the repository and make changes on your fork in a feature branch:
issue.
Submit unit tests for your changes. Go has a great test framework built in; use
it! Take a look at existing tests for inspiration. [Run the full test
suite](README.md) on your branch before
submitting a pull request.
it! Take a look at existing tests for inspiration. Also, end-to-end tests are
available. Run the full test suite, both unit tests and e2e tests on your
branch before submitting a pull request. See [BUILDING.md](BUILDING.md) for
instructions to build and run tests.
Write clean code. Universally formatted code promotes ease of writing, reading,
and maintenance. Always run `gofmt -s -w file.go` on each changed file before
@ -144,7 +157,7 @@ suggested modifications and push additional commits to your feature branch. Post
a comment after pushing. New commits show up in the pull request automatically,
but the reviewers are notified only when you comment.
Pull requests must be cleanly rebased on top of master without multiple branches
Pull requests must be cleanly rebased on top of the base branch without multiple branches
mixed into the PR.
**Git tip**: If your PR no longer merges cleanly, use `rebase master` in your
@ -164,7 +177,7 @@ changes in the same pull request so that a revert would remove all traces of
the feature or fix.
Include an issue reference like `Closes #XXXX` or `Fixes #XXXX` in the pull
request description that close an issue. Including references automatically
request description that closes an issue. Including references automatically
closes the issue on a merge.
Please do not add yourself to the `AUTHORS` file, as it is regenerated regularly
@ -187,7 +200,7 @@ For more details, see the [MAINTAINERS](MAINTAINERS) page.
The sign-off is a simple line at the end of the explanation for the patch. Your
signature certifies that you wrote the patch or otherwise have the right to pass
it on as an open-source patch. The rules are pretty simple: if you can certify
the below (from [developercertificate.org](http://developercertificate.org/)):
the below (from [developercertificate.org](https://developercertificate.org/)):
```
Developer Certificate of Origin
@ -239,7 +252,7 @@ commit automatically with `git commit -s`.
### How can I become a maintainer?
The procedures for adding new maintainers are explained in the global
[MAINTAINERS](https://github.com/docker/opensource/blob/master/MAINTAINERS)
[MAINTAINERS](https://github.com/docker/opensource/blob/main/MAINTAINERS)
file in the
[https://github.com/docker/opensource/](https://github.com/docker/opensource/)
repository.
@ -255,7 +268,7 @@ your help to keep it that way. To help with this we've come up with some general
guidelines for the community as a whole:
* Be nice: Be courteous, respectful and polite to fellow community members:
no regional, racial, gender, or other abuse will be tolerated. We like
no regional, racial, gender or other abuse will be tolerated. We like
nice people way better than mean ones!
* Encourage diversity and participation: Make everyone in our community feel
@ -269,10 +282,10 @@ guidelines for the community as a whole:
* Stay on topic: Make sure that you are posting to the correct channel and
avoid off-topic discussions. Remember when you update an issue or respond
to an email you are potentially sending to a large number of people. Please
consider this before you update. Also remember that nobody likes spam.
to an email you are potentially sending it to a large number of people. Please
consider this before you update. Also, remember that nobody likes spam.
* Don't send email to the maintainers: There's no need to send email to the
* Don't send emails to the maintainers: There's no need to send emails to the
maintainers to ask them to investigate an issue or to take a look at a
pull request. Instead of sending an email, GitHub mentions should be
used to ping maintainers to review a pull request, a proposal or an
@ -286,7 +299,7 @@ to result in a solid, consistent codebase.
It is possible that the code base does not currently comply with these
guidelines. We are not looking for a massive PR that fixes this, since that
goes against the spirit of the guidelines. All new contributions should make a
goes against the spirit of the guidelines. All new contributors should make their
best effort to clean up and make the code base better than they left it.
Obviously, apply your best judgement. Remember, the goal here is to make the
code base easier for humans to navigate and understand. Always keep that in
@ -298,9 +311,9 @@ The rules:
2. All code should pass the default levels of
[`golint`](https://github.com/golang/lint).
3. All code should follow the guidelines covered in [Effective
Go](http://golang.org/doc/effective_go.html) and [Go Code Review
Comments](https://github.com/golang/go/wiki/CodeReviewComments).
4. Comment the code. Tell us the why, the history and the context.
Go](https://go.dev/doc/effective_go) and [Go Code Review
Comments](https://go.dev/wiki/CodeReviewComments).
4. Include code comments. Tell us the why, the history and the context.
5. Document _all_ declarations and methods, even private ones. Declare
expectations, caveats and anything else that may be important. If a type
gets exported, having the comments already there will ensure it's ready.
@ -321,6 +334,6 @@ The rules:
guidelines. Since you've read all the rules, you now know that.
If you are having trouble getting into the mood of idiomatic Go, we recommend
reading through [Effective Go](https://golang.org/doc/effective_go.html). The
[Go Blog](https://blog.golang.org) is also a great resource. Drinking the
reading through [Effective Go](https://go.dev/doc/effective_go). The
[Go Blog](https://go.dev/blog/) is also a great resource. Drinking the
kool-aid is a lot easier than going thirsty.

View File

@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1.2
# syntax=docker/dockerfile:1
# Copyright 2020 Docker Compose CLI authors
@ -15,93 +15,183 @@
# See the License for the specific language governing permissions and
# limitations under the License.
ARG GO_VERSION=1.18.2-alpine
ARG GOLANGCI_LINT_VERSION=v1.40.1-alpine
ARG PROTOC_GEN_GO_VERSION=v1.4.3
ARG GO_VERSION=1.23.12
ARG XX_VERSION=1.6.1
ARG GOLANGCI_LINT_VERSION=v2.0.2
ARG ADDLICENSE_VERSION=v1.0.0
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS base
WORKDIR /compose-cli
RUN apk add --no-cache -vv \
git \
docker \
make \
protoc \
protobuf-dev
ARG BUILD_TAGS="e2e"
ARG DOCS_FORMATS="md,yaml"
ARG LICENSE_FILES=".*\(Dockerfile\|Makefile\|\.go\|\.hcl\|\.sh\)"
# xx is a helper for cross-compilation
FROM --platform=${BUILDPLATFORM} tonistiigi/xx:${XX_VERSION} AS xx
# osxcross contains the MacOSX cross toolchain for xx
FROM crazymax/osxcross:11.3-alpine AS osxcross
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint
FROM ghcr.io/google/addlicense:${ADDLICENSE_VERSION} AS addlicense
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine AS base
COPY --from=xx / /
RUN apk add --no-cache \
clang \
docker \
file \
findutils \
git \
make \
protoc \
protobuf-dev
WORKDIR /src
ENV CGO_ENABLED=0
FROM base AS build-base
COPY go.* .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download
FROM base AS lint
ENV CGO_ENABLED=0
COPY --from=golangci/golangci-lint /usr/bin/golangci-lint /usr/bin/golangci-lint
ARG BUILD_TAGS
ARG GIT_TAG
RUN --mount=target=. \
FROM build-base AS vendored
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/.cache/golangci-lint \
BUILD_TAGS=${BUILD_TAGS} \
GIT_TAG=${GIT_TAG} \
make -f builder.Makefile lint
go mod tidy && mkdir /out && cp go.mod go.sum /out
FROM base AS make-compose-plugin
ENV CGO_ENABLED=0
FROM scratch AS vendor-update
COPY --from=vendored /out /
FROM vendored AS vendor-validate
RUN --mount=type=bind,target=.,rw <<EOT
set -e
git add -A
cp -rf /out/* .
diff=$(git status --porcelain -- go.mod go.sum)
if [ -n "$diff" ]; then
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make go-mod-tidy"'
echo "$diff"
exit 1
fi
EOT
FROM build-base AS build
ARG BUILD_TAGS
ARG BUILD_FLAGS
ARG TARGETPLATFORM
RUN --mount=type=bind,target=. \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=bind,from=osxcross,src=/osxsdk,target=/xx-sdk \
xx-go --wrap && \
if [ "$(xx-info os)" == "darwin" ]; then export CGO_ENABLED=1; fi && \
make build GO_BUILDTAGS="$BUILD_TAGS" DESTDIR=/out && \
xx-verify --static /out/docker-compose
FROM build-base AS lint
ARG BUILD_TAGS
ENV GOLANGCI_LINT_CACHE=/cache/golangci-lint
RUN --mount=type=bind,target=. \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/cache/golangci-lint \
--mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \
golangci-lint cache status && \
golangci-lint run --build-tags "$BUILD_TAGS" ./...
FROM build-base AS test
ARG CGO_ENABLED=0
ARG BUILD_TAGS
RUN --mount=type=bind,target=. \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/go/pkg/mod \
rm -rf /tmp/coverage && \
mkdir -p /tmp/coverage && \
rm -rf /tmp/report && \
mkdir -p /tmp/report && \
go run gotest.tools/gotestsum@latest --format testname --junitfile "/tmp/report/report.xml" -- -tags "$BUILD_TAGS" -v -cover -covermode=atomic $(go list $(TAGS) ./... | grep -vE 'e2e') -args -test.gocoverdir="/tmp/coverage" && \
go tool covdata percent -i=/tmp/coverage
FROM scratch AS test-coverage
COPY --from=test --link /tmp/coverage /
COPY --from=test --link /tmp/report /
FROM base AS license-set
ARG LICENSE_FILES
RUN --mount=type=bind,target=.,rw \
--mount=from=addlicense,source=/app/addlicense,target=/usr/bin/addlicense \
find . -regex "${LICENSE_FILES}" | xargs addlicense -c 'Docker Compose CLI' -l apache && \
mkdir /out && \
find . -regex "${LICENSE_FILES}" | cpio -pdm /out
FROM scratch AS license-update
COPY --from=set /out /
FROM base AS license-validate
ARG LICENSE_FILES
RUN --mount=type=bind,target=. \
--mount=from=addlicense,source=/app/addlicense,target=/usr/bin/addlicense \
find . -regex "${LICENSE_FILES}" | xargs addlicense -check -c 'Docker Compose CLI' -l apache -ignore validate -ignore testdata -ignore resolvepath -v
FROM base AS docsgen
WORKDIR /src
RUN --mount=target=. \
--mount=target=/root/.cache,type=cache \
--mount=type=cache,target=/go/pkg/mod \
go build -o /out/docsgen ./docs/yaml/main/generate.go
FROM --platform=${BUILDPLATFORM} alpine AS docs-build
RUN apk add --no-cache rsync git
WORKDIR /src
COPY --from=docsgen /out/docsgen /usr/bin
ARG DOCS_FORMATS
RUN --mount=target=/context \
--mount=target=.,type=tmpfs <<EOT
set -e
rsync -a /context/. .
docsgen --formats "$DOCS_FORMATS" --source "docs/reference"
mkdir /out
cp -r docs/reference /out
EOT
FROM scratch AS docs-update
COPY --from=docs-build /out /out
FROM docs-build AS docs-validate
RUN --mount=target=/context \
--mount=target=.,type=tmpfs <<EOT
set -e
rsync -a /context/. .
git add -A
rm -rf docs/reference/*
cp -rf /out/* ./docs/
if [ -n "$(git status --porcelain -- docs/reference)" ]; then
echo >&2 'ERROR: Docs result differs. Please update with "make docs"'
git status --porcelain -- docs/reference
exit 1
fi
EOT
FROM scratch AS binary-unix
COPY --link --from=build /out/docker-compose /
FROM binary-unix AS binary-darwin
FROM binary-unix AS binary-linux
FROM scratch AS binary-windows
COPY --link --from=build /out/docker-compose /docker-compose.exe
FROM binary-$TARGETOS AS binary
# enable scanning for this stage
ARG BUILDKIT_SBOM_SCAN_STAGE=true
FROM --platform=$BUILDPLATFORM alpine AS releaser
WORKDIR /work
ARG TARGETOS
ARG TARGETARCH
ARG BUILD_TAGS
ARG GIT_TAG
RUN --mount=target=. \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
BUILD_TAGS=${BUILD_TAGS} \
GIT_TAG=${GIT_TAG} \
make COMPOSE_BINARY=/out/docker-compose -f builder.Makefile compose-plugin
ARG TARGETVARIANT
RUN --mount=from=binary \
mkdir -p /out && \
# TODO: should just use standard arch
TARGETARCH=$([ "$TARGETARCH" = "amd64" ] && echo "x86_64" || echo "$TARGETARCH"); \
TARGETARCH=$([ "$TARGETARCH" = "arm64" ] && echo "aarch64" || echo "$TARGETARCH"); \
cp docker-compose* "/out/docker-compose-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}$(ls docker-compose* | sed -e 's/^docker-compose//')"
FROM base AS make-cross
ARG BUILD_TAGS
ARG GIT_TAG
RUN --mount=target=. \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
BUILD_TAGS=${BUILD_TAGS} \
GIT_TAG=${GIT_TAG} \
make COMPOSE_BINARY=/out/docker-compose -f builder.Makefile cross
FROM scratch AS compose-plugin
COPY --from=make-compose-plugin /out/* .
FROM scratch AS cross
COPY --from=make-cross /out/* .
FROM base AS test
ENV CGO_ENABLED=0
ARG BUILD_TAGS
ARG GIT_TAG
RUN --mount=target=. \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
BUILD_TAGS=${BUILD_TAGS} \
GIT_TAG=${GIT_TAG} \
make -f builder.Makefile test
FROM base AS check-license-headers
RUN go install github.com/kunalkushwaha/ltag@latest
RUN --mount=target=. \
make -f builder.Makefile check-license-headers
FROM base AS make-go-mod-tidy
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod tidy
FROM scratch AS go-mod-tidy
COPY --from=make-go-mod-tidy /compose-cli/go.mod .
COPY --from=make-go-mod-tidy /compose-cli/go.sum .
FROM base AS check-go-mod
COPY . .
RUN make -f builder.Makefile check-go-mod
FROM scratch AS release
COPY --from=releaser /out/ /

View File

@ -1,6 +1,6 @@
# Docker maintainers file
#
# This file describes who runs the docker/compose-cli project and how.
# This file describes who runs the docker/compose project and how.
# This is a living document - if you see something out of date or missing, speak up!
#
# It is structured to be consumable by both humans and programs.
@ -22,13 +22,29 @@
# subsystem maintainers accountable. If ownership is unclear, they are the de facto owners.
people = [
"rumpl",
"gtardif",
"glours",
"jhrotko",
"milas",
"ndeloof",
"chris-crone",
"nicksieger",
"StefanScherer",
"ulyssessouza"
]
[Org."Regular maintainers"]
# The Regular maintainers are people who aren't Core maintainers but are around
# to help reviewing and fixing bugs, just on a less regular basis than previously.
# Most of them were previously Core maintainers of Compose.
people = [
"aiordache",
"chris-crone",
"gtardif",
"laurazard",
"maxcleme",
"rumpl",
"thaJeztah"
]
[people]
# A reference list of all people associated with the project.
@ -37,16 +53,51 @@
# ADD YOURSELF HERE IN ALPHABETICAL ORDER
[people.aiordache]
Name = "Anca Iordache"
Email = "anca.iordache@docker.com"
GitHub = "aiordache "
[people.chris-crone]
Name = "Christopher Crone"
Email = "christopher.crone@docker.com"
GitHub = "chris-crone"
[people.glours]
Name = "Guillaume Lours"
Email = "guillaume.lours@docker.com"
GitHub = "glours"
[people.gtardif]
Name = "Guillaume Tardif"
Email = "guillaume.tardif@docker.com"
GitHub = "gtardif"
[people.jhrotko]
Name = "Joana Hrotko"
Email = "joana.hrotko@docker.com"
Github = "jhrotko"
[people.laurazard]
Name = "Laura Brehm"
Email = "laura.brehm@docker.com"
GitHub = "laurazard"
[people.maxcleme]
Name = "Maxime Clement"
Email = "maxime.clement@docker.com"
GitHub = "maxcleme"
[people.milas]
Name = "Milas Bowman"
Email = "milas.bowman@docker.com"
GitHub = "milas"
[people.nicksieger]
Name = "Nick Sieger"
Email = "nick.sieger@docker.com"
GitHub = "nicksieger"
[people.ndeloof]
Name = "Nicolas Deloof"
Email = "nicolas.deloof@docker.com"
@ -57,7 +108,17 @@
Email = "djordje.lukic@docker.com"
GitHub = "rumpl"
[people.ulyssessouza]
Name = "Ulysses Souza"
Email = "<ulysses.souza@docker.com"
Github = "ulyssessouza"
[people.thaJeztah]
Name = "Sebastiaan van Stijn"
Email = "sebastiaan.vanstijn@docker.com"
GitHub = "thaJeztah "
[people.StefanScherer]
Name = "Stefan Scherer"
Email = "stefan.scherer@docker.com"
GitHub = "StefanScherer"
[people.ulyssessouza]
Name = "Ulysses Souza"
Email = "<ulysses.souza@docker.com"
Github = "ulyssessouza"

142
Makefile
View File

@ -12,94 +12,130 @@
# See the License for the specific language governing permissions and
# limitations under the License.
export DOCKER_BUILDKIT=1
PKG := github.com/docker/compose/v2
VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
MOBY_DOCKER=/usr/bin/docker
endif
ifeq ($(UNAME_S),Darwin)
MOBY_DOCKER=/Applications/Docker.app/Contents/Resources/bin/docker
GO_LDFLAGS ?= -w -X ${PKG}/internal.Version=${VERSION}
GO_BUILDTAGS ?= e2e
DRIVE_PREFIX?=
ifeq ($(OS),Windows_NT)
DETECTED_OS = Windows
DRIVE_PREFIX=C:
else
DETECTED_OS = $(shell uname -s)
endif
BINARY_FOLDER=$(shell pwd)/bin
GIT_TAG?=$(shell git describe --tags --match "v[0-9]*")
ifeq ($(DETECTED_OS),Windows)
BINARY_EXT=.exe
endif
BUILD_FLAGS?=
TEST_FLAGS?=
E2E_TEST?=
ifeq ($(E2E_TEST),)
else
TEST_FLAGS=-run $(E2E_TEST)
ifneq ($(E2E_TEST),)
TEST_FLAGS:=$(TEST_FLAGS) -run '$(E2E_TEST)'
endif
all: compose-plugin
EXCLUDE_E2E_TESTS?=
ifneq ($(EXCLUDE_E2E_TESTS),)
TEST_FLAGS:=$(TEST_FLAGS) -skip '$(EXCLUDE_E2E_TESTS)'
endif
.PHONY: compose-plugin
compose-plugin: ## Compile the compose cli-plugin
@docker build . --target compose-plugin \
--platform local \
--build-arg BUILD_TAGS=e2e,kube \
--build-arg GIT_TAG=$(GIT_TAG) \
--output ./bin
BUILDX_CMD ?= docker buildx
# DESTDIR overrides the output path for binaries and other artifacts
# this is used by docker/docker-ce-packaging for the apt/rpm builds,
# so it's important that the resulting binary ends up EXACTLY at the
# path $DESTDIR/docker-compose when specified.
#
# See https://github.com/docker/docker-ce-packaging/blob/e43fbd37e48fde49d907b9195f23b13537521b94/rpm/SPECS/docker-compose-plugin.spec#L47
#
# By default, all artifacts go to subdirectories under ./bin/ in the
# repo root, e.g. ./bin/build, ./bin/coverage, ./bin/release.
DESTDIR ?=
all: build
.PHONY: build ## Build the compose cli-plugin
build:
GO111MODULE=on go build $(BUILD_FLAGS) -trimpath -tags "$(GO_BUILDTAGS)" -ldflags "$(GO_LDFLAGS)" -o "$(or $(DESTDIR),./bin/build)/docker-compose$(BINARY_EXT)" ./cmd
.PHONY: binary
binary:
$(BUILDX_CMD) bake binary
.PHONY: binary-with-coverage
binary-with-coverage:
$(BUILDX_CMD) bake binary-with-coverage
.PHONY: install
install: binary
mkdir -p ~/.docker/cli-plugins
install $(or $(DESTDIR),./bin/build)/docker-compose ~/.docker/cli-plugins/docker-compose
.PHONY: e2e-compose
e2e-compose: ## Run end to end local tests in plugin mode. Set E2E_TEST=TestName to run a single test
docker compose version
go test $(TEST_FLAGS) -count=1 ./pkg/e2e
e2e-compose: example-provider ## Run end to end local tests in plugin mode. Set E2E_TEST=TestName to run a single test
go run gotest.tools/gotestsum@latest --format testname --junitfile "/tmp/report/report.xml" -- -v $(TEST_FLAGS) -count=1 ./pkg/e2e
.PHONY: e2e-compose-standalone
e2e-compose-standalone: ## Run End to end local tests in standalone mode. Set E2E_TEST=TestName to run a single test
docker-compose version
go test $(TEST_FLAGS) -v -count=1 -parallel=1 --tags=standalone ./pkg/e2e
go run gotest.tools/gotestsum@latest --format testname --junitfile "/tmp/report/report.xml" -- $(TEST_FLAGS) -v -count=1 -parallel=1 --tags=standalone ./pkg/e2e
.PHONY: build-and-e2e-compose
build-and-e2e-compose: build e2e-compose ## Compile the compose cli-plugin and run end to end local tests in plugin mode. Set E2E_TEST=TestName to run a single test
.PHONY: build-and-e2e-compose-standalone
build-and-e2e-compose-standalone: build e2e-compose-standalone ## Compile the compose cli-plugin and run End to end local tests in standalone mode. Set E2E_TEST=TestName to run a single test
.PHONY: example-provider
example-provider: ## build example provider for e2e tests
go build -o bin/build/example-provider docs/examples/provider.go
.PHONY: mocks
mocks:
mockgen --version >/dev/null 2>&1 || go install go.uber.org/mock/mockgen@v0.4.0
mockgen -destination pkg/mocks/mock_docker_cli.go -package mocks github.com/docker/cli/cli/command Cli
mockgen -destination pkg/mocks/mock_docker_api.go -package mocks github.com/docker/docker/client APIClient
mockgen -destination pkg/mocks/mock_docker_compose_api.go -package mocks -source=./pkg/api/api.go Service
.PHONY: e2e
e2e: e2e-compose e2e-compose-standalone ## Run end to end local tests in both modes. Set E2E_TEST=TestName to run a single test
.PHONY: build-and-e2e
build-and-e2e: build e2e-compose e2e-compose-standalone ## Compile the compose cli-plugin and run end to end local tests in both modes. Set E2E_TEST=TestName to run a single test
.PHONY: cross
cross: ## Compile the CLI for linux, darwin and windows
@docker build . --target cross \
--build-arg BUILD_TAGS \
--build-arg GIT_TAG=$(GIT_TAG) \
--output ./bin \
$(BUILDX_CMD) bake binary-cross
.PHONY: test
test: ## Run unit tests
@docker build --progress=plain . \
--build-arg BUILD_TAGS=kube \
--build-arg GIT_TAG=$(GIT_TAG) \
--target test
$(BUILDX_CMD) bake test
.PHONY: cache-clear
cache-clear: ## Clear the builder cache
@docker builder prune --force --filter type=exec.cachemount --filter=unused-for=24h
$(BUILDX_CMD) prune --force --filter type=exec.cachemount --filter=unused-for=24h
.PHONY: lint
lint: ## run linter(s)
@docker build . \
--build-arg BUILD_TAGS=kube,e2e \
--build-arg GIT_TAG=$(GIT_TAG) \
--target lint
$(BUILDX_CMD) bake lint
.PHONY: fmt
fmt:
gofumpt --version >/dev/null 2>&1 || go install mvdan.cc/gofumpt@latest
gofumpt -w .
.PHONY: docs
docs: ## generate documentation
$(eval $@_TMP_OUT := $(shell mktemp -d -t dockercli-output.XXXXXXXXXX))
docker build . \
--output type=local,dest=$($@_TMP_OUT) \
-f ./docs/docs.Dockerfile \
--target update
$(eval $@_TMP_OUT := $(shell mktemp -d -t compose-output.XXXXXXXXXX))
$(BUILDX_CMD) bake --set "*.output=type=local,dest=$($@_TMP_OUT)" docs-update
rm -rf ./docs/internal
cp -R "$($@_TMP_OUT)"/out/* ./docs/
rm -rf "$($@_TMP_OUT)"/*
cp -R "$(DRIVE_PREFIX)$($@_TMP_OUT)"/out/* ./docs/
rm -rf "$(DRIVE_PREFIX)$($@_TMP_OUT)"/*
.PHONY: validate-docs
validate-docs: ## validate the doc does not change
@docker build . \
-f ./docs/docs.Dockerfile \
--target validate
$(BUILDX_CMD) bake docs-validate
.PHONY: check-dependencies
check-dependencies: ## check dependency updates
@ -107,19 +143,19 @@ check-dependencies: ## check dependency updates
.PHONY: validate-headers
validate-headers: ## Check license header for all files
@docker build . --target check-license-headers
$(BUILDX_CMD) bake license-validate
.PHONY: go-mod-tidy
go-mod-tidy: ## Run go mod tidy in a container and output resulting go.mod and go.sum
@docker build . --target go-mod-tidy --output .
$(BUILDX_CMD) bake vendor-update
.PHONY: validate-go-mod
validate-go-mod: ## Validate go.mod and go.sum are up-to-date
@docker build . --target check-go-mod
$(BUILDX_CMD) bake vendor-validate
validate: validate-go-mod validate-headers validate-docs ## Validate sources
validate: validate-go-mod validate-headers validate-docs ## Validate sources
pre-commit: validate check-dependencies lint compose-plugin test e2e-compose
pre-commit: validate check-dependencies lint build test e2e-compose
help: ## Show help
@echo Please specify a build target. The choices are:

View File

@ -1,28 +1,40 @@
# Table of Contents
- [Docker Compose v2](#docker-compose-v2)
- [Where to get Docker Compose](#where-to-get-docker-compose)
+ [Windows and macOS](#windows-and-macos)
+ [Linux](#linux)
- [Quick Start](#quick-start)
- [Contributing](#contributing)
- [Legacy](#legacy)
# Docker Compose v2
[![Actions Status](https://github.com/docker/compose/workflows/Continuous%20integration/badge.svg)](https://github.com/docker/compose/actions)
[![GitHub release](https://img.shields.io/github/v/release/docker/compose.svg?style=flat-square)](https://github.com/docker/compose/releases/latest)
[![PkgGoDev](https://img.shields.io/badge/go.dev-docs-007d9c?style=flat-square&logo=go&logoColor=white)](https://pkg.go.dev/github.com/docker/compose/v2)
[![Build Status](https://img.shields.io/github/actions/workflow/status/docker/compose/ci.yml?label=ci&logo=github&style=flat-square)](https://github.com/docker/compose/actions?query=workflow%3Aci)
[![Go Report Card](https://goreportcard.com/badge/github.com/docker/compose/v2?style=flat-square)](https://goreportcard.com/report/github.com/docker/compose/v2)
[![Codecov](https://codecov.io/gh/docker/compose/branch/main/graph/badge.svg?token=HP3K4Y4ctu)](https://codecov.io/gh/docker/compose)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/docker/compose/badge)](https://api.securityscorecards.dev/projects/github.com/docker/compose)
![Docker Compose](logo.png?raw=true "Docker Compose Logo")
Docker Compose is a tool for running multi-container applications on Docker
defined using the [Compose file format](https://compose-spec.io).
A Compose file is used to define how the one or more containers that make up
A Compose file is used to define how one or more containers that make up
your application are configured.
Once you have a Compose file, you can create and start your application with a
single command: `docker compose up`.
# About update and backward compatibility
Docker Compose V2 is a major version bump release of Docker Compose. It has been completely rewritten from scratch in Golang (V1 was in Python). The installation instructions for Compose V2 differ from V1. V2 is not a standalone binary anymore, and installation scripts will have to be adjusted. Some commands are different.
For a smooth transition from legacy docker-compose 1.xx, please consider installing [compose-switch](https://github.com/docker/compose-switch) to translate `docker-compose ...` commands into Compose V2's `docker compose .... `. Also check V2's `--compatibility` flag.
> **Note**: About Docker Swarm
> Docker Swarm used to rely on the legacy compose file format but did not adopted the compose specification
> so is missing some of the recent enhancements in the compose syntax. After
> [acquisition by Mirantis](https://www.mirantis.com/software/swarm/) swarm isn't maintained by Docker Inc, and
> as such some Docker Compose features aren't accessible to swarm users.
# Where to get Docker Compose
### Windows and macOS
Docker Compose is included in
[Docker Desktop](https://www.docker.com/products/docker-desktop)
[Docker Desktop](https://www.docker.com/products/docker-desktop/)
for Windows and macOS.
### Linux
@ -30,23 +42,23 @@ for Windows and macOS.
You can download Docker Compose binaries from the
[release page](https://github.com/docker/compose/releases) on this repository.
Rename the relevant binary for your OS to `docker-compose` and copy it to `$HOME/.docker/cli-plugins`
Rename the relevant binary for your OS to `docker-compose` and copy it to `$HOME/.docker/cli-plugins`
Or copy it into one of these folders for installing it system-wide:
Or copy it into one of these folders to install it system-wide:
* `/usr/local/lib/docker/cli-plugins` OR `/usr/local/libexec/docker/cli-plugins`
* `/usr/lib/docker/cli-plugins` OR `/usr/libexec/docker/cli-plugins`
(might require to make the downloaded file executable with `chmod +x`)
(might require making the downloaded file executable with `chmod +x`)
Quick Start
-----------
Using Docker Compose is basically a three-step process:
Using Docker Compose is a three-step process:
1. Define your app's environment with a `Dockerfile` so it can be
reproduced anywhere.
2. Define the services that make up your app in `docker-compose.yml` so
2. Define the services that make up your app in `compose.yaml` so
they can be run together in an isolated environment.
3. Lastly, run `docker compose up` and Compose will start and run your entire
app.
@ -73,3 +85,8 @@ Want to help develop Docker Compose? Check out our
If you find an issue, please report it on the
[issue tracker](https://github.com/docker/compose/issues/new/choose).
Legacy
-------------
The Python version of Compose is available under the `v1` [branch](https://github.com/docker/compose/tree/v1).

View File

@ -1,73 +0,0 @@
# Copyright 2020 Docker Compose CLI authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
GOOS?=$(shell go env GOOS)
GOARCH?=$(shell go env GOARCH)
PKG_NAME := github.com/docker/compose/v2
EXTENSION:=
ifeq ($(GOOS),windows)
EXTENSION:=.exe
endif
STATIC_FLAGS=CGO_ENABLED=0
GIT_TAG?=$(shell git describe --tags --match "v[0-9]*")
LDFLAGS="-s -w -X $(PKG_NAME)/internal.Version=${GIT_TAG}"
GO_BUILD=$(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS)
COMPOSE_BINARY?=bin/docker-compose
COMPOSE_BINARY_WITH_EXTENSION=$(COMPOSE_BINARY)$(EXTENSION)
WORK_DIR:=$(shell mktemp -d)
TAGS:=
ifdef BUILD_TAGS
TAGS=-tags $(BUILD_TAGS)
LINT_TAGS=--build-tags $(BUILD_TAGS)
endif
.PHONY: compose-plugin
compose-plugin:
GOOS=${GOOS} GOARCH=${GOARCH} $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY_WITH_EXTENSION) ./cmd
.PHONY: cross
cross:
GOOS=linux GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-x86_64 ./cmd
GOOS=linux GOARCH=ppc64le $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-ppc64le ./cmd
GOOS=linux GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-aarch64 ./cmd
GOOS=linux GOARM=6 GOARCH=arm $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-armv6 ./cmd
GOOS=linux GOARM=7 GOARCH=arm $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-armv7 ./cmd
GOOS=linux GOARCH=s390x $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-s390x ./cmd
GOOS=darwin GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-darwin-x86_64 ./cmd
GOOS=darwin GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-darwin-aarch64 ./cmd
GOOS=windows GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-windows-x86_64.exe ./cmd
.PHONY: test
test:
go test $(TAGS) -cover $(shell go list $(TAGS) ./... | grep -vE 'e2e')
.PHONY: lint
lint:
golangci-lint run $(LINT_TAGS) --timeout 10m0s ./...
.PHONY: check-license-headers
check-license-headers:
./scripts/validate/fileheader
.PHONY: check-go-mod
check-go-mod:
./scripts/validate/check-go-mod

147
cmd/cmdtrace/cmd_span.go Normal file
View File

@ -0,0 +1,147 @@
/*
Copyright 2023 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmdtrace
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"time"
dockercli "github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
commands "github.com/docker/compose/v2/cmd/compose"
"github.com/docker/compose/v2/internal/tracing"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
)
// Setup should be called as part of the command's PersistentPreRunE
// as soon as possible after initializing the dockerCli.
//
// It initializes the tracer for the CLI using both auto-detection
// from the Docker context metadata as well as standard OTEL_ env
// vars, creates a root span for the command, and wraps the actual
// command invocation to ensure the span is properly finalized and
// exported before exit.
func Setup(cmd *cobra.Command, dockerCli command.Cli, args []string) error {
tracingShutdown, err := tracing.InitTracing(dockerCli)
if err != nil {
return fmt.Errorf("initializing tracing: %w", err)
}
ctx := cmd.Context()
ctx, cmdSpan := otel.Tracer("").Start(
ctx,
"cli/"+strings.Join(commandName(cmd), "-"),
)
cmdSpan.SetAttributes(
attribute.StringSlice("cli.flags", getFlags(cmd.Flags())),
attribute.Bool("cli.isatty", dockerCli.In().IsTerminal()),
)
cmd.SetContext(ctx)
wrapRunE(cmd, cmdSpan, tracingShutdown)
return nil
}
// wrapRunE injects a wrapper function around the command's actual RunE (or Run)
// method. This is necessary to capture the command result for reporting as well
// as flushing any spans before exit.
//
// Unfortunately, PersistentPostRun(E) can't be used for this purpose because it
// only runs if RunE does _not_ return an error, but this should run unconditionally.
func wrapRunE(c *cobra.Command, cmdSpan trace.Span, tracingShutdown tracing.ShutdownFunc) {
origRunE := c.RunE
if origRunE == nil {
origRun := c.Run
//nolint:unparam // wrapper function for RunE, always returns nil by design
origRunE = func(cmd *cobra.Command, args []string) error {
origRun(cmd, args)
return nil
}
c.Run = nil
}
c.RunE = func(cmd *cobra.Command, args []string) error {
cmdErr := origRunE(cmd, args)
if cmdSpan != nil {
if cmdErr != nil && !errors.Is(cmdErr, context.Canceled) {
// default exit code is 1 if a more descriptive error
// wasn't returned
exitCode := 1
var statusErr dockercli.StatusError
if errors.As(cmdErr, &statusErr) {
exitCode = statusErr.StatusCode
}
cmdSpan.SetStatus(codes.Error, "CLI command returned error")
cmdSpan.RecordError(cmdErr, trace.WithAttributes(
attribute.Int("exit_code", exitCode),
))
} else {
cmdSpan.SetStatus(codes.Ok, "")
}
cmdSpan.End()
}
if tracingShutdown != nil {
// use background for root context because the cmd's context might have
// been canceled already
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
// TODO(milas): add an env var to enable logging from the
// OTel components for debugging purposes
_ = tracingShutdown(ctx)
}
return cmdErr
}
}
// commandName returns the path components for a given command,
// in reverse alphabetical order for consistent usage metrics.
//
// The root Compose command and anything before (i.e. "docker")
// are not included.
//
// For example:
// - docker compose alpha watch -> [watch, alpha]
// - docker-compose up -> [up]
func commandName(cmd *cobra.Command) []string {
var name []string
for c := cmd; c != nil; c = c.Parent() {
if c.Name() == commands.PluginName {
break
}
name = append(name, c.Name())
}
sort.Sort(sort.Reverse(sort.StringSlice(name)))
return name
}
func getFlags(fs *flag.FlagSet) []string {
var result []string
fs.Visit(func(flag *flag.Flag) {
result = append(result, flag.Name)
})
return result
}

View File

@ -0,0 +1,112 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmdtrace
import (
"reflect"
"testing"
commands "github.com/docker/compose/v2/cmd/compose"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
)
func TestGetFlags(t *testing.T) {
// Initialize flagSet with flags
fs := flag.NewFlagSet("up", flag.ContinueOnError)
var (
detach string
timeout string
)
fs.StringVar(&detach, "detach", "d", "")
fs.StringVar(&timeout, "timeout", "t", "")
_ = fs.Set("detach", "detach")
_ = fs.Set("timeout", "timeout")
tests := []struct {
name string
input *flag.FlagSet
expected []string
}{
{
name: "NoFlags",
input: flag.NewFlagSet("NoFlags", flag.ContinueOnError),
expected: nil,
},
{
name: "Flags",
input: fs,
expected: []string{"detach", "timeout"},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
result := getFlags(test.input)
if !reflect.DeepEqual(result, test.expected) {
t.Errorf("Expected %v, but got %v", test.expected, result)
}
})
}
}
func TestCommandName(t *testing.T) {
tests := []struct {
name string
setupCmd func() *cobra.Command
want []string
}{
{
name: "docker compose alpha watch -> [watch, alpha]",
setupCmd: func() *cobra.Command {
dockerCmd := &cobra.Command{Use: "docker"}
composeCmd := &cobra.Command{Use: commands.PluginName}
alphaCmd := &cobra.Command{Use: "alpha"}
watchCmd := &cobra.Command{Use: "watch"}
dockerCmd.AddCommand(composeCmd)
composeCmd.AddCommand(alphaCmd)
alphaCmd.AddCommand(watchCmd)
return watchCmd
},
want: []string{"watch", "alpha"},
},
{
name: "docker-compose up -> [up]",
setupCmd: func() *cobra.Command {
dockerComposeCmd := &cobra.Command{Use: commands.PluginName}
upCmd := &cobra.Command{Use: "up"}
dockerComposeCmd.AddCommand(upCmd)
return upCmd
},
want: []string{"up"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cmd := tt.setupCmd()
got := commandName(cmd)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("commandName() = %v, want %v", got, tt.want)
}
})
}
}

View File

@ -19,10 +19,18 @@ package compatibility
import (
"fmt"
"os"
"strings"
"github.com/docker/compose/v2/cmd/compose"
)
func getCompletionCommands() []string {
return []string{
"__complete",
"__completeNoDesc",
}
}
func getBoolFlags() []string {
return []string{
"--debug", "-D",
@ -48,39 +56,50 @@ func Convert(args []string) []string {
var rootFlags []string
command := []string{compose.PluginName}
l := len(args)
ARGS:
for i := 0; i < l; i++ {
arg := args[i]
if arg[0] != '-' {
// not a top-level flag anymore, keep the rest of the command unmodified
if arg == compose.PluginName {
i++
}
if contains(getCompletionCommands(), arg) {
command = append([]string{arg}, command...)
continue
}
if arg != "" && arg[0] != '-' {
command = append(command, args[i:]...)
break
}
if arg == "--verbose" {
switch arg {
case "--verbose":
arg = "--debug"
}
if arg == "-h" {
case "-h":
// docker cli has deprecated -h to avoid ambiguity with -H, while docker-compose still support it
arg = "--help"
}
if arg == "--version" || arg == "-v" {
case "--version", "-v":
// redirect --version pseudo-command to actual command
arg = "version"
}
if contains(getBoolFlags(), arg) {
rootFlags = append(rootFlags, arg)
continue
}
if contains(getStringFlags(), arg) {
i++
if i >= l {
fmt.Fprintf(os.Stderr, "flag needs an argument: '%s'\n", arg)
os.Exit(1)
for _, flag := range getStringFlags() {
if arg == flag {
i++
if i >= l {
fmt.Fprintf(os.Stderr, "flag needs an argument: '%s'\n", arg)
os.Exit(1)
}
rootFlags = append(rootFlags, arg, args[i])
continue ARGS
}
if strings.HasPrefix(arg, flag) {
_, val, found := strings.Cut(arg, "=")
if found {
rootFlags = append(rootFlags, flag, val)
continue ARGS
}
}
rootFlags = append(rootFlags, arg, args[i])
continue
}
command = append(command, arg)
}

View File

@ -17,6 +17,9 @@
package compatibility
import (
"errors"
"os"
"os/exec"
"testing"
"gotest.tools/v3/assert"
@ -24,9 +27,10 @@ import (
func Test_convert(t *testing.T) {
tests := []struct {
name string
args []string
want []string
name string
args []string
want []string
wantErr bool
}{
{
name: "compose only",
@ -38,16 +42,31 @@ func Test_convert(t *testing.T) {
args: []string{"--context", "foo", "-f", "compose.yaml", "up"},
want: []string{"--context", "foo", "compose", "-f", "compose.yaml", "up"},
},
{
name: "with context arg",
args: []string{"--context=foo", "-f", "compose.yaml", "up"},
want: []string{"--context", "foo", "compose", "-f", "compose.yaml", "up"},
},
{
name: "with host",
args: []string{"--host", "tcp://1.2.3.4", "up"},
want: []string{"--host", "tcp://1.2.3.4", "compose", "up"},
},
{
name: "compose --verbose",
args: []string{"--verbose"},
want: []string{"--debug", "compose"},
},
{
name: "compose --version",
args: []string{"--version"},
want: []string{"compose", "version"},
},
{
name: "compose -v",
args: []string{"-v"},
want: []string{"compose", "version"},
},
{
name: "help",
args: []string{"-h"},
@ -68,11 +87,46 @@ func Test_convert(t *testing.T) {
args: []string{"--log-level", "INFO", "up"},
want: []string{"--log-level", "INFO", "compose", "up"},
},
{
name: "empty string argument",
args: []string{"--project-directory", "", "ps"},
want: []string{"compose", "--project-directory", "", "ps"},
},
{
name: "compose as project name",
args: []string{"--project-name", "compose", "down", "--remove-orphans"},
want: []string{"compose", "--project-name", "compose", "down", "--remove-orphans"},
},
{
name: "completion command",
args: []string{"__complete", "up"},
want: []string{"__complete", "compose", "up"},
},
{
name: "string flag without argument",
args: []string{"--log-level"},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := Convert(tt.args)
assert.DeepEqual(t, tt.want, got)
if tt.wantErr {
if os.Getenv("BE_CRASHER") == "1" {
Convert(tt.args)
return
}
cmd := exec.Command(os.Args[0], "-test.run=^"+t.Name()+"$")
cmd.Env = append(os.Environ(), "BE_CRASHER=1")
err := cmd.Run()
var e *exec.ExitError
if errors.As(err, &e) && !e.Success() {
return
}
t.Fatalf("process ran with err %v, want exit status 1", err)
} else {
got := Convert(tt.args)
assert.DeepEqual(t, tt.want, got)
}
})
}
}

39
cmd/compose/alpha.go Normal file
View File

@ -0,0 +1,39 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/api"
"github.com/spf13/cobra"
)
// alphaCommand groups all experimental subcommands
func alphaCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
cmd := &cobra.Command{
Short: "Experimental commands",
Use: "alpha [COMMAND]",
Hidden: true,
Annotations: map[string]string{
"experimentalCLI": "true",
},
}
cmd.AddCommand(
vizCommand(p, dockerCli, backend),
publishCommand(p, dockerCli, backend),
generateCommand(p, backend),
)
return cmd
}

80
cmd/compose/attach.go Normal file
View File

@ -0,0 +1,80 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/api"
"github.com/spf13/cobra"
)
type attachOpts struct {
*composeOptions
service string
index int
detachKeys string
noStdin bool
proxy bool
}
func attachCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := attachOpts{
composeOptions: &composeOptions{
ProjectOptions: p,
},
}
runCmd := &cobra.Command{
Use: "attach [OPTIONS] SERVICE",
Short: "Attach local standard input, output, and error streams to a service's running container",
Args: cobra.MinimumNArgs(1),
PreRunE: Adapt(func(ctx context.Context, args []string) error {
opts.service = args[0]
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
return runAttach(ctx, dockerCli, backend, opts)
}),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
runCmd.Flags().IntVar(&opts.index, "index", 0, "index of the container if service has multiple replicas.")
runCmd.Flags().StringVarP(&opts.detachKeys, "detach-keys", "", "", "Override the key sequence for detaching from a container.")
runCmd.Flags().BoolVar(&opts.noStdin, "no-stdin", false, "Do not attach STDIN")
runCmd.Flags().BoolVar(&opts.proxy, "sig-proxy", true, "Proxy all received signals to the process")
return runCmd
}
func runAttach(ctx context.Context, dockerCli command.Cli, backend api.Service, opts attachOpts) error {
projectName, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}
attachOpts := api.AttachOptions{
Service: opts.service,
Index: opts.index,
DetachKeys: opts.detachKeys,
NoStdin: opts.noStdin,
Proxy: opts.proxy,
}
return backend.Attach(ctx, projectName, attachOpts)
}

149
cmd/compose/bridge.go Normal file
View File

@ -0,0 +1,149 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"fmt"
"io"
"github.com/distribution/reference"
"github.com/docker/cli/cli/command"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/go-units"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/docker/compose/v2/pkg/bridge"
)
func bridgeCommand(p *ProjectOptions, dockerCli command.Cli) *cobra.Command {
cmd := &cobra.Command{
Use: "bridge CMD [OPTIONS]",
Short: "Convert compose files into another model",
TraverseChildren: true,
}
cmd.AddCommand(
convertCommand(p, dockerCli),
transformersCommand(dockerCli),
)
return cmd
}
func convertCommand(p *ProjectOptions, dockerCli command.Cli) *cobra.Command {
convertOpts := bridge.ConvertOptions{}
cmd := &cobra.Command{
Use: "convert",
Short: "Convert compose files to Kubernetes manifests, Helm charts, or another model",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runConvert(ctx, dockerCli, p, convertOpts)
}),
}
flags := cmd.Flags()
flags.StringVarP(&convertOpts.Output, "output", "o", "out", "The output directory for the Kubernetes resources")
flags.StringArrayVarP(&convertOpts.Transformations, "transformation", "t", nil, "Transformation to apply to compose model (default: docker/compose-bridge-kubernetes)")
flags.StringVar(&convertOpts.Templates, "templates", "", "Directory containing transformation templates")
return cmd
}
func runConvert(ctx context.Context, dockerCli command.Cli, p *ProjectOptions, opts bridge.ConvertOptions) error {
project, _, err := p.ToProject(ctx, dockerCli, nil)
if err != nil {
return err
}
return bridge.Convert(ctx, dockerCli, project, opts)
}
func transformersCommand(dockerCli command.Cli) *cobra.Command {
cmd := &cobra.Command{
Use: "transformations CMD [OPTIONS]",
Short: "Manage transformation images",
}
cmd.AddCommand(
listTransformersCommand(dockerCli),
createTransformerCommand(dockerCli),
)
return cmd
}
func listTransformersCommand(dockerCli command.Cli) *cobra.Command {
options := lsOptions{}
cmd := &cobra.Command{
Use: "list",
Aliases: []string{"ls"},
Short: "List available transformations",
RunE: Adapt(func(ctx context.Context, args []string) error {
transformers, err := bridge.ListTransformers(ctx, dockerCli)
if err != nil {
return err
}
return displayTransformer(dockerCli, transformers, options)
}),
}
cmd.Flags().StringVar(&options.Format, "format", "table", "Format the output. Values: [table | json]")
cmd.Flags().BoolVarP(&options.Quiet, "quiet", "q", false, "Only display transformer names")
return cmd
}
func displayTransformer(dockerCli command.Cli, transformers []image.Summary, options lsOptions) error {
if options.Quiet {
for _, t := range transformers {
if len(t.RepoTags) > 0 {
_, _ = fmt.Fprintln(dockerCli.Out(), t.RepoTags[0])
} else {
_, _ = fmt.Fprintln(dockerCli.Out(), t.ID)
}
}
return nil
}
return formatter.Print(transformers, options.Format, dockerCli.Out(),
func(w io.Writer) {
for _, img := range transformers {
id := stringid.TruncateID(img.ID)
size := units.HumanSizeWithPrecision(float64(img.Size), 3)
repo, tag := "<none>", "<none>"
if len(img.RepoTags) > 0 {
ref, err := reference.ParseDockerRef(img.RepoTags[0])
if err == nil {
// ParseDockerRef will reject a local image ID
repo = reference.FamiliarName(ref)
if tagged, ok := ref.(reference.Tagged); ok {
tag = tagged.Tag()
}
}
}
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", id, repo, tag, size)
}
},
"IMAGE ID", "REPO", "TAGS", "SIZE")
}
func createTransformerCommand(dockerCli command.Cli) *cobra.Command {
var opts bridge.CreateTransformerOptions
cmd := &cobra.Command{
Use: "create [OPTION] PATH",
Short: "Create a new transformation",
RunE: Adapt(func(ctx context.Context, args []string) error {
opts.Dest = args[0]
return bridge.CreateTransformer(ctx, dockerCli, opts)
}),
}
cmd.Flags().StringVarP(&opts.From, "from", "f", "", "Existing transformation to copy (default: docker/compose-bridge-kubernetes)")
return cmd
}

View File

@ -22,117 +22,148 @@ import (
"os"
"strings"
"github.com/compose-spec/compose-go/cli"
"github.com/compose-spec/compose-go/loader"
"github.com/compose-spec/compose-go/types"
buildx "github.com/docker/buildx/util/progress"
"github.com/docker/compose/v2/pkg/utils"
"github.com/compose-spec/compose-go/v2/cli"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
cliopts "github.com/docker/cli/opts"
ui "github.com/docker/compose/v2/pkg/progress"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
)
type buildOptions struct {
*projectOptions
composeOptions
quiet bool
pull bool
progress string
args []string
noCache bool
memory string
ssh string
*ProjectOptions
quiet bool
pull bool
push bool
args []string
noCache bool
memory cliopts.MemBytes
ssh string
builder string
deps bool
print bool
check bool
sbom string
provenance string
}
func (opts buildOptions) toAPIBuildOptions(services []string) (api.BuildOptions, error) {
var SSHKeys []types.SSHKey
var err error
if opts.ssh != "" {
SSHKeys, err = loader.ParseShortSSHSyntax(opts.ssh)
if err != nil {
return api.BuildOptions{}, err
id, path, found := strings.Cut(opts.ssh, "=")
if !found && id != "default" {
return api.BuildOptions{}, fmt.Errorf("invalid ssh key %q", opts.ssh)
}
SSHKeys = append(SSHKeys, types.SSHKey{
ID: id,
Path: path,
})
}
builderName := opts.builder
if builderName == "" {
builderName = os.Getenv("BUILDX_BUILDER")
}
uiMode := ui.Mode
if uiMode == ui.ModeJSON {
uiMode = "rawjson"
}
return api.BuildOptions{
Pull: opts.pull,
Progress: opts.progress,
Args: types.NewMappingWithEquals(opts.args),
NoCache: opts.noCache,
Quiet: opts.quiet,
Services: services,
SSHs: SSHKeys,
Pull: opts.pull,
Push: opts.push,
Progress: uiMode,
Args: types.NewMappingWithEquals(opts.args),
NoCache: opts.noCache,
Quiet: opts.quiet,
Services: services,
Deps: opts.deps,
Memory: int64(opts.memory),
Print: opts.print,
Check: opts.check,
SSHs: SSHKeys,
Builder: builderName,
SBOM: opts.sbom,
Provenance: opts.provenance,
}, nil
}
var printerModes = []string{
buildx.PrinterModeAuto,
buildx.PrinterModeTty,
buildx.PrinterModePlain,
buildx.PrinterModeQuiet,
}
func buildCommand(p *projectOptions, backend api.Service) *cobra.Command {
func buildCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := buildOptions{
projectOptions: p,
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "build [SERVICE...]",
Use: "build [OPTIONS] [SERVICE...]",
Short: "Build or rebuild services",
PreRunE: Adapt(func(ctx context.Context, args []string) error {
if opts.memory != "" {
fmt.Println("WARNING --memory is ignored as not supported in buildkit.")
}
if opts.quiet {
opts.progress = buildx.PrinterModeQuiet
ui.Mode = ui.ModeQuiet
devnull, err := os.Open(os.DevNull)
if err != nil {
return err
}
os.Stdout = devnull
}
if !utils.StringContains(printerModes, opts.progress) {
return fmt.Errorf("unsupported --progress value %q", opts.progress)
}
return nil
}),
RunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("ssh") && opts.ssh == "" {
opts.ssh = "default"
}
return runBuild(ctx, backend, opts, args)
if cmd.Flags().Changed("progress") && opts.ssh == "" {
fmt.Fprint(os.Stderr, "--progress is a global compose flag, better use `docker compose --progress xx build ...\n")
}
return runBuild(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
cmd.Flags().BoolVarP(&opts.quiet, "quiet", "q", false, "Don't print anything to STDOUT")
cmd.Flags().BoolVar(&opts.pull, "pull", false, "Always attempt to pull a newer version of the image.")
cmd.Flags().StringVar(&opts.progress, "progress", buildx.PrinterModeAuto, fmt.Sprintf(`Set type of progress output (%s)`, strings.Join(printerModes, ", ")))
cmd.Flags().StringArrayVar(&opts.args, "build-arg", []string{}, "Set build-time variables for services.")
cmd.Flags().StringVar(&opts.ssh, "ssh", "", "Set SSH authentications used when building service images. (use 'default' for using your default SSH Agent)")
cmd.Flags().Bool("parallel", true, "Build images in parallel. DEPRECATED")
cmd.Flags().MarkHidden("parallel") //nolint:errcheck
cmd.Flags().Bool("compress", true, "Compress the build context using gzip. DEPRECATED")
cmd.Flags().MarkHidden("compress") //nolint:errcheck
cmd.Flags().Bool("force-rm", true, "Always remove intermediate containers. DEPRECATED")
cmd.Flags().MarkHidden("force-rm") //nolint:errcheck
cmd.Flags().BoolVar(&opts.noCache, "no-cache", false, "Do not use cache when building the image")
cmd.Flags().Bool("no-rm", false, "Do not remove intermediate containers after a successful build. DEPRECATED")
cmd.Flags().MarkHidden("no-rm") //nolint:errcheck
cmd.Flags().StringVarP(&opts.memory, "memory", "m", "", "Set memory limit for the build container. Not supported on buildkit yet.")
cmd.Flags().MarkHidden("memory") //nolint:errcheck
flags := cmd.Flags()
flags.BoolVar(&opts.push, "push", false, "Push service images")
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress the build output")
flags.BoolVar(&opts.pull, "pull", false, "Always attempt to pull a newer version of the image")
flags.StringArrayVar(&opts.args, "build-arg", []string{}, "Set build-time variables for services")
flags.StringVar(&opts.ssh, "ssh", "", "Set SSH authentications used when building service images. (use 'default' for using your default SSH Agent)")
flags.StringVar(&opts.builder, "builder", "", "Set builder to use")
flags.BoolVar(&opts.deps, "with-dependencies", false, "Also build dependencies (transitively)")
flags.StringVar(&opts.provenance, "provenance", "", `Add a provenance attestation`)
flags.StringVar(&opts.sbom, "sbom", "", `Add a SBOM attestation`)
flags.Bool("parallel", true, "Build images in parallel. DEPRECATED")
flags.MarkHidden("parallel") //nolint:errcheck
flags.Bool("compress", true, "Compress the build context using gzip. DEPRECATED")
flags.MarkHidden("compress") //nolint:errcheck
flags.Bool("force-rm", true, "Always remove intermediate containers. DEPRECATED")
flags.MarkHidden("force-rm") //nolint:errcheck
flags.BoolVar(&opts.noCache, "no-cache", false, "Do not use cache when building the image")
flags.Bool("no-rm", false, "Do not remove intermediate containers after a successful build. DEPRECATED")
flags.MarkHidden("no-rm") //nolint:errcheck
flags.VarP(&opts.memory, "memory", "m", "Set memory limit for the build container. Not supported by BuildKit.")
flags.StringVar(&p.Progress, "progress", "", fmt.Sprintf(`Set type of ui output (%s)`, strings.Join(printerModes, ", ")))
flags.MarkHidden("progress") //nolint:errcheck
flags.BoolVar(&opts.print, "print", false, "Print equivalent bake file")
flags.BoolVar(&opts.check, "check", false, "Check build configuration")
return cmd
}
func runBuild(ctx context.Context, backend api.Service, opts buildOptions, services []string) error {
project, err := opts.toProject(services, cli.WithResolvedPaths(true))
func runBuild(ctx context.Context, dockerCli command.Cli, backend api.Service, opts buildOptions, services []string) error {
opts.All = true // do not drop resources as build may involve some dependencies by additional_contexts
project, _, err := opts.ToProject(ctx, dockerCli, nil, cli.WithResolvedPaths(true), cli.WithoutEnvironmentResolution)
if err != nil {
return err
}
if err := applyPlatforms(project, false); err != nil {
return err
}
apiBuildOptions, err := opts.toAPIBuildOptions(services)
apiBuildOptions.Attestations = true
if err != nil {
return err
}
return backend.Build(ctx, project, apiBuildOptions)
}

93
cmd/compose/commit.go Normal file
View File

@ -0,0 +1,93 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/opts"
"github.com/docker/compose/v2/pkg/api"
"github.com/spf13/cobra"
)
type commitOptions struct {
*ProjectOptions
service string
reference string
pause bool
comment string
author string
changes opts.ListOpts
index int
}
func commitCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
options := commitOptions{
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "commit [OPTIONS] SERVICE [REPOSITORY[:TAG]]",
Short: "Create a new image from a service container's changes",
Args: cobra.RangeArgs(1, 2),
PreRunE: Adapt(func(ctx context.Context, args []string) error {
options.service = args[0]
if len(args) > 1 {
options.reference = args[1]
}
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
return runCommit(ctx, dockerCli, backend, options)
}),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.IntVar(&options.index, "index", 0, "index of the container if service has multiple replicas.")
flags.BoolVarP(&options.pause, "pause", "p", true, "Pause container during commit")
flags.StringVarP(&options.comment, "message", "m", "", "Commit message")
flags.StringVarP(&options.author, "author", "a", "", `Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")`)
options.changes = opts.NewListOpts(nil)
flags.VarP(&options.changes, "change", "c", "Apply Dockerfile instruction to the created image")
return cmd
}
func runCommit(ctx context.Context, dockerCli command.Cli, backend api.Service, options commitOptions) error {
projectName, err := options.toProjectName(ctx, dockerCli)
if err != nil {
return err
}
commitOptions := api.CommitOptions{
Service: options.service,
Reference: options.reference,
Pause: options.pause,
Comment: options.comment,
Author: options.author,
Changes: options.changes,
Index: options.index,
}
return backend.Commit(ctx, projectName, commitOptions)
}

View File

@ -17,8 +17,11 @@
package compose
import (
"sort"
"strings"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/api"
"github.com/spf13/cobra"
)
@ -27,22 +30,73 @@ type validArgsFn func(cmd *cobra.Command, args []string, toComplete string) ([]s
func noCompletion() validArgsFn {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return nil, cobra.ShellCompDirectiveNoFileComp
return []string{}, cobra.ShellCompDirectiveNoSpace
}
}
func serviceCompletion(p *projectOptions) validArgsFn {
func completeServiceNames(dockerCli command.Cli, p *ProjectOptions) validArgsFn {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
project, err := p.toProject(nil)
p.Offline = true
project, _, err := p.ToProject(cmd.Context(), dockerCli, nil)
if err != nil {
return nil, cobra.ShellCompDirectiveNoFileComp
}
var serviceNames []string
for _, s := range project.ServiceNames() {
var values []string
serviceNames := append(project.ServiceNames(), project.DisabledServiceNames()...)
for _, s := range serviceNames {
if toComplete == "" || strings.HasPrefix(s, toComplete) {
serviceNames = append(serviceNames, s)
values = append(values, s)
}
}
return serviceNames, cobra.ShellCompDirectiveNoFileComp
return values, cobra.ShellCompDirectiveNoFileComp
}
}
func completeProjectNames(backend api.Service) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, err := backend.List(cmd.Context(), api.ListOptions{
All: true,
})
if err != nil {
return nil, cobra.ShellCompDirectiveError
}
var values []string
for _, stack := range list {
if strings.HasPrefix(stack.Name, toComplete) {
values = append(values, stack.Name)
}
}
return values, cobra.ShellCompDirectiveNoFileComp
}
}
func completeProfileNames(dockerCli command.Cli, p *ProjectOptions) validArgsFn {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
p.Offline = true
project, _, err := p.ToProject(cmd.Context(), dockerCli, nil)
if err != nil {
return nil, cobra.ShellCompDirectiveNoFileComp
}
allProfileNames := project.AllServices().GetProfiles()
sort.Strings(allProfileNames)
var values []string
for _, profileName := range allProfileNames {
if strings.HasPrefix(profileName, toComplete) {
values = append(values, profileName)
}
}
return values, cobra.ShellCompDirectiveNoFileComp
}
}
func completeScaleArgs(cli command.Cli, p *ProjectOptions) cobra.CompletionFunc {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
completions, directive := completeServiceNames(cli, p)(cmd, args, toComplete)
for i, completion := range completions {
completions[i] = completion + "="
}
return completions, directive
}
}

View File

@ -18,32 +18,87 @@ package compose
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"os"
"os/signal"
"path/filepath"
"strconv"
"strings"
"syscall"
"github.com/compose-spec/compose-go/cli"
"github.com/compose-spec/compose-go/types"
composegoutils "github.com/compose-spec/compose-go/utils"
"github.com/compose-spec/compose-go/v2/cli"
"github.com/compose-spec/compose-go/v2/dotenv"
"github.com/compose-spec/compose-go/v2/loader"
"github.com/compose-spec/compose-go/v2/types"
composegoutils "github.com/compose-spec/compose-go/v2/utils"
"github.com/docker/buildx/util/logutil"
dockercli "github.com/docker/cli/cli"
"github.com/docker/cli/cli-plugins/manager"
"github.com/docker/cli/cli-plugins/metadata"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/pkg/kvfile"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/docker/compose/v2/internal/desktop"
"github.com/docker/compose/v2/internal/experimental"
"github.com/docker/compose/v2/internal/tracing"
"github.com/docker/compose/v2/pkg/api"
ui "github.com/docker/compose/v2/pkg/progress"
"github.com/docker/compose/v2/pkg/remote"
"github.com/docker/compose/v2/pkg/utils"
"github.com/morikuni/aec"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/compose"
"github.com/docker/compose/v2/pkg/progress"
"github.com/docker/compose/v2/pkg/utils"
)
const (
// ComposeParallelLimit set the limit running concurrent operation on docker engine
ComposeParallelLimit = "COMPOSE_PARALLEL_LIMIT"
// ComposeProjectName define the project name to be used, instead of guessing from parent directory
ComposeProjectName = "COMPOSE_PROJECT_NAME"
// ComposeCompatibility try to mimic compose v1 as much as possible
ComposeCompatibility = "COMPOSE_COMPATIBILITY"
// ComposeRemoveOrphans remove "orphaned" containers, i.e. containers tagged for current project but not declared as service
ComposeRemoveOrphans = "COMPOSE_REMOVE_ORPHANS"
// ComposeIgnoreOrphans ignore "orphaned" containers
ComposeIgnoreOrphans = "COMPOSE_IGNORE_ORPHANS"
// ComposeEnvFiles defines the env files to use if --env-file isn't used
ComposeEnvFiles = "COMPOSE_ENV_FILES"
// ComposeMenu defines if the navigation menu should be rendered. Can be also set via --menu
ComposeMenu = "COMPOSE_MENU"
// ComposeProgress defines type of progress output, if --progress isn't used
ComposeProgress = "COMPOSE_PROGRESS"
)
// rawEnv load a dot env file using docker/cli key=value parser, without attempt to interpolate or evaluate values
func rawEnv(r io.Reader, filename string, vars map[string]string, lookup func(key string) (string, bool)) error {
lines, err := kvfile.ParseFromReader(r, lookup)
if err != nil {
return fmt.Errorf("failed to parse env_file %s: %w", filename, err)
}
for _, line := range lines {
key, value, _ := strings.Cut(line, "=")
vars[key] = value
}
return nil
}
func init() {
// compose evaluates env file values for interpolation
// `raw` format allows to load env_file with the same parser used by docker run --env-file
dotenv.RegisterFormat("raw", rawEnv)
}
type Backend interface {
api.Service
SetDesktopClient(cli *desktop.Client)
SetExperiments(experiments *experimental.State)
}
// Command defines a compose CLI command as a func with args
type Command func(context.Context, []string) error
@ -53,31 +108,25 @@ type CobraCommand func(context.Context, *cobra.Command, []string) error
// AdaptCmd adapt a CobraCommand func to cobra library
func AdaptCmd(fn CobraCommand) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
contextString := fmt.Sprintf("%s", ctx)
if !strings.HasSuffix(contextString, ".WithCancel") { // need to handle cancel
cancellableCtx, cancel := context.WithCancel(cmd.Context())
ctx = cancellableCtx
s := make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGTERM, syscall.SIGINT)
go func() {
<-s
cancel()
}()
}
ctx, cancel := context.WithCancel(cmd.Context())
s := make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGTERM, syscall.SIGINT)
go func() {
<-s
cancel()
signal.Stop(s)
close(s)
}()
err := fn(ctx, cmd, args)
var composeErr compose.Error
if api.IsErrCanceled(err) || errors.Is(ctx.Err(), context.Canceled) {
err = dockercli.StatusError{
StatusCode: 130,
Status: compose.CanceledStatus,
}
}
if errors.As(err, &composeErr) {
err = dockercli.StatusError{
StatusCode: composeErr.GetMetricsFailureCategory().ExitCode,
Status: err.Error(),
}
if ui.Mode == ui.ModeJSON {
err = makeJSONError(err)
}
return err
}
@ -90,14 +139,17 @@ func Adapt(fn Command) func(cmd *cobra.Command, args []string) error {
})
}
type projectOptions struct {
type ProjectOptions struct {
ProjectName string
Profiles []string
ConfigPaths []string
WorkDir string
ProjectDir string
EnvFile string
EnvFiles []string
Compatibility bool
Progress string
Offline bool
All bool
}
// ProjectFunc does stuff within a types.Project
@ -107,16 +159,28 @@ type ProjectFunc func(ctx context.Context, project *types.Project) error
type ProjectServicesFunc func(ctx context.Context, project *types.Project, services []string) error
// WithProject creates a cobra run command from a ProjectFunc based on configured project options and selected services
func (o *projectOptions) WithProject(fn ProjectFunc) func(cmd *cobra.Command, args []string) error {
return o.WithServices(func(ctx context.Context, project *types.Project, services []string) error {
func (o *ProjectOptions) WithProject(fn ProjectFunc, dockerCli command.Cli) func(cmd *cobra.Command, args []string) error {
return o.WithServices(dockerCli, func(ctx context.Context, project *types.Project, services []string) error {
return fn(ctx, project)
})
}
// WithServices creates a cobra run command from a ProjectFunc based on configured project options and selected services
func (o *projectOptions) WithServices(fn ProjectServicesFunc) func(cmd *cobra.Command, args []string) error {
func (o *ProjectOptions) WithServices(dockerCli command.Cli, fn ProjectServicesFunc) func(cmd *cobra.Command, args []string) error {
return Adapt(func(ctx context.Context, args []string) error {
project, err := o.toProject(args, cli.WithResolvedPaths(true))
options := []cli.ProjectOptionsFn{
cli.WithResolvedPaths(true),
cli.WithoutEnvironmentResolution,
}
project, metrics, err := o.ToProject(ctx, dockerCli, args, options...)
if err != nil {
return err
}
ctx = context.WithValue(ctx, tracing.MetricsKey{}, metrics)
project, err = project.WithServicesEnvironmentResolved(true)
if err != nil {
return err
}
@ -125,100 +189,225 @@ func (o *projectOptions) WithServices(fn ProjectServicesFunc) func(cmd *cobra.Co
})
}
func (o *projectOptions) addProjectFlags(f *pflag.FlagSet) {
type jsonErrorData struct {
Error bool `json:"error,omitempty"`
Message string `json:"message,omitempty"`
}
func errorAsJSON(message string) string {
errorMessage := &jsonErrorData{
Error: true,
Message: message,
}
marshal, err := json.Marshal(errorMessage)
if err == nil {
return string(marshal)
} else {
return message
}
}
func makeJSONError(err error) error {
if err == nil {
return nil
}
var statusErr dockercli.StatusError
if errors.As(err, &statusErr) {
return dockercli.StatusError{
StatusCode: statusErr.StatusCode,
Status: errorAsJSON(statusErr.Status),
}
}
return fmt.Errorf("%s", errorAsJSON(err.Error()))
}
func (o *ProjectOptions) addProjectFlags(f *pflag.FlagSet) {
f.StringArrayVar(&o.Profiles, "profile", []string{}, "Specify a profile to enable")
f.StringVarP(&o.ProjectName, "project-name", "p", "", "Project name")
f.StringArrayVarP(&o.ConfigPaths, "file", "f", []string{}, "Compose configuration files")
f.StringVar(&o.EnvFile, "env-file", "", "Specify an alternate environment file.")
f.StringArrayVar(&o.EnvFiles, "env-file", defaultStringArrayVar(ComposeEnvFiles), "Specify an alternate environment file")
f.StringVar(&o.ProjectDir, "project-directory", "", "Specify an alternate working directory\n(default: the path of the, first specified, Compose file)")
f.StringVar(&o.WorkDir, "workdir", "", "DEPRECATED! USE --project-directory INSTEAD.\nSpecify an alternate working directory\n(default: the path of the, first specified, Compose file)")
f.BoolVar(&o.Compatibility, "compatibility", false, "Run compose in backward compatibility mode")
f.StringVar(&o.Progress, "progress", os.Getenv(ComposeProgress), fmt.Sprintf(`Set type of progress output (%s)`, strings.Join(printerModes, ", ")))
f.BoolVar(&o.All, "all-resources", false, "Include all resources, even those not used by services")
_ = f.MarkHidden("workdir")
}
func (o *projectOptions) toProjectName() (string, error) {
// get default value for a command line flag that is set by a coma-separated value in environment variable
func defaultStringArrayVar(env string) []string {
return strings.FieldsFunc(os.Getenv(env), func(c rune) bool {
return c == ','
})
}
func (o *ProjectOptions) projectOrName(ctx context.Context, dockerCli command.Cli, services ...string) (*types.Project, string, error) {
name := o.ProjectName
var project *types.Project
if len(o.ConfigPaths) > 0 || o.ProjectName == "" {
p, _, err := o.ToProject(ctx, dockerCli, services, cli.WithDiscardEnvFile, cli.WithoutEnvironmentResolution)
if err != nil {
envProjectName := os.Getenv(ComposeProjectName)
if envProjectName != "" {
return nil, envProjectName, nil
}
return nil, "", err
}
project = p
name = p.Name
}
return project, name, nil
}
func (o *ProjectOptions) toProjectName(ctx context.Context, dockerCli command.Cli) (string, error) {
if o.ProjectName != "" {
return o.ProjectName, nil
}
envProjectName := os.Getenv("COMPOSE_PROJECT_NAME")
envProjectName := os.Getenv(ComposeProjectName)
if envProjectName != "" {
return envProjectName, nil
}
project, err := o.toProject(nil)
project, _, err := o.ToProject(ctx, dockerCli, nil)
if err != nil {
return "", err
}
return project.Name, nil
}
func (o *projectOptions) toProject(services []string, po ...cli.ProjectOptionsFn) (*types.Project, error) {
func (o *ProjectOptions) ToModel(ctx context.Context, dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (map[string]any, error) {
remotes := o.remoteLoaders(dockerCli)
for _, r := range remotes {
po = append(po, cli.WithResourceLoader(r))
}
options, err := o.toProjectOptions(po...)
if err != nil {
return nil, compose.WrapComposeError(err)
return nil, err
}
project, err := cli.ProjectFromOptions(options)
if o.Compatibility || utils.StringToBool(options.Environment[ComposeCompatibility]) {
api.Separator = "_"
}
return options.LoadModel(ctx)
}
func (o *ProjectOptions) ToProject(ctx context.Context, dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (*types.Project, tracing.Metrics, error) { //nolint:gocyclo
var metrics tracing.Metrics
remotes := o.remoteLoaders(dockerCli)
for _, r := range remotes {
po = append(po, cli.WithResourceLoader(r))
}
options, err := o.toProjectOptions(po...)
if err != nil {
return nil, compose.WrapComposeError(err)
return nil, metrics, err
}
if o.Compatibility || utils.StringToBool(project.Environment["COMPOSE_COMPATIBILITY"]) {
compose.Separator = "_"
}
ef := o.EnvFile
if ef != "" && !filepath.IsAbs(ef) {
ef, err = filepath.Abs(ef)
if err != nil {
return nil, err
options.WithListeners(func(event string, metadata map[string]any) {
switch event {
case "extends":
metrics.CountExtends++
case "include":
paths := metadata["path"].(types.StringList)
for _, path := range paths {
var isRemote bool
for _, r := range remotes {
if r.Accept(path) {
isRemote = true
break
}
}
if isRemote {
metrics.CountIncludesRemote++
} else {
metrics.CountIncludesLocal++
}
}
}
})
if o.Compatibility || utils.StringToBool(options.Environment[ComposeCompatibility]) {
api.Separator = "_"
}
for i, s := range project.Services {
project, err := options.LoadProject(ctx)
if err != nil {
return nil, metrics, err
}
if project.Name == "" {
return nil, metrics, errors.New("project name can't be empty. Use `--project-name` to set a valid name")
}
project, err = project.WithServicesEnabled(services...)
if err != nil {
return nil, metrics, err
}
for name, s := range project.Services {
s.CustomLabels = map[string]string{
api.ProjectLabel: project.Name,
api.ServiceLabel: s.Name,
api.ServiceLabel: name,
api.VersionLabel: api.ComposeVersion,
api.WorkingDirLabel: project.WorkingDir,
api.ConfigFilesLabel: strings.Join(project.ComposeFiles, ","),
api.OneoffLabel: "False", // default, will be overridden by `run` command
}
if ef != "" {
s.CustomLabels[api.EnvironmentFileLabel] = ef
if len(o.EnvFiles) != 0 {
s.CustomLabels[api.EnvironmentFileLabel] = strings.Join(o.EnvFiles, ",")
}
project.Services[i] = s
project.Services[name] = s
}
if len(services) > 0 {
s, err := project.GetServices(services...)
if err != nil {
return nil, err
}
o.Profiles = append(o.Profiles, s.GetProfiles()...)
project, err = project.WithSelectedServices(services)
if err != nil {
return nil, tracing.Metrics{}, err
}
if profiles, ok := options.Environment["COMPOSE_PROFILES"]; ok {
o.Profiles = append(o.Profiles, strings.Split(profiles, ",")...)
if !o.All {
project = project.WithoutUnnecessaryResources()
}
project.ApplyProfiles(o.Profiles)
project.WithoutUnnecessaryResources()
err = project.ForServices(services)
return project, err
return project, metrics, err
}
func (o *projectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.ProjectOptions, error) {
func (o *ProjectOptions) remoteLoaders(dockerCli command.Cli) []loader.ResourceLoader {
if o.Offline {
return nil
}
git := remote.NewGitRemoteLoader(dockerCli, o.Offline)
oci := remote.NewOCIRemoteLoader(dockerCli, o.Offline)
return []loader.ResourceLoader{git, oci}
}
func (o *ProjectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.ProjectOptions, error) {
pwd, err := os.Getwd()
if err != nil {
return nil, err
}
return cli.NewProjectOptions(o.ConfigPaths,
append(po,
cli.WithWorkingDirectory(o.ProjectDir),
// First apply os.Environment, always win
cli.WithOsEnv,
cli.WithEnvFile(o.EnvFile),
// set PWD as this variable is not consistently supported on Windows
cli.WithEnv([]string{"PWD=" + pwd}),
// Load PWD/.env if present and no explicit --env-file has been set
cli.WithEnvFiles(o.EnvFiles...),
// read dot env file to populate project environment
cli.WithDotEnv,
// get compose file path set by COMPOSE_FILE
cli.WithConfigFileEnv,
// if none was selected, get default compose.yaml file from current dir or parent folder
cli.WithDefaultConfigPath,
// .. and then, a project directory != PWD maybe has been set so let's load .env file
cli.WithEnvFiles(o.EnvFiles...),
cli.WithDotEnv,
// eventually COMPOSE_PROFILES should have been set
cli.WithDefaultProfiles(o.Profiles...),
cli.WithName(o.ProjectName))...)
}
@ -227,42 +416,54 @@ const PluginName = "compose"
// RunningAsStandalone detects when running as a standalone program
func RunningAsStandalone() bool {
return len(os.Args) < 2 || os.Args[1] != manager.MetadataSubcommandName && os.Args[1] != PluginName
return len(os.Args) < 2 || os.Args[1] != metadata.MetadataSubcommandName && os.Args[1] != PluginName
}
// RootCommand returns the compose command with its child commands
func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := projectOptions{}
func RootCommand(dockerCli command.Cli, backend Backend) *cobra.Command { //nolint:gocyclo
// filter out useless commandConn.CloseWrite warning message that can occur
// when using a remote context that is unreachable: "commandConn.CloseWrite: commandconn: failed to wait: signal: killed"
// https://github.com/docker/cli/blob/e1f24d3c93df6752d3c27c8d61d18260f141310c/cli/connhelper/commandconn/commandconn.go#L203-L215
logrus.AddHook(logutil.NewFilter([]logrus.Level{
logrus.WarnLevel,
},
"commandConn.CloseWrite:",
"commandConn.CloseRead:",
))
experiments := experimental.NewState()
opts := ProjectOptions{}
var (
ansi string
noAnsi bool
verbose bool
version bool
ansi string
noAnsi bool
verbose bool
version bool
parallel int
dryRun bool
)
command := &cobra.Command{
c := &cobra.Command{
Short: "Docker Compose",
Long: "Define and run multi-container applications with Docker",
Use: PluginName,
TraverseChildren: true,
// By default (no Run/RunE in parent command) for typos in subcommands, cobra displays the help of parent command but exit(0) !
// By default (no Run/RunE in parent c) for typos in subcommands, cobra displays the help of parent c but exit(0) !
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return cmd.Help()
}
if version {
return versionCommand().Execute()
return versionCommand(dockerCli).Execute()
}
_ = cmd.Help()
return dockercli.StatusError{
StatusCode: compose.CommandSyntaxFailure.ExitCode,
StatusCode: 1,
Status: fmt.Sprintf("unknown docker command: %q", "compose "+args[0]),
}
},
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
err := setEnvWithDotEnv(&opts)
if err != nil {
return err
}
ctx := cmd.Context()
parent := cmd.Root()
if parent != nil {
parentPrerun := parent.PersistentPreRunE
if parentPrerun != nil {
@ -272,23 +473,64 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command {
}
}
}
if verbose {
logrus.SetLevel(logrus.TraceLevel)
}
err := setEnvWithDotEnv(opts)
if err != nil {
return err
}
if noAnsi {
if ansi != "auto" {
return errors.New(`cannot specify DEPRECATED "--no-ansi" and "--ansi". Please use only "--ansi"`)
}
ansi = "never"
fmt.Fprint(os.Stderr, aec.Apply("option '--no-ansi' is DEPRECATED ! Please use '--ansi' instead.\n", aec.RedF))
fmt.Fprint(os.Stderr, "option '--no-ansi' is DEPRECATED ! Please use '--ansi' instead.\n")
}
if verbose {
logrus.SetLevel(logrus.TraceLevel)
if v, ok := os.LookupEnv("COMPOSE_ANSI"); ok && !cmd.Flags().Changed("ansi") {
ansi = v
}
formatter.SetANSIMode(ansi)
formatter.SetANSIMode(dockerCli, ansi)
if noColor, ok := os.LookupEnv("NO_COLOR"); ok && noColor != "" {
ui.NoColor()
formatter.SetANSIMode(dockerCli, formatter.Never)
}
switch ansi {
case "never":
progress.Mode = progress.ModePlain
case "tty":
progress.Mode = progress.ModeTTY
ui.Mode = ui.ModePlain
case "always":
ui.Mode = ui.ModeTTY
}
switch opts.Progress {
case "", ui.ModeAuto:
if ansi == "never" {
ui.Mode = ui.ModePlain
}
case ui.ModeTTY:
if ansi == "never" {
return fmt.Errorf("can't use --progress tty while ANSI support is disabled")
}
ui.Mode = ui.ModeTTY
case ui.ModePlain:
if ansi == "always" {
return fmt.Errorf("can't use --progress plain while ANSI support is forced")
}
ui.Mode = ui.ModePlain
case ui.ModeQuiet, "none":
ui.Mode = ui.ModeQuiet
case ui.ModeJSON:
ui.Mode = ui.ModeJSON
logrus.SetFormatter(&logrus.JSONFormatter{})
default:
return fmt.Errorf("unsupported --progress value %q", opts.Progress)
}
// (4) options validation / normalization
if opts.WorkDir != "" {
if opts.ProjectDir != "" {
return errors.New(`cannot specify DEPRECATED "--workdir" and "--project-directory". Please use only "--project-directory" instead`)
@ -296,69 +538,186 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command {
opts.ProjectDir = opts.WorkDir
fmt.Fprint(os.Stderr, aec.Apply("option '--workdir' is DEPRECATED at root level! Please use '--project-directory' instead.\n", aec.RedF))
}
for i, file := range opts.EnvFiles {
if !filepath.IsAbs(file) {
file, err := filepath.Abs(file)
if err != nil {
return err
}
opts.EnvFiles[i] = file
}
}
composeCmd := cmd
for composeCmd.Name() != PluginName {
if !composeCmd.HasParent() {
return fmt.Errorf("error parsing command line, expected %q", PluginName)
}
composeCmd = composeCmd.Parent()
}
if v, ok := os.LookupEnv(ComposeParallelLimit); ok && !composeCmd.Flags().Changed("parallel") {
i, err := strconv.Atoi(v)
if err != nil {
return fmt.Errorf("%s must be an integer (found: %q)", ComposeParallelLimit, v)
}
parallel = i
}
if parallel > 0 {
logrus.Debugf("Limiting max concurrency to %d jobs", parallel)
backend.MaxConcurrency(parallel)
}
// dry run detection
ctx, err = backend.DryRunMode(ctx, dryRun)
if err != nil {
return err
}
cmd.SetContext(ctx)
// (6) Desktop integration
var desktopCli *desktop.Client
if !dryRun {
if desktopCli, err = desktop.NewFromDockerClient(ctx, dockerCli); desktopCli != nil {
logrus.Debugf("Enabled Docker Desktop integration (experimental) @ %s", desktopCli.Endpoint())
backend.SetDesktopClient(desktopCli)
} else if err != nil {
// not fatal, Compose will still work but behave as though
// it's not running as part of Docker Desktop
logrus.Debugf("failed to enable Docker Desktop integration: %v", err)
} else {
logrus.Trace("Docker Desktop integration not enabled")
}
}
// (7) experimental features
if err := experiments.Load(ctx, desktopCli); err != nil {
logrus.Debugf("Failed to query feature flags from Desktop: %v", err)
}
backend.SetExperiments(experiments)
return nil
},
}
command.AddCommand(
upCommand(&opts, backend),
downCommand(&opts, backend),
startCommand(&opts, backend),
restartCommand(&opts, backend),
stopCommand(&opts, backend),
psCommand(&opts, backend),
listCommand(backend),
logsCommand(&opts, backend),
convertCommand(&opts, backend),
killCommand(&opts, backend),
c.AddCommand(
upCommand(&opts, dockerCli, backend),
downCommand(&opts, dockerCli, backend),
startCommand(&opts, dockerCli, backend),
restartCommand(&opts, dockerCli, backend),
stopCommand(&opts, dockerCli, backend),
psCommand(&opts, dockerCli, backend),
listCommand(dockerCli, backend),
logsCommand(&opts, dockerCli, backend),
configCommand(&opts, dockerCli),
killCommand(&opts, dockerCli, backend),
runCommand(&opts, dockerCli, backend),
removeCommand(&opts, backend),
removeCommand(&opts, dockerCli, backend),
execCommand(&opts, dockerCli, backend),
pauseCommand(&opts, backend),
unpauseCommand(&opts, backend),
topCommand(&opts, backend),
eventsCommand(&opts, backend),
portCommand(&opts, backend),
imagesCommand(&opts, backend),
versionCommand(),
buildCommand(&opts, backend),
pushCommand(&opts, backend),
pullCommand(&opts, backend),
createCommand(&opts, backend),
copyCommand(&opts, backend),
attachCommand(&opts, dockerCli, backend),
exportCommand(&opts, dockerCli, backend),
commitCommand(&opts, dockerCli, backend),
pauseCommand(&opts, dockerCli, backend),
unpauseCommand(&opts, dockerCli, backend),
topCommand(&opts, dockerCli, backend),
eventsCommand(&opts, dockerCli, backend),
portCommand(&opts, dockerCli, backend),
imagesCommand(&opts, dockerCli, backend),
versionCommand(dockerCli),
buildCommand(&opts, dockerCli, backend),
pushCommand(&opts, dockerCli, backend),
pullCommand(&opts, dockerCli, backend),
createCommand(&opts, dockerCli, backend),
copyCommand(&opts, dockerCli, backend),
waitCommand(&opts, dockerCli, backend),
scaleCommand(&opts, dockerCli, backend),
statsCommand(&opts, dockerCli),
watchCommand(&opts, dockerCli, backend),
publishCommand(&opts, dockerCli, backend),
alphaCommand(&opts, dockerCli, backend),
bridgeCommand(&opts, dockerCli),
volumesCommand(&opts, dockerCli, backend),
)
command.Flags().SetInterspersed(false)
opts.addProjectFlags(command.Flags())
command.Flags().StringVar(&ansi, "ansi", "auto", `Control when to print ANSI control characters ("never"|"always"|"auto")`)
command.Flags().BoolVarP(&version, "version", "v", false, "Show the Docker Compose version information")
command.Flags().MarkHidden("version") //nolint:errcheck
command.Flags().BoolVar(&noAnsi, "no-ansi", false, `Do not print ANSI control characters (DEPRECATED)`)
command.Flags().MarkHidden("no-ansi") //nolint:errcheck
command.Flags().BoolVar(&verbose, "verbose", false, "Show more output")
command.Flags().MarkHidden("verbose") //nolint:errcheck
return command
c.Flags().SetInterspersed(false)
opts.addProjectFlags(c.Flags())
c.RegisterFlagCompletionFunc( //nolint:errcheck
"project-name",
completeProjectNames(backend),
)
c.RegisterFlagCompletionFunc( //nolint:errcheck
"project-directory",
func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return []string{}, cobra.ShellCompDirectiveFilterDirs
},
)
c.RegisterFlagCompletionFunc( //nolint:errcheck
"file",
func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return []string{"yaml", "yml"}, cobra.ShellCompDirectiveFilterFileExt
},
)
c.RegisterFlagCompletionFunc( //nolint:errcheck
"profile",
completeProfileNames(dockerCli, &opts),
)
c.RegisterFlagCompletionFunc( //nolint:errcheck
"progress",
cobra.FixedCompletions(printerModes, cobra.ShellCompDirectiveNoFileComp),
)
c.Flags().StringVar(&ansi, "ansi", "auto", `Control when to print ANSI control characters ("never"|"always"|"auto")`)
c.Flags().IntVar(&parallel, "parallel", -1, `Control max parallelism, -1 for unlimited`)
c.Flags().BoolVarP(&version, "version", "v", false, "Show the Docker Compose version information")
c.PersistentFlags().BoolVar(&dryRun, "dry-run", false, "Execute command in dry run mode")
c.Flags().MarkHidden("version") //nolint:errcheck
c.Flags().BoolVar(&noAnsi, "no-ansi", false, `Do not print ANSI control characters (DEPRECATED)`)
c.Flags().MarkHidden("no-ansi") //nolint:errcheck
c.Flags().BoolVar(&verbose, "verbose", false, "Show more output")
c.Flags().MarkHidden("verbose") //nolint:errcheck
return c
}
func setEnvWithDotEnv(prjOpts *projectOptions) error {
options, err := prjOpts.toProjectOptions()
func setEnvWithDotEnv(opts ProjectOptions) error {
options, err := cli.NewProjectOptions(opts.ConfigPaths,
cli.WithWorkingDirectory(opts.ProjectDir),
cli.WithOsEnv,
cli.WithEnvFiles(opts.EnvFiles...),
cli.WithDotEnv,
)
if err != nil {
return compose.WrapComposeError(err)
return nil
}
workingDir, err := options.GetWorkingDir()
envFromFile, err := dotenv.GetEnvFromFile(composegoutils.GetAsEqualsMap(os.Environ()), options.EnvFiles)
if err != nil {
return err
}
envFromFile, err := cli.GetEnvFromFile(composegoutils.GetAsEqualsMap(os.Environ()), workingDir, options.EnvFile)
if err != nil {
return err
return nil
}
for k, v := range envFromFile {
if _, ok := os.LookupEnv(k); !ok {
if err = os.Setenv(k, v); err != nil {
return err
return nil
}
}
}
return nil
return err
}
var printerModes = []string{
ui.ModeAuto,
ui.ModeTTY,
ui.ModePlain,
ui.ModeJSON,
ui.ModeQuiet,
}
func SetUnchangedOption(name string, experimentalFlag bool) bool {
var value bool
// If the var is defined we use that value first
if envVar, ok := os.LookupEnv(name); ok {
value = utils.StringToBool(envVar)
} else {
// if not, we try to get it from experimental feature flag
value = experimentalFlag
}
return value
}

View File

@ -19,30 +19,32 @@ package compose
import (
"testing"
"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
"gotest.tools/v3/assert"
)
func TestFilterServices(t *testing.T) {
p := &types.Project{
Services: []types.ServiceConfig{
{
Services: types.Services{
"foo": {
Name: "foo",
Links: []string{"bar"},
},
{
Name: "bar",
NetworkMode: types.NetworkModeServicePrefix + "zot",
"bar": {
Name: "bar",
DependsOn: map[string]types.ServiceDependency{
"zot": {},
},
},
{
"zot": {
Name: "zot",
},
{
"qix": {
Name: "qix",
},
},
}
err := p.ForServices([]string{"bar"})
p, err := p.WithSelectedServices([]string{"bar"})
assert.NilError(t, err)
assert.Equal(t, len(p.Services), 2)

517
cmd/compose/config.go Normal file
View File

@ -0,0 +1,517 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"os"
"sort"
"strings"
"github.com/compose-spec/compose-go/v2/cli"
"github.com/compose-spec/compose-go/v2/template"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/compose"
)
type configOptions struct {
*ProjectOptions
Format string
Output string
quiet bool
resolveImageDigests bool
noInterpolate bool
noNormalize bool
noResolvePath bool
noResolveEnv bool
services bool
volumes bool
networks bool
models bool
profiles bool
images bool
hash string
noConsistency bool
variables bool
environment bool
lockImageDigests bool
}
func (o *configOptions) ToProject(ctx context.Context, dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (*types.Project, error) {
po = append(po, o.ToProjectOptions()...)
project, _, err := o.ProjectOptions.ToProject(ctx, dockerCli, services, po...)
return project, err
}
func (o *configOptions) ToModel(ctx context.Context, dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (map[string]any, error) {
po = append(po, o.ToProjectOptions()...)
return o.ProjectOptions.ToModel(ctx, dockerCli, services, po...)
}
func (o *configOptions) ToProjectOptions() []cli.ProjectOptionsFn {
return []cli.ProjectOptionsFn{
cli.WithInterpolation(!o.noInterpolate),
cli.WithResolvedPaths(!o.noResolvePath),
cli.WithNormalization(!o.noNormalize),
cli.WithConsistency(!o.noConsistency),
cli.WithDefaultProfiles(o.Profiles...),
cli.WithDiscardEnvFile,
}
}
func configCommand(p *ProjectOptions, dockerCli command.Cli) *cobra.Command {
opts := configOptions{
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "config [OPTIONS] [SERVICE...]",
Short: "Parse, resolve and render compose file in canonical format",
PreRunE: Adapt(func(ctx context.Context, args []string) error {
if opts.quiet {
devnull, err := os.Open(os.DevNull)
if err != nil {
return err
}
os.Stdout = devnull
}
if p.Compatibility {
opts.noNormalize = true
}
if opts.lockImageDigests {
opts.resolveImageDigests = true
}
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
if opts.services {
return runServices(ctx, dockerCli, opts)
}
if opts.volumes {
return runVolumes(ctx, dockerCli, opts)
}
if opts.networks {
return runNetworks(ctx, dockerCli, opts)
}
if opts.models {
return runModels(ctx, dockerCli, opts)
}
if opts.hash != "" {
return runHash(ctx, dockerCli, opts)
}
if opts.profiles {
return runProfiles(ctx, dockerCli, opts, args)
}
if opts.images {
return runConfigImages(ctx, dockerCli, opts, args)
}
if opts.variables {
return runVariables(ctx, dockerCli, opts, args)
}
if opts.environment {
return runEnvironment(ctx, dockerCli, opts, args)
}
if opts.Format == "" {
opts.Format = "yaml"
}
return runConfig(ctx, dockerCli, opts, args)
}),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.StringVar(&opts.Format, "format", "", "Format the output. Values: [yaml | json]")
flags.BoolVar(&opts.resolveImageDigests, "resolve-image-digests", false, "Pin image tags to digests")
flags.BoolVar(&opts.lockImageDigests, "lock-image-digests", false, "Produces an override file with image digests")
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Only validate the configuration, don't print anything")
flags.BoolVar(&opts.noInterpolate, "no-interpolate", false, "Don't interpolate environment variables")
flags.BoolVar(&opts.noNormalize, "no-normalize", false, "Don't normalize compose model")
flags.BoolVar(&opts.noResolvePath, "no-path-resolution", false, "Don't resolve file paths")
flags.BoolVar(&opts.noConsistency, "no-consistency", false, "Don't check model consistency - warning: may produce invalid Compose output")
flags.BoolVar(&opts.noResolveEnv, "no-env-resolution", false, "Don't resolve service env files")
flags.BoolVar(&opts.services, "services", false, "Print the service names, one per line.")
flags.BoolVar(&opts.volumes, "volumes", false, "Print the volume names, one per line.")
flags.BoolVar(&opts.networks, "networks", false, "Print the network names, one per line.")
flags.BoolVar(&opts.models, "models", false, "Print the model names, one per line.")
flags.BoolVar(&opts.profiles, "profiles", false, "Print the profile names, one per line.")
flags.BoolVar(&opts.images, "images", false, "Print the image names, one per line.")
flags.StringVar(&opts.hash, "hash", "", "Print the service config hash, one per line.")
flags.BoolVar(&opts.variables, "variables", false, "Print model variables and default values.")
flags.BoolVar(&opts.environment, "environment", false, "Print environment used for interpolation.")
flags.StringVarP(&opts.Output, "output", "o", "", "Save to file (default to stdout)")
return cmd
}
func runConfig(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) (err error) {
var content []byte
if opts.noInterpolate {
content, err = runConfigNoInterpolate(ctx, dockerCli, opts, services)
if err != nil {
return err
}
} else {
content, err = runConfigInterpolate(ctx, dockerCli, opts, services)
if err != nil {
return err
}
}
if !opts.noInterpolate {
content = escapeDollarSign(content)
}
if opts.quiet {
return nil
}
if opts.Output != "" && len(content) > 0 {
return os.WriteFile(opts.Output, content, 0o666)
}
_, err = fmt.Fprint(dockerCli.Out(), string(content))
return err
}
func runConfigInterpolate(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) ([]byte, error) {
project, err := opts.ToProject(ctx, dockerCli, services)
if err != nil {
return nil, err
}
if opts.resolveImageDigests {
project, err = project.WithImagesResolved(compose.ImageDigestResolver(ctx, dockerCli.ConfigFile(), dockerCli.Client()))
if err != nil {
return nil, err
}
}
if !opts.noResolveEnv {
project, err = project.WithServicesEnvironmentResolved(true)
if err != nil {
return nil, err
}
}
if !opts.noConsistency {
err := project.CheckContainerNameUnicity()
if err != nil {
return nil, err
}
}
if opts.lockImageDigests {
project = imagesOnly(project)
}
var content []byte
switch opts.Format {
case "json":
content, err = project.MarshalJSON()
case "yaml":
content, err = project.MarshalYAML()
default:
return nil, fmt.Errorf("unsupported format %q", opts.Format)
}
if err != nil {
return nil, err
}
return content, nil
}
// imagesOnly return project with all attributes removed but service.images
func imagesOnly(project *types.Project) *types.Project {
digests := types.Services{}
for name, config := range project.Services {
digests[name] = types.ServiceConfig{
Image: config.Image,
}
}
project = &types.Project{Services: digests}
return project
}
func runConfigNoInterpolate(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) ([]byte, error) {
// we can't use ToProject, so the model we render here is only partially resolved
model, err := opts.ToModel(ctx, dockerCli, services)
if err != nil {
return nil, err
}
if opts.resolveImageDigests {
err = resolveImageDigests(ctx, dockerCli, model)
if err != nil {
return nil, err
}
}
if opts.lockImageDigests {
for key, e := range model {
if key != "services" {
delete(model, key)
} else {
for _, s := range e.(map[string]any) {
service := s.(map[string]any)
for key := range service {
if key != "image" {
delete(service, key)
}
}
}
}
}
}
return formatModel(model, opts.Format)
}
func resolveImageDigests(ctx context.Context, dockerCli command.Cli, model map[string]any) (err error) {
// create a pseudo-project so we can rely on WithImagesResolved to resolve images
p := &types.Project{
Services: types.Services{},
}
services := model["services"].(map[string]any)
for name, s := range services {
service := s.(map[string]any)
if image, ok := service["image"]; ok {
p.Services[name] = types.ServiceConfig{
Image: image.(string),
}
}
}
p, err = p.WithImagesResolved(compose.ImageDigestResolver(ctx, dockerCli.ConfigFile(), dockerCli.Client()))
if err != nil {
return err
}
// Collect image resolved with digest and update model accordingly
for name, s := range services {
service := s.(map[string]any)
config := p.Services[name]
if config.Image != "" {
service["image"] = config.Image
}
services[name] = service
}
model["services"] = services
return nil
}
func formatModel(model map[string]any, format string) (content []byte, err error) {
switch format {
case "json":
content, err = json.MarshalIndent(model, "", " ")
case "yaml":
buf := bytes.NewBuffer([]byte{})
encoder := yaml.NewEncoder(buf)
encoder.SetIndent(2)
err = encoder.Encode(model)
content = buf.Bytes()
default:
return nil, fmt.Errorf("unsupported format %q", format)
}
return
}
func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
if opts.noInterpolate {
// we can't use ToProject, so the model we render here is only partially resolved
data, err := opts.ToModel(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
if err != nil {
return err
}
if _, ok := data["services"]; ok {
for serviceName := range data["services"].(map[string]any) {
_, _ = fmt.Fprintln(dockerCli.Out(), serviceName)
}
}
return nil
}
project, err := opts.ToProject(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
if err != nil {
return err
}
err = project.ForEachService(project.ServiceNames(), func(serviceName string, _ *types.ServiceConfig) error {
_, _ = fmt.Fprintln(dockerCli.Out(), serviceName)
return nil
})
return err
}
func runVolumes(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
project, err := opts.ToProject(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
if err != nil {
return err
}
for n := range project.Volumes {
_, _ = fmt.Fprintln(dockerCli.Out(), n)
}
return nil
}
func runNetworks(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
project, err := opts.ToProject(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
if err != nil {
return err
}
for n := range project.Networks {
_, _ = fmt.Fprintln(dockerCli.Out(), n)
}
return nil
}
func runModels(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
project, err := opts.ToProject(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
if err != nil {
return err
}
for _, model := range project.Models {
if model.Model != "" {
_, _ = fmt.Fprintln(dockerCli.Out(), model.Model)
}
}
return nil
}
func runHash(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
var services []string
if opts.hash != "*" {
services = append(services, strings.Split(opts.hash, ",")...)
}
project, err := opts.ToProject(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
if err != nil {
return err
}
if err := applyPlatforms(project, true); err != nil {
return err
}
if len(services) == 0 {
services = project.ServiceNames()
}
sorted := services
sort.Slice(sorted, func(i, j int) bool {
return sorted[i] < sorted[j]
})
for _, name := range sorted {
s, err := project.GetService(name)
if err != nil {
return err
}
hash, err := compose.ServiceHash(s)
if err != nil {
return err
}
_, _ = fmt.Fprintf(dockerCli.Out(), "%s %s\n", name, hash)
}
return nil
}
func runProfiles(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
set := map[string]struct{}{}
project, err := opts.ToProject(ctx, dockerCli, services, cli.WithoutEnvironmentResolution)
if err != nil {
return err
}
for _, s := range project.AllServices() {
for _, p := range s.Profiles {
set[p] = struct{}{}
}
}
profiles := make([]string, 0, len(set))
for p := range set {
profiles = append(profiles, p)
}
sort.Strings(profiles)
for _, p := range profiles {
_, _ = fmt.Fprintln(dockerCli.Out(), p)
}
return nil
}
func runConfigImages(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
project, err := opts.ToProject(ctx, dockerCli, services, cli.WithoutEnvironmentResolution)
if err != nil {
return err
}
for _, s := range project.Services {
_, _ = fmt.Fprintln(dockerCli.Out(), api.GetImageNameOrDefault(s, project.Name))
}
return nil
}
func runVariables(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
opts.noInterpolate = true
model, err := opts.ToModel(ctx, dockerCli, services, cli.WithoutEnvironmentResolution)
if err != nil {
return err
}
variables := template.ExtractVariables(model, template.DefaultPattern)
if opts.Format == "yaml" {
result, err := yaml.Marshal(variables)
if err != nil {
return err
}
fmt.Print(string(result))
return nil
}
return formatter.Print(variables, opts.Format, dockerCli.Out(), func(w io.Writer) {
for name, variable := range variables {
_, _ = fmt.Fprintf(w, "%s\t%t\t%s\t%s\n", name, variable.Required, variable.DefaultValue, variable.PresenceValue)
}
}, "NAME", "REQUIRED", "DEFAULT VALUE", "ALTERNATE VALUE")
}
func runEnvironment(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
project, err := opts.ToProject(ctx, dockerCli, services)
if err != nil {
return err
}
for _, v := range project.Environment.Values() {
fmt.Println(v)
}
return nil
}
func escapeDollarSign(marshal []byte) []byte {
dollar := []byte{'$'}
escDollar := []byte{'$', '$'}
return bytes.ReplaceAll(marshal, dollar, escDollar)
}

View File

@ -1,239 +0,0 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"bufio"
"context"
"fmt"
"io"
"os"
"sort"
"strings"
"github.com/cnabio/cnab-to-oci/remotes"
"github.com/compose-spec/compose-go/cli"
"github.com/compose-spec/compose-go/types"
"github.com/distribution/distribution/v3/reference"
cliconfig "github.com/docker/cli/cli/config"
"github.com/opencontainers/go-digest"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/compose"
)
type convertOptions struct {
*projectOptions
Format string
Output string
quiet bool
resolveImageDigests bool
noInterpolate bool
noNormalize bool
services bool
volumes bool
profiles bool
images bool
hash string
}
func convertCommand(p *projectOptions, backend api.Service) *cobra.Command {
opts := convertOptions{
projectOptions: p,
}
cmd := &cobra.Command{
Aliases: []string{"config"},
Use: "convert SERVICES",
Short: "Converts the compose file to platform's canonical format",
PreRunE: Adapt(func(ctx context.Context, args []string) error {
if opts.quiet {
devnull, err := os.Open(os.DevNull)
if err != nil {
return err
}
os.Stdout = devnull
}
if p.Compatibility {
opts.noNormalize = true
}
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
if opts.services {
return runServices(opts)
}
if opts.volumes {
return runVolumes(opts)
}
if opts.hash != "" {
return runHash(opts)
}
if opts.profiles {
return runProfiles(opts, args)
}
if opts.images {
return runConfigImages(opts, args)
}
return runConvert(ctx, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
}
flags := cmd.Flags()
flags.StringVar(&opts.Format, "format", "yaml", "Format the output. Values: [yaml | json]")
flags.BoolVar(&opts.resolveImageDigests, "resolve-image-digests", false, "Pin image tags to digests.")
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Only validate the configuration, don't print anything.")
flags.BoolVar(&opts.noInterpolate, "no-interpolate", false, "Don't interpolate environment variables.")
flags.BoolVar(&opts.noNormalize, "no-normalize", false, "Don't normalize compose model.")
flags.BoolVar(&opts.services, "services", false, "Print the service names, one per line.")
flags.BoolVar(&opts.volumes, "volumes", false, "Print the volume names, one per line.")
flags.BoolVar(&opts.profiles, "profiles", false, "Print the profile names, one per line.")
flags.BoolVar(&opts.images, "images", false, "Print the image names, one per line.")
flags.StringVar(&opts.hash, "hash", "", "Print the service config hash, one per line.")
flags.StringVarP(&opts.Output, "output", "o", "", "Save to file (default to stdout)")
return cmd
}
func runConvert(ctx context.Context, backend api.Service, opts convertOptions, services []string) error {
var json []byte
project, err := opts.toProject(services,
cli.WithInterpolation(!opts.noInterpolate),
cli.WithResolvedPaths(true),
cli.WithNormalization(!opts.noNormalize),
cli.WithDiscardEnvFile)
if err != nil {
return err
}
if opts.resolveImageDigests {
configFile := cliconfig.LoadDefaultConfigFile(os.Stderr)
resolver := remotes.CreateResolver(configFile)
err = project.ResolveImages(func(named reference.Named) (digest.Digest, error) {
_, desc, err := resolver.Resolve(ctx, named.String())
return desc.Digest, err
})
if err != nil {
return err
}
}
json, err = backend.Convert(ctx, project, api.ConvertOptions{
Format: opts.Format,
Output: opts.Output,
})
if err != nil {
return err
}
if opts.quiet {
return nil
}
var out io.Writer = os.Stdout
if opts.Output != "" && len(json) > 0 {
file, err := os.Create(opts.Output)
if err != nil {
return err
}
out = bufio.NewWriter(file)
}
_, err = fmt.Fprint(out, string(json))
return err
}
func runServices(opts convertOptions) error {
project, err := opts.toProject(nil)
if err != nil {
return err
}
return project.WithServices(project.ServiceNames(), func(s types.ServiceConfig) error {
fmt.Println(s.Name)
return nil
})
}
func runVolumes(opts convertOptions) error {
project, err := opts.toProject(nil)
if err != nil {
return err
}
for n := range project.Volumes {
fmt.Println(n)
}
return nil
}
func runHash(opts convertOptions) error {
var services []string
if opts.hash != "*" {
services = append(services, strings.Split(opts.hash, ",")...)
}
project, err := opts.toProject(services)
if err != nil {
return err
}
for _, s := range project.Services {
hash, err := compose.ServiceHash(s)
if err != nil {
return err
}
fmt.Printf("%s %s\n", s.Name, hash)
}
return nil
}
func runProfiles(opts convertOptions, services []string) error {
set := map[string]struct{}{}
project, err := opts.toProject(services)
if err != nil {
return err
}
for _, s := range project.AllServices() {
for _, p := range s.Profiles {
set[p] = struct{}{}
}
}
profiles := make([]string, 0, len(set))
for p := range set {
profiles = append(profiles, p)
}
sort.Strings(profiles)
for _, p := range profiles {
fmt.Println(p)
}
return nil
}
func runConfigImages(opts convertOptions, services []string) error {
project, err := opts.toProject(services)
if err != nil {
return err
}
for _, s := range project.Services {
if s.Image != "" {
fmt.Println(s.Image)
} else {
fmt.Printf("%s_%s\n", project.Name, s.Name)
}
}
return nil
}

View File

@ -21,13 +21,14 @@ import (
"errors"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
)
type copyOptions struct {
*projectOptions
*ProjectOptions
source string
destination string
@ -37,9 +38,9 @@ type copyOptions struct {
copyUIDGID bool
}
func copyCommand(p *projectOptions, backend api.Service) *cobra.Command {
func copyCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := copyOptions{
projectOptions: p,
ProjectOptions: p,
}
copyCmd := &cobra.Command{
Use: `cp [OPTIONS] SERVICE:SRC_PATH DEST_PATH|-
@ -58,24 +59,22 @@ func copyCommand(p *projectOptions, backend api.Service) *cobra.Command {
RunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
opts.source = args[0]
opts.destination = args[1]
return runCopy(ctx, backend, opts)
return runCopy(ctx, dockerCli, backend, opts)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := copyCmd.Flags()
flags.IntVar(&opts.index, "index", 0, "Index of the container if there are multiple instances of a service .")
flags.BoolVar(&opts.all, "all", false, "Copy to all the containers of the service.")
flags.MarkHidden("all") //nolint:errcheck
flags.MarkDeprecated("all", "By default all the containers of the service will get the source file/directory to be copied.") //nolint:errcheck
flags.IntVar(&opts.index, "index", 0, "Index of the container if service has multiple replicas")
flags.BoolVar(&opts.all, "all", false, "Include containers created by the run command")
flags.BoolVarP(&opts.followLink, "follow-link", "L", false, "Always follow symbol link in SRC_PATH")
flags.BoolVarP(&opts.copyUIDGID, "archive", "a", false, "Archive mode (copy all uid/gid information)")
return copyCmd
}
func runCopy(ctx context.Context, backend api.Service, opts copyOptions) error {
name, err := opts.toProjectName()
func runCopy(ctx context.Context, dockerCli command.Cli, backend api.Service, opts copyOptions) error {
name, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}

View File

@ -19,10 +19,16 @@ package compose
import (
"context"
"fmt"
"slices"
"strconv"
"strings"
"time"
"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/docker/compose/v2/pkg/api"
)
@ -30,6 +36,8 @@ import (
type createOptions struct {
Build bool
noBuild bool
Pull string
pullChanged bool
removeOrphans bool
ignoreOrphans bool
forceRecreate bool
@ -39,14 +47,20 @@ type createOptions struct {
timeChanged bool
timeout int
quietPull bool
scale []string
AssumeYes bool
}
func createCommand(p *projectOptions, backend api.Service) *cobra.Command {
func createCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := createOptions{}
buildOpts := buildOptions{
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "create [SERVICE...]",
Short: "Creates containers for a service.",
PreRunE: Adapt(func(ctx context.Context, args []string) error {
Use: "create [OPTIONS] [SERVICE...]",
Short: "Creates containers for a service",
PreRunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
opts.pullChanged = cmd.Flags().Changed("pull")
if opts.Build && opts.noBuild {
return fmt.Errorf("--build and --no-build are incompatible")
}
@ -55,27 +69,60 @@ func createCommand(p *projectOptions, backend api.Service) *cobra.Command {
}
return nil
}),
RunE: p.WithProject(func(ctx context.Context, project *types.Project) error {
return backend.Create(ctx, project, api.CreateOptions{
RemoveOrphans: opts.removeOrphans,
IgnoreOrphans: opts.ignoreOrphans,
Recreate: opts.recreateStrategy(),
RecreateDependencies: opts.dependenciesRecreateStrategy(),
Inherit: !opts.noInherit,
Timeout: opts.GetTimeout(),
QuietPull: false,
})
RunE: p.WithServices(dockerCli, func(ctx context.Context, project *types.Project, services []string) error {
return runCreate(ctx, dockerCli, backend, opts, buildOpts, project, services)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.BoolVar(&opts.Build, "build", false, "Build images before starting containers.")
flags.BoolVar(&opts.noBuild, "no-build", false, "Don't build an image, even if it's missing.")
flags.BoolVar(&opts.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed.")
flags.BoolVar(&opts.Build, "build", false, "Build images before starting containers")
flags.BoolVar(&opts.noBuild, "no-build", false, "Don't build an image, even if it's policy")
flags.StringVar(&opts.Pull, "pull", "policy", `Pull image before running ("always"|"missing"|"never"|"build")`)
flags.BoolVar(&opts.quietPull, "quiet-pull", false, "Pull without printing progress information")
flags.BoolVar(&opts.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed")
flags.BoolVar(&opts.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
flags.BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
flags.StringArrayVar(&opts.scale, "scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.")
flags.BoolVarP(&opts.AssumeYes, "yes", "y", false, `Assume "yes" as answer to all prompts and run non-interactively`)
flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
// assumeYes was introduced by mistake as `--y`
if name == "y" {
logrus.Warn("--y is deprecated, please use --yes instead")
name = "yes"
}
return pflag.NormalizedName(name)
})
return cmd
}
func runCreate(ctx context.Context, _ command.Cli, backend api.Service, createOpts createOptions, buildOpts buildOptions, project *types.Project, services []string) error {
if err := createOpts.Apply(project); err != nil {
return err
}
var build *api.BuildOptions
if !createOpts.noBuild {
bo, err := buildOpts.toAPIBuildOptions(services)
if err != nil {
return err
}
build = &bo
}
return backend.Create(ctx, project, api.CreateOptions{
Build: build,
Services: services,
RemoveOrphans: createOpts.removeOrphans,
IgnoreOrphans: createOpts.ignoreOrphans,
Recreate: createOpts.recreateStrategy(),
RecreateDependencies: createOpts.dependenciesRecreateStrategy(),
Inherit: !createOpts.noInherit,
Timeout: createOpts.GetTimeout(),
QuietPull: createOpts.quietPull,
AssumeYes: createOpts.AssumeYes,
})
}
func (opts createOptions) recreateStrategy() string {
if opts.noRecreate {
return api.RecreateNever
@ -83,6 +130,9 @@ func (opts createOptions) recreateStrategy() string {
if opts.forceRecreate {
return api.RecreateForce
}
if opts.noInherit {
return api.RecreateForce
}
return api.RecreateDiverged
}
@ -104,7 +154,19 @@ func (opts createOptions) GetTimeout() *time.Duration {
return nil
}
func (opts createOptions) Apply(project *types.Project) {
func (opts createOptions) Apply(project *types.Project) error {
if opts.pullChanged {
if !opts.isPullPolicyValid() {
return fmt.Errorf("invalid --pull option %q", opts.Pull)
}
for i, service := range project.Services {
service.PullPolicy = opts.Pull
project.Services[i] = service
}
}
// N.B. opts.Build means "force build all", but images can still be built
// when this is false
// e.g. if a service has pull_policy: build or its local image is policy
if opts.Build {
for i, service := range project.Services {
if service.Build == nil {
@ -114,10 +176,41 @@ func (opts createOptions) Apply(project *types.Project) {
project.Services[i] = service
}
}
if opts.noBuild {
for i, service := range project.Services {
service.Build = nil
project.Services[i] = service
if err := applyPlatforms(project, true); err != nil {
return err
}
err := applyScaleOpts(project, opts.scale)
if err != nil {
return err
}
return nil
}
func applyScaleOpts(project *types.Project, opts []string) error {
for _, scale := range opts {
split := strings.Split(scale, "=")
if len(split) != 2 {
return fmt.Errorf("invalid --scale option %q. Should be SERVICE=NUM", scale)
}
name := split[0]
replicas, err := strconv.Atoi(split[1])
if err != nil {
return err
}
err = setServiceScale(project, name, replicas)
if err != nil {
return err
}
}
return nil
}
func (opts createOptions) isPullPolicyValid() bool {
pullPolicies := []string{
types.PullPolicyAlways, types.PullPolicyNever, types.PullPolicyBuild,
types.PullPolicyMissing, types.PullPolicyIfNotPresent,
}
return slices.Contains(pullPolicies, opts.Pull)
}

174
cmd/compose/create_test.go Normal file
View File

@ -0,0 +1,174 @@
/*
Copyright 2023 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"fmt"
"testing"
"github.com/compose-spec/compose-go/v2/types"
"github.com/davecgh/go-spew/spew"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/mocks"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
func TestRunCreate(t *testing.T) {
ctrl, ctx := gomock.WithContext(context.Background(), t)
backend := mocks.NewMockService(ctrl)
backend.EXPECT().Create(
gomock.Eq(ctx),
pullPolicy(""),
deepEqual(defaultCreateOptions(true)),
)
createOpts := createOptions{}
buildOpts := buildOptions{
ProjectOptions: &ProjectOptions{},
}
project := sampleProject()
err := runCreate(ctx, nil, backend, createOpts, buildOpts, project, nil)
require.NoError(t, err)
}
func TestRunCreate_Build(t *testing.T) {
ctrl, ctx := gomock.WithContext(context.Background(), t)
backend := mocks.NewMockService(ctrl)
backend.EXPECT().Create(
gomock.Eq(ctx),
pullPolicy("build"),
deepEqual(defaultCreateOptions(true)),
)
createOpts := createOptions{
Build: true,
}
buildOpts := buildOptions{
ProjectOptions: &ProjectOptions{},
}
project := sampleProject()
err := runCreate(ctx, nil, backend, createOpts, buildOpts, project, nil)
require.NoError(t, err)
}
func TestRunCreate_NoBuild(t *testing.T) {
ctrl, ctx := gomock.WithContext(context.Background(), t)
backend := mocks.NewMockService(ctrl)
backend.EXPECT().Create(
gomock.Eq(ctx),
pullPolicy(""),
deepEqual(defaultCreateOptions(false)),
)
createOpts := createOptions{
noBuild: true,
}
buildOpts := buildOptions{}
project := sampleProject()
err := runCreate(ctx, nil, backend, createOpts, buildOpts, project, nil)
require.NoError(t, err)
}
func sampleProject() *types.Project {
return &types.Project{
Name: "test",
Services: types.Services{
"svc": {
Name: "svc",
Build: &types.BuildConfig{
Context: ".",
},
},
},
}
}
func defaultCreateOptions(includeBuild bool) api.CreateOptions {
var build *api.BuildOptions
if includeBuild {
bo := defaultBuildOptions()
build = &bo
}
return api.CreateOptions{
Build: build,
Services: nil,
RemoveOrphans: false,
IgnoreOrphans: false,
Recreate: "diverged",
RecreateDependencies: "diverged",
Inherit: true,
Timeout: nil,
QuietPull: false,
}
}
func defaultBuildOptions() api.BuildOptions {
return api.BuildOptions{
Args: make(types.MappingWithEquals),
Progress: "auto",
}
}
// deepEqual returns a nice diff on failure vs gomock.Eq when used
// on structs.
func deepEqual(x interface{}) gomock.Matcher {
return gomock.GotFormatterAdapter(
gomock.GotFormatterFunc(func(got interface{}) string {
return cmp.Diff(x, got)
}),
gomock.Eq(x),
)
}
func spewAdapter(m gomock.Matcher) gomock.Matcher {
return gomock.GotFormatterAdapter(
gomock.GotFormatterFunc(func(got interface{}) string {
return spew.Sdump(got)
}),
m,
)
}
type withPullPolicy struct {
policy string
}
func pullPolicy(policy string) gomock.Matcher {
return spewAdapter(withPullPolicy{policy: policy})
}
func (w withPullPolicy) Matches(x interface{}) bool {
proj, ok := x.(*types.Project)
if !ok || proj == nil || len(proj.Services) == 0 {
return false
}
for _, svc := range proj.Services {
if svc.PullPolicy != w.policy {
return false
}
}
return true
}
func (w withPullPolicy) String() string {
return fmt.Sprintf("has pull policy %q for all services", w.policy)
}

View File

@ -22,7 +22,7 @@ import (
"os"
"time"
"github.com/compose-spec/compose-go/types"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/utils"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@ -32,7 +32,7 @@ import (
)
type downOptions struct {
*projectOptions
*ProjectOptions
removeOrphans bool
timeChanged bool
timeout int
@ -40,12 +40,12 @@ type downOptions struct {
images string
}
func downCommand(p *projectOptions, backend api.Service) *cobra.Command {
func downCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := downOptions{
projectOptions: p,
ProjectOptions: p,
}
downCmd := &cobra.Command{
Use: "down",
Use: "down [OPTIONS] [SERVICES]",
Short: "Stop and remove containers, networks",
PreRunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
opts.timeChanged = cmd.Flags().Changed("timeout")
@ -57,20 +57,18 @@ func downCommand(p *projectOptions, backend api.Service) *cobra.Command {
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
return runDown(ctx, backend, opts)
return runDown(ctx, dockerCli, backend, opts, args)
}),
Args: cobra.NoArgs,
ValidArgsFunction: noCompletion(),
}
flags := downCmd.Flags()
removeOrphans := utils.StringToBool(os.Getenv("COMPOSE_REMOVE_ORPHANS "))
flags.BoolVar(&opts.removeOrphans, "remove-orphans", removeOrphans, "Remove containers for services not defined in the Compose file.")
flags.IntVarP(&opts.timeout, "timeout", "t", 10, "Specify a shutdown timeout in seconds")
flags.BoolVarP(&opts.volumes, "volumes", "v", false, " Remove named volumes declared in the `volumes` section of the Compose file and anonymous volumes attached to containers.")
removeOrphans := utils.StringToBool(os.Getenv(ComposeRemoveOrphans))
flags.BoolVar(&opts.removeOrphans, "remove-orphans", removeOrphans, "Remove containers for services not defined in the Compose file")
flags.IntVarP(&opts.timeout, "timeout", "t", 0, "Specify a shutdown timeout in seconds")
flags.BoolVarP(&opts.volumes, "volumes", "v", false, `Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers`)
flags.StringVar(&opts.images, "rmi", "", `Remove images used by services. "local" remove only images that don't have a custom tag ("local"|"all")`)
flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
switch name {
case "volume":
if name == "volume" {
name = "volumes"
logrus.Warn("--volume is deprecated, please use --volumes")
}
@ -79,16 +77,10 @@ func downCommand(p *projectOptions, backend api.Service) *cobra.Command {
return downCmd
}
func runDown(ctx context.Context, backend api.Service, opts downOptions) error {
name := opts.ProjectName
var project *types.Project
if opts.ProjectName == "" {
p, err := opts.toProject(nil)
if err != nil {
return err
}
project = p
name = p.Name
func runDown(ctx context.Context, dockerCli command.Cli, backend api.Service, opts downOptions, services []string) error {
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
var timeout *time.Duration
@ -102,5 +94,6 @@ func runDown(ctx context.Context, backend api.Service, opts downOptions) error {
Timeout: timeout,
Images: opts.images,
Volumes: opts.volumes,
Services: services,
})
}

View File

@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/api"
"github.com/spf13/cobra"
@ -28,36 +29,42 @@ import (
type eventsOpts struct {
*composeOptions
json bool
json bool
since string
until string
}
func eventsCommand(p *projectOptions, backend api.Service) *cobra.Command {
func eventsCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := eventsOpts{
composeOptions: &composeOptions{
projectOptions: p,
ProjectOptions: p,
},
}
cmd := &cobra.Command{
Use: "events [options] [--] [SERVICE...]",
Short: "Receive real time events from containers.",
Use: "events [OPTIONS] [SERVICE...]",
Short: "Receive real time events from containers",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runEvents(ctx, backend, opts, args)
return runEvents(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
cmd.Flags().BoolVar(&opts.json, "json", false, "Output events as a stream of json objects")
cmd.Flags().StringVar(&opts.since, "since", "", "Show all events created since timestamp")
cmd.Flags().StringVar(&opts.until, "until", "", "Stream events until this timestamp")
return cmd
}
func runEvents(ctx context.Context, backend api.Service, opts eventsOpts, services []string) error {
project, err := opts.toProjectName()
func runEvents(ctx context.Context, dockerCli command.Cli, backend api.Service, opts eventsOpts, services []string) error {
name, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}
return backend.Events(ctx, project, api.EventsOptions{
return backend.Events(ctx, name, api.EventsOptions{
Services: services,
Since: opts.since,
Until: opts.until,
Consumer: func(event api.Event) error {
if opts.json {
marshal, err := json.Marshal(map[string]interface{}{
@ -71,9 +78,9 @@ func runEvents(ctx context.Context, backend api.Service, opts eventsOpts, servic
if err != nil {
return err
}
fmt.Println(string(marshal))
_, _ = fmt.Fprintln(dockerCli.Out(), string(marshal))
} else {
fmt.Println(event)
_, _ = fmt.Fprintln(dockerCli.Out(), event)
}
return nil
},

View File

@ -18,12 +18,16 @@ package compose
import (
"context"
"errors"
"fmt"
"os"
"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/compose"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@ -43,15 +47,15 @@ type execOpts struct {
interactive bool
}
func execCommand(p *projectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
func execCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := execOpts{
composeOptions: &composeOptions{
projectOptions: p,
ProjectOptions: p,
},
}
runCmd := &cobra.Command{
Use: "exec [options] [-e KEY=VAL...] [--] SERVICE COMMAND [ARGS...]",
Short: "Execute a command in a running container.",
Use: "exec [OPTIONS] SERVICE COMMAND [ARGS...]",
Short: "Execute a command in a running container",
Args: cobra.MinimumNArgs(2),
PreRunE: Adapt(func(ctx context.Context, args []string) error {
opts.service = args[0]
@ -59,34 +63,42 @@ func execCommand(p *projectOptions, dockerCli command.Cli, backend api.Service)
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
return runExec(ctx, backend, opts)
err := runExec(ctx, dockerCli, backend, opts)
if err != nil {
logrus.Debugf("%v", err)
var cliError cli.StatusError
if ok := errors.As(err, &cliError); ok {
os.Exit(err.(cli.StatusError).StatusCode) //nolint: errorlint
}
}
return err
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
runCmd.Flags().BoolVarP(&opts.detach, "detach", "d", false, "Detached mode: Run command in the background.")
runCmd.Flags().BoolVarP(&opts.detach, "detach", "d", false, "Detached mode: Run command in the background")
runCmd.Flags().StringArrayVarP(&opts.environment, "env", "e", []string{}, "Set environment variables")
runCmd.Flags().IntVar(&opts.index, "index", 1, "index of the container if there are multiple instances of a service [default: 1].")
runCmd.Flags().BoolVarP(&opts.privileged, "privileged", "", false, "Give extended privileges to the process.")
runCmd.Flags().StringVarP(&opts.user, "user", "u", "", "Run the command as this user.")
runCmd.Flags().IntVar(&opts.index, "index", 0, "Index of the container if service has multiple replicas")
runCmd.Flags().BoolVarP(&opts.privileged, "privileged", "", false, "Give extended privileges to the process")
runCmd.Flags().StringVarP(&opts.user, "user", "u", "", "Run the command as this user")
runCmd.Flags().BoolVarP(&opts.noTty, "no-TTY", "T", !dockerCli.Out().IsTerminal(), "Disable pseudo-TTY allocation. By default `docker compose exec` allocates a TTY.")
runCmd.Flags().StringVarP(&opts.workingDir, "workdir", "w", "", "Path to workdir directory for this command.")
runCmd.Flags().StringVarP(&opts.workingDir, "workdir", "w", "", "Path to workdir directory for this command")
runCmd.Flags().BoolVarP(&opts.interactive, "interactive", "i", true, "Keep STDIN open even if not attached.")
runCmd.Flags().BoolVarP(&opts.interactive, "interactive", "i", true, "Keep STDIN open even if not attached")
runCmd.Flags().MarkHidden("interactive") //nolint:errcheck
runCmd.Flags().BoolP("tty", "t", true, "Allocate a pseudo-TTY.")
runCmd.Flags().BoolP("tty", "t", true, "Allocate a pseudo-TTY")
runCmd.Flags().MarkHidden("tty") //nolint:errcheck
runCmd.Flags().SetInterspersed(false)
return runCmd
}
func runExec(ctx context.Context, backend api.Service, opts execOpts) error {
projectName, err := opts.toProjectName()
func runExec(ctx context.Context, dockerCli command.Cli, backend api.Service, opts execOpts) error {
projectName, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}
projectOptions, err := opts.composeOptions.toProjectOptions()
projectOptions, err := opts.composeOptions.toProjectOptions() //nolint:staticcheck
if err != nil {
return err
}
@ -109,8 +121,8 @@ func runExec(ctx context.Context, backend api.Service, opts execOpts) error {
exitCode, err := backend.Exec(ctx, projectName, execOpts)
if exitCode != 0 {
errMsg := ""
if err != nil {
errMsg := fmt.Sprintf("exit status %d", exitCode)
if err != nil && err.Error() != "" {
errMsg = err.Error()
}
return cli.StatusError{StatusCode: exitCode, Status: errMsg}

74
cmd/compose/export.go Normal file
View File

@ -0,0 +1,74 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"github.com/docker/cli/cli/command"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
)
type exportOptions struct {
*ProjectOptions
service string
output string
index int
}
func exportCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
options := exportOptions{
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "export [OPTIONS] SERVICE",
Short: "Export a service container's filesystem as a tar archive",
Args: cobra.MinimumNArgs(1),
PreRunE: Adapt(func(ctx context.Context, args []string) error {
options.service = args[0]
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
return runExport(ctx, dockerCli, backend, options)
}),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.IntVar(&options.index, "index", 0, "index of the container if service has multiple replicas.")
flags.StringVarP(&options.output, "output", "o", "", "Write to a file, instead of STDOUT")
return cmd
}
func runExport(ctx context.Context, dockerCli command.Cli, backend api.Service, options exportOptions) error {
projectName, err := options.toProjectName(ctx, dockerCli)
if err != nil {
return err
}
exportOptions := api.ExportOptions{
Service: options.service,
Index: options.index,
Output: options.output,
}
return backend.Export(ctx, projectName, exportOptions)
}

82
cmd/compose/generate.go Normal file
View File

@ -0,0 +1,82 @@
/*
Copyright 2023 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"fmt"
"os"
"github.com/docker/compose/v2/pkg/api"
"github.com/spf13/cobra"
)
type generateOptions struct {
*ProjectOptions
Format string
}
func generateCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
opts := generateOptions{
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "generate [OPTIONS] [CONTAINERS...]",
Short: "EXPERIMENTAL - Generate a Compose file from existing containers",
PreRunE: Adapt(func(ctx context.Context, args []string) error {
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
return runGenerate(ctx, backend, opts, args)
}),
}
cmd.Flags().StringVar(&opts.ProjectName, "name", "", "Project name to set in the Compose file")
cmd.Flags().StringVar(&opts.ProjectDir, "project-dir", "", "Directory to use for the project")
cmd.Flags().StringVar(&opts.Format, "format", "yaml", "Format the output. Values: [yaml | json]")
return cmd
}
func runGenerate(ctx context.Context, backend api.Service, opts generateOptions, containers []string) error {
_, _ = fmt.Fprintln(os.Stderr, "generate command is EXPERIMENTAL")
if len(containers) == 0 {
return fmt.Errorf("at least one container must be specified")
}
project, err := backend.Generate(ctx, api.GenerateOptions{
Containers: containers,
ProjectName: opts.ProjectName,
})
if err != nil {
return err
}
var content []byte
switch opts.Format {
case "json":
content, err = project.MarshalJSON()
case "yaml":
content, err = project.MarshalYAML()
default:
return fmt.Errorf("unsupported format %q", opts.Format)
}
if err != nil {
return err
}
fmt.Println(string(content))
return nil
}

View File

@ -20,42 +20,46 @@ import (
"context"
"fmt"
"io"
"os"
"sort"
"maps"
"slices"
"strings"
"time"
"github.com/containerd/platforms"
"github.com/docker/cli/cli/command"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/go-units"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/utils"
)
type imageOptions struct {
*projectOptions
Quiet bool
*ProjectOptions
Quiet bool
Format string
}
func imagesCommand(p *projectOptions, backend api.Service) *cobra.Command {
func imagesCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := imageOptions{
projectOptions: p,
ProjectOptions: p,
}
imgCmd := &cobra.Command{
Use: "images [SERVICE...]",
Use: "images [OPTIONS] [SERVICE...]",
Short: "List images used by the created containers",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runImages(ctx, backend, opts, args)
return runImages(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
imgCmd.Flags().StringVar(&opts.Format, "format", "table", "Format the output. Values: [table | json]")
imgCmd.Flags().BoolVarP(&opts.Quiet, "quiet", "q", false, "Only display IDs")
return imgCmd
}
func runImages(ctx context.Context, backend api.Service, opts imageOptions, services []string) error {
projectName, err := opts.toProjectName()
func runImages(ctx context.Context, dockerCli command.Cli, backend api.Service, opts imageOptions, services []string) error {
projectName, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}
@ -74,23 +78,55 @@ func runImages(ctx context.Context, backend api.Service, opts imageOptions, serv
if i := strings.IndexRune(img.ID, ':'); i >= 0 {
id = id[i+1:]
}
if !utils.StringContains(ids, id) {
if !slices.Contains(ids, id) {
ids = append(ids, id)
}
}
for _, img := range ids {
fmt.Println(img)
_, _ = fmt.Fprintln(dockerCli.Out(), img)
}
return nil
}
if opts.Format == "json" {
sort.Slice(images, func(i, j int) bool {
return images[i].ContainerName < images[j].ContainerName
})
type img struct {
ID string `json:"ID"`
ContainerName string `json:"ContainerName"`
Repository string `json:"Repository"`
Tag string `json:"Tag"`
Platform string `json:"Platform"`
Size int64 `json:"Size"`
LastTagTime time.Time `json:"LastTagTime"`
}
// Convert map to slice
var imageList []img
for ctr, i := range images {
lastTagTime := i.LastTagTime
if lastTagTime.IsZero() {
lastTagTime = i.Created
}
imageList = append(imageList, img{
ContainerName: ctr,
ID: i.ID,
Repository: i.Repository,
Tag: i.Tag,
Platform: platforms.Format(i.Platform),
Size: i.Size,
LastTagTime: lastTagTime,
})
}
json, err := formatter.ToJSON(imageList, "", "")
if err != nil {
return err
}
_, err = fmt.Fprintln(dockerCli.Out(), json)
return err
}
return formatter.Print(images, formatter.PRETTY, os.Stdout,
return formatter.Print(images, opts.Format, dockerCli.Out(),
func(w io.Writer) {
for _, img := range images {
for _, container := range slices.Sorted(maps.Keys(images)) {
img := images[container]
id := stringid.TruncateID(img.ID)
size := units.HumanSizeWithPrecision(float64(img.Size), 3)
repo := img.Repository
@ -101,8 +137,10 @@ func runImages(ctx context.Context, backend api.Service, opts imageOptions, serv
if tag == "" {
tag = "<none>"
}
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", img.ContainerName, repo, tag, id, size)
created := units.HumanDuration(time.Now().UTC().Sub(img.LastTagTime)) + " ago"
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
container, repo, tag, platforms.Format(img.Platform), id, size, created)
}
},
"Container", "Repository", "Tag", "Image Id", "Size")
"CONTAINER", "REPOSITORY", "TAG", "PLATFORM", "IMAGE ID", "SIZE", "CREATED")
}

View File

@ -18,45 +18,52 @@ package compose
import (
"context"
"os"
"github.com/docker/cli/cli/command"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/utils"
)
type killOptions struct {
*projectOptions
signal string
*ProjectOptions
removeOrphans bool
signal string
}
func killCommand(p *projectOptions, backend api.Service) *cobra.Command {
func killCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := killOptions{
projectOptions: p,
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "kill [options] [SERVICE...]",
Short: "Force stop service containers.",
Use: "kill [OPTIONS] [SERVICE...]",
Short: "Force stop service containers",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runKill(ctx, backend, opts, args)
return runKill(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.StringVarP(&opts.signal, "signal", "s", "SIGKILL", "SIGNAL to send to the container.")
removeOrphans := utils.StringToBool(os.Getenv(ComposeRemoveOrphans))
flags.BoolVar(&opts.removeOrphans, "remove-orphans", removeOrphans, "Remove containers for services not defined in the Compose file")
flags.StringVarP(&opts.signal, "signal", "s", "SIGKILL", "SIGNAL to send to the container")
return cmd
}
func runKill(ctx context.Context, backend api.Service, opts killOptions, services []string) error {
projectName, err := opts.toProjectName()
func runKill(ctx context.Context, dockerCli command.Cli, backend api.Service, opts killOptions, services []string) error {
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
return backend.Kill(ctx, projectName, api.KillOptions{
Services: services,
Signal: opts.signal,
return backend.Kill(ctx, name, api.KillOptions{
RemoveOrphans: opts.removeOrphans,
Project: project,
Services: services,
Signal: opts.signal,
})
}

View File

@ -20,9 +20,9 @@ import (
"context"
"fmt"
"io"
"os"
"strings"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/docker/cli/opts"
@ -38,20 +38,21 @@ type lsOptions struct {
Filter opts.FilterOpt
}
func listCommand(backend api.Service) *cobra.Command {
opts := lsOptions{Filter: opts.NewFilterOpt()}
func listCommand(dockerCli command.Cli, backend api.Service) *cobra.Command {
lsOpts := lsOptions{Filter: opts.NewFilterOpt()}
lsCmd := &cobra.Command{
Use: "ls",
Use: "ls [OPTIONS]",
Short: "List running compose projects",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runList(ctx, backend, opts)
return runList(ctx, dockerCli, backend, lsOpts)
}),
Args: cobra.NoArgs,
ValidArgsFunction: noCompletion(),
}
lsCmd.Flags().StringVar(&opts.Format, "format", "pretty", "Format the output. Values: [pretty | json].")
lsCmd.Flags().BoolVarP(&opts.Quiet, "quiet", "q", false, "Only display IDs.")
lsCmd.Flags().Var(&opts.Filter, "filter", "Filter output based on conditions provided.")
lsCmd.Flags().BoolVarP(&opts.All, "all", "a", false, "Show all stopped Compose projects")
lsCmd.Flags().StringVar(&lsOpts.Format, "format", "table", "Format the output. Values: [table | json]")
lsCmd.Flags().BoolVarP(&lsOpts.Quiet, "quiet", "q", false, "Only display project names")
lsCmd.Flags().Var(&lsOpts.Filter, "filter", "Filter output based on conditions provided")
lsCmd.Flags().BoolVarP(&lsOpts.All, "all", "a", false, "Show all stopped Compose projects")
return lsCmd
}
@ -60,23 +61,17 @@ var acceptedListFilters = map[string]bool{
"name": true,
}
func runList(ctx context.Context, backend api.Service, opts lsOptions) error {
filters := opts.Filter.Value()
func runList(ctx context.Context, dockerCli command.Cli, backend api.Service, lsOpts lsOptions) error {
filters := lsOpts.Filter.Value()
err := filters.Validate(acceptedListFilters)
if err != nil {
return err
}
stackList, err := backend.List(ctx, api.ListOptions{All: opts.All})
stackList, err := backend.List(ctx, api.ListOptions{All: lsOpts.All})
if err != nil {
return err
}
if opts.Quiet {
for _, s := range stackList {
fmt.Println(s.Name)
}
return nil
}
if filters.Len() > 0 {
var filtered []api.Stack
@ -89,8 +84,15 @@ func runList(ctx context.Context, backend api.Service, opts lsOptions) error {
stackList = filtered
}
if lsOpts.Quiet {
for _, s := range stackList {
_, _ = fmt.Fprintln(dockerCli.Out(), s.Name)
}
return nil
}
view := viewFromStackList(stackList)
return formatter.Print(view, opts.Format, os.Stdout, func(w io.Writer) {
return formatter.Print(view, lsOpts.Format, dockerCli.Out(), func(w io.Writer) {
for _, stack := range view {
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\n", stack.Name, stack.Status, stack.ConfigFiles)
}

View File

@ -18,19 +18,20 @@ package compose
import (
"context"
"os"
"github.com/docker/compose/v2/cmd/formatter"
"errors"
"github.com/docker/cli/cli/command"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/docker/compose/v2/pkg/api"
)
type logsOptions struct {
*projectOptions
*ProjectOptions
composeOptions
follow bool
index int
tail string
since string
until string
@ -39,38 +40,57 @@ type logsOptions struct {
timestamps bool
}
func logsCommand(p *projectOptions, backend api.Service) *cobra.Command {
func logsCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := logsOptions{
projectOptions: p,
ProjectOptions: p,
}
logsCmd := &cobra.Command{
Use: "logs [SERVICE...]",
Use: "logs [OPTIONS] [SERVICE...]",
Short: "View output from containers",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runLogs(ctx, backend, opts, args)
return runLogs(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
PreRunE: func(cmd *cobra.Command, args []string) error {
if opts.index > 0 && len(args) != 1 {
return errors.New("--index requires one service to be selected")
}
return nil
},
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := logsCmd.Flags()
flags.BoolVarP(&opts.follow, "follow", "f", false, "Follow log output.")
flags.BoolVarP(&opts.follow, "follow", "f", false, "Follow log output")
flags.IntVar(&opts.index, "index", 0, "index of the container if service has multiple replicas")
flags.StringVar(&opts.since, "since", "", "Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
flags.StringVar(&opts.until, "until", "", "Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
flags.BoolVar(&opts.noColor, "no-color", false, "Produce monochrome output.")
flags.BoolVar(&opts.noPrefix, "no-log-prefix", false, "Don't print prefix in logs.")
flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps.")
flags.StringVar(&opts.tail, "tail", "all", "Number of lines to show from the end of the logs for each container.")
flags.BoolVar(&opts.noColor, "no-color", false, "Produce monochrome output")
flags.BoolVar(&opts.noPrefix, "no-log-prefix", false, "Don't print prefix in logs")
flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps")
flags.StringVarP(&opts.tail, "tail", "n", "all", "Number of lines to show from the end of the logs for each container")
return logsCmd
}
func runLogs(ctx context.Context, backend api.Service, opts logsOptions, services []string) error {
projectName, err := opts.toProjectName()
func runLogs(ctx context.Context, dockerCli command.Cli, backend api.Service, opts logsOptions, services []string) error {
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
consumer := formatter.NewLogConsumer(ctx, os.Stdout, !opts.noColor, !opts.noPrefix)
return backend.Logs(ctx, projectName, consumer, api.LogOptions{
// exclude services configured to ignore output (attach: false), until explicitly selected
if project != nil && len(services) == 0 {
for n, service := range project.Services {
if service.Attach == nil || *service.Attach {
services = append(services, n)
}
}
}
consumer := formatter.NewLogConsumer(ctx, dockerCli.Out(), dockerCli.Err(), !opts.noColor, !opts.noPrefix, false)
return backend.Logs(ctx, name, consumer, api.LogOptions{
Project: project,
Services: services,
Follow: opts.follow,
Index: opts.index,
Tail: opts.tail,
Since: opts.since,
Until: opts.until,

291
cmd/compose/options.go Normal file
View File

@ -0,0 +1,291 @@
/*
Copyright 2023 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"fmt"
"io"
"os"
"slices"
"sort"
"strings"
"text/tabwriter"
"github.com/compose-spec/compose-go/v2/cli"
"github.com/compose-spec/compose-go/v2/template"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/internal/tracing"
ui "github.com/docker/compose/v2/pkg/progress"
"github.com/docker/compose/v2/pkg/prompt"
)
func applyPlatforms(project *types.Project, buildForSinglePlatform bool) error {
defaultPlatform := project.Environment["DOCKER_DEFAULT_PLATFORM"]
for name, service := range project.Services {
if service.Build == nil {
continue
}
// default platform only applies if the service doesn't specify
if defaultPlatform != "" && service.Platform == "" {
if len(service.Build.Platforms) > 0 && !slices.Contains(service.Build.Platforms, defaultPlatform) {
return fmt.Errorf("service %q build.platforms does not support value set by DOCKER_DEFAULT_PLATFORM: %s", name, defaultPlatform)
}
service.Platform = defaultPlatform
}
if service.Platform != "" {
if len(service.Build.Platforms) > 0 {
if !slices.Contains(service.Build.Platforms, service.Platform) {
return fmt.Errorf("service %q build configuration does not support platform: %s", name, service.Platform)
}
}
if buildForSinglePlatform || len(service.Build.Platforms) == 0 {
// if we're building for a single platform, we want to build for the platform we'll use to run the image
// similarly, if no build platforms were explicitly specified, it makes sense to build for the platform
// the image is designed for rather than allowing the builder to infer the platform
service.Build.Platforms = []string{service.Platform}
}
}
// services can specify that they should be built for multiple platforms, which can be used
// with `docker compose build` to produce a multi-arch image
// other cases, such as `up` and `run`, need a single architecture to actually run
// if there is only a single platform present (which might have been inferred
// from service.Platform above), it will be used, even if it requires emulation.
// if there's more than one platform, then the list is cleared so that the builder
// can decide.
// TODO(milas): there's no validation that the platform the builder will pick is actually one
// of the supported platforms from the build definition
// e.g. `build.platforms: [linux/arm64, linux/amd64]` on a `linux/ppc64` machine would build
// for `linux/ppc64` instead of returning an error that it's not a valid platform for the service.
if buildForSinglePlatform && len(service.Build.Platforms) > 1 {
// empty indicates that the builder gets to decide
service.Build.Platforms = nil
}
project.Services[name] = service
}
return nil
}
// isRemoteConfig checks if the main compose file is from a remote source (OCI or Git)
func isRemoteConfig(dockerCli command.Cli, options buildOptions) bool {
if len(options.ConfigPaths) == 0 {
return false
}
remoteLoaders := options.remoteLoaders(dockerCli)
for _, loader := range remoteLoaders {
if loader.Accept(options.ConfigPaths[0]) {
return true
}
}
return false
}
// checksForRemoteStack handles environment variable prompts for remote configurations
func checksForRemoteStack(ctx context.Context, dockerCli command.Cli, project *types.Project, options buildOptions, assumeYes bool, cmdEnvs []string) error {
if !isRemoteConfig(dockerCli, options) {
return nil
}
if metrics, ok := ctx.Value(tracing.MetricsKey{}).(tracing.Metrics); ok && metrics.CountIncludesRemote > 0 {
if err := confirmRemoteIncludes(dockerCli, options, assumeYes); err != nil {
return err
}
}
displayLocationRemoteStack(dockerCli, project, options)
return promptForInterpolatedVariables(ctx, dockerCli, options.ProjectOptions, assumeYes, cmdEnvs)
}
// Prepare the values map and collect all variables info
type varInfo struct {
name string
value string
source string
required bool
defaultValue string
}
// promptForInterpolatedVariables displays all variables and their values at once,
// then prompts for confirmation
func promptForInterpolatedVariables(ctx context.Context, dockerCli command.Cli, projectOptions *ProjectOptions, assumeYes bool, cmdEnvs []string) error {
if assumeYes {
return nil
}
varsInfo, noVariables, err := extractInterpolationVariablesFromModel(ctx, dockerCli, projectOptions, cmdEnvs)
if err != nil {
return err
}
if noVariables {
return nil
}
displayInterpolationVariables(dockerCli.Out(), varsInfo)
// Prompt for confirmation
userInput := prompt.NewPrompt(dockerCli.In(), dockerCli.Out())
msg := "\nDo you want to proceed with these variables? [Y/n]: "
confirmed, err := userInput.Confirm(msg, true)
if err != nil {
return err
}
if !confirmed {
return fmt.Errorf("operation cancelled by user")
}
return nil
}
func extractInterpolationVariablesFromModel(ctx context.Context, dockerCli command.Cli, projectOptions *ProjectOptions, cmdEnvs []string) ([]varInfo, bool, error) {
cmdEnvMap := extractEnvCLIDefined(cmdEnvs)
// Create a model without interpolation to extract variables
opts := configOptions{
noInterpolate: true,
ProjectOptions: projectOptions,
}
model, err := opts.ToModel(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
if err != nil {
return nil, false, err
}
// Extract variables that need interpolation
variables := template.ExtractVariables(model, template.DefaultPattern)
if len(variables) == 0 {
return nil, true, nil
}
var varsInfo []varInfo
proposedValues := make(map[string]string)
for name, variable := range variables {
info := varInfo{
name: name,
required: variable.Required,
defaultValue: variable.DefaultValue,
}
// Determine value and source based on priority
if value, exists := cmdEnvMap[name]; exists {
info.value = value
info.source = "command-line"
proposedValues[name] = value
} else if value, exists := os.LookupEnv(name); exists {
info.value = value
info.source = "environment"
proposedValues[name] = value
} else if variable.DefaultValue != "" {
info.value = variable.DefaultValue
info.source = "compose file"
proposedValues[name] = variable.DefaultValue
} else {
info.value = "<unset>"
info.source = "none"
}
varsInfo = append(varsInfo, info)
}
return varsInfo, false, nil
}
func extractEnvCLIDefined(cmdEnvs []string) map[string]string {
// Parse command-line environment variables
cmdEnvMap := make(map[string]string)
for _, env := range cmdEnvs {
parts := strings.SplitN(env, "=", 2)
if len(parts) == 2 {
cmdEnvMap[parts[0]] = parts[1]
}
}
return cmdEnvMap
}
func displayInterpolationVariables(writer io.Writer, varsInfo []varInfo) {
// Display all variables in a table format
_, _ = fmt.Fprintln(writer, "\nFound the following variables in configuration:")
w := tabwriter.NewWriter(writer, 0, 0, 3, ' ', 0)
_, _ = fmt.Fprintln(w, "VARIABLE\tVALUE\tSOURCE\tREQUIRED\tDEFAULT")
sort.Slice(varsInfo, func(a, b int) bool {
return varsInfo[a].name < varsInfo[b].name
})
for _, info := range varsInfo {
required := "no"
if info.required {
required = "yes"
}
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n",
info.name,
info.value,
info.source,
required,
info.defaultValue,
)
}
_ = w.Flush()
}
func displayLocationRemoteStack(dockerCli command.Cli, project *types.Project, options buildOptions) {
mainComposeFile := options.ProjectOptions.ConfigPaths[0] //nolint:staticcheck
if ui.Mode != ui.ModeQuiet && ui.Mode != ui.ModeJSON {
_, _ = fmt.Fprintf(dockerCli.Out(), "Your compose stack %q is stored in %q\n", mainComposeFile, project.WorkingDir)
}
}
func confirmRemoteIncludes(dockerCli command.Cli, options buildOptions, assumeYes bool) error {
if assumeYes {
return nil
}
var remoteIncludes []string
remoteLoaders := options.ProjectOptions.remoteLoaders(dockerCli) //nolint:staticcheck
for _, cf := range options.ProjectOptions.ConfigPaths { //nolint:staticcheck
for _, loader := range remoteLoaders {
if loader.Accept(cf) {
remoteIncludes = append(remoteIncludes, cf)
break
}
}
}
if len(remoteIncludes) == 0 {
return nil
}
_, _ = fmt.Fprintln(dockerCli.Out(), "\nWarning: This Compose project includes files from remote sources:")
for _, include := range remoteIncludes {
_, _ = fmt.Fprintf(dockerCli.Out(), " - %s\n", include)
}
_, _ = fmt.Fprintln(dockerCli.Out(), "\nRemote includes could potentially be malicious. Make sure you trust the source.")
msg := "Do you want to continue? [y/N]: "
confirmed, err := prompt.NewPrompt(dockerCli.In(), dockerCli.Out()).Confirm(msg, false)
if err != nil {
return err
}
if !confirmed {
return fmt.Errorf("operation cancelled by user")
}
return nil
}

394
cmd/compose/options_test.go Normal file
View File

@ -0,0 +1,394 @@
/*
Copyright 2023 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"bytes"
"context"
"fmt"
"io"
"os"
"path/filepath"
"strings"
"testing"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/streams"
"github.com/docker/compose/v2/pkg/mocks"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
func TestApplyPlatforms_InferFromRuntime(t *testing.T) {
makeProject := func() *types.Project {
return &types.Project{
Services: types.Services{
"test": {
Name: "test",
Image: "foo",
Build: &types.BuildConfig{
Context: ".",
Platforms: []string{
"linux/amd64",
"linux/arm64",
"alice/32",
},
},
Platform: "alice/32",
},
},
}
}
t.Run("SinglePlatform", func(t *testing.T) {
project := makeProject()
require.NoError(t, applyPlatforms(project, true))
require.EqualValues(t, []string{"alice/32"}, project.Services["test"].Build.Platforms)
})
t.Run("MultiPlatform", func(t *testing.T) {
project := makeProject()
require.NoError(t, applyPlatforms(project, false))
require.EqualValues(t, []string{"linux/amd64", "linux/arm64", "alice/32"},
project.Services["test"].Build.Platforms)
})
}
func TestApplyPlatforms_DockerDefaultPlatform(t *testing.T) {
makeProject := func() *types.Project {
return &types.Project{
Environment: map[string]string{
"DOCKER_DEFAULT_PLATFORM": "linux/amd64",
},
Services: types.Services{
"test": {
Name: "test",
Image: "foo",
Build: &types.BuildConfig{
Context: ".",
Platforms: []string{
"linux/amd64",
"linux/arm64",
},
},
},
},
}
}
t.Run("SinglePlatform", func(t *testing.T) {
project := makeProject()
require.NoError(t, applyPlatforms(project, true))
require.EqualValues(t, []string{"linux/amd64"}, project.Services["test"].Build.Platforms)
})
t.Run("MultiPlatform", func(t *testing.T) {
project := makeProject()
require.NoError(t, applyPlatforms(project, false))
require.EqualValues(t, []string{"linux/amd64", "linux/arm64"},
project.Services["test"].Build.Platforms)
})
}
func TestApplyPlatforms_UnsupportedPlatform(t *testing.T) {
makeProject := func() *types.Project {
return &types.Project{
Environment: map[string]string{
"DOCKER_DEFAULT_PLATFORM": "commodore/64",
},
Services: types.Services{
"test": {
Name: "test",
Image: "foo",
Build: &types.BuildConfig{
Context: ".",
Platforms: []string{
"linux/amd64",
"linux/arm64",
},
},
},
},
}
}
t.Run("SinglePlatform", func(t *testing.T) {
project := makeProject()
require.EqualError(t, applyPlatforms(project, true),
`service "test" build.platforms does not support value set by DOCKER_DEFAULT_PLATFORM: commodore/64`)
})
t.Run("MultiPlatform", func(t *testing.T) {
project := makeProject()
require.EqualError(t, applyPlatforms(project, false),
`service "test" build.platforms does not support value set by DOCKER_DEFAULT_PLATFORM: commodore/64`)
})
}
func TestIsRemoteConfig(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
cli := mocks.NewMockCli(ctrl)
tests := []struct {
name string
configPaths []string
want bool
}{
{
name: "empty config paths",
configPaths: []string{},
want: false,
},
{
name: "local file",
configPaths: []string{"docker-compose.yaml"},
want: false,
},
{
name: "OCI reference",
configPaths: []string{"oci://registry.example.com/stack:latest"},
want: true,
},
{
name: "GIT reference",
configPaths: []string{"git://github.com/user/repo.git"},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
opts := buildOptions{
ProjectOptions: &ProjectOptions{
ConfigPaths: tt.configPaths,
},
}
got := isRemoteConfig(cli, opts)
require.Equal(t, tt.want, got)
})
}
}
func TestDisplayLocationRemoteStack(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
cli := mocks.NewMockCli(ctrl)
buf := new(bytes.Buffer)
cli.EXPECT().Out().Return(streams.NewOut(buf)).AnyTimes()
project := &types.Project{
Name: "test-project",
WorkingDir: "/tmp/test",
}
options := buildOptions{
ProjectOptions: &ProjectOptions{
ConfigPaths: []string{"oci://registry.example.com/stack:latest"},
},
}
displayLocationRemoteStack(cli, project, options)
output := buf.String()
require.Equal(t, output, fmt.Sprintf("Your compose stack %q is stored in %q\n", "oci://registry.example.com/stack:latest", "/tmp/test"))
}
func TestDisplayInterpolationVariables(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
// Create a temporary directory for the test
tmpDir, err := os.MkdirTemp("", "compose-test")
require.NoError(t, err)
defer func() { _ = os.RemoveAll(tmpDir) }()
// Create a temporary compose file
composeContent := `
services:
app:
image: nginx
environment:
- TEST_VAR=${TEST_VAR:?required} # required with default
- API_KEY=${API_KEY:?} # required without default
- DEBUG=${DEBUG:-true} # optional with default
- UNSET_VAR # optional without default
`
composePath := filepath.Join(tmpDir, "docker-compose.yml")
err = os.WriteFile(composePath, []byte(composeContent), 0o644)
require.NoError(t, err)
buf := new(bytes.Buffer)
cli := mocks.NewMockCli(ctrl)
cli.EXPECT().Out().Return(streams.NewOut(buf)).AnyTimes()
// Create ProjectOptions with the temporary compose file
projectOptions := &ProjectOptions{
ConfigPaths: []string{composePath},
}
// Set up the context with necessary environment variables
ctx := context.Background()
_ = os.Setenv("TEST_VAR", "test-value")
_ = os.Setenv("API_KEY", "123456")
defer func() {
_ = os.Unsetenv("TEST_VAR")
_ = os.Unsetenv("API_KEY")
}()
// Extract variables from the model
info, noVariables, err := extractInterpolationVariablesFromModel(ctx, cli, projectOptions, []string{})
require.NoError(t, err)
require.False(t, noVariables)
// Display the variables
displayInterpolationVariables(cli.Out(), info)
// Expected output format with proper spacing
expected := "\nFound the following variables in configuration:\n" +
"VARIABLE VALUE SOURCE REQUIRED DEFAULT\n" +
"API_KEY 123456 environment yes \n" +
"DEBUG true compose file no true\n" +
"TEST_VAR test-value environment yes \n"
// Normalize spaces and newlines for comparison
normalizeSpaces := func(s string) string {
// Replace multiple spaces with a single space
s = strings.Join(strings.Fields(strings.TrimSpace(s)), " ")
return s
}
actualOutput := buf.String()
// Compare normalized strings
require.Equal(t,
normalizeSpaces(expected),
normalizeSpaces(actualOutput),
"\nExpected:\n%s\nGot:\n%s", expected, actualOutput)
}
func TestConfirmRemoteIncludes(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
cli := mocks.NewMockCli(ctrl)
tests := []struct {
name string
opts buildOptions
assumeYes bool
userInput string
wantErr bool
errMessage string
wantPrompt bool
wantOutput string
}{
{
name: "no remote includes",
opts: buildOptions{
ProjectOptions: &ProjectOptions{
ConfigPaths: []string{
"docker-compose.yaml",
"./local/path/compose.yaml",
},
},
},
assumeYes: false,
wantErr: false,
wantPrompt: false,
},
{
name: "assume yes with remote includes",
opts: buildOptions{
ProjectOptions: &ProjectOptions{
ConfigPaths: []string{
"oci://registry.example.com/stack:latest",
"git://github.com/user/repo.git",
},
},
},
assumeYes: true,
wantErr: false,
wantPrompt: false,
},
{
name: "user confirms remote includes",
opts: buildOptions{
ProjectOptions: &ProjectOptions{
ConfigPaths: []string{
"oci://registry.example.com/stack:latest",
"git://github.com/user/repo.git",
},
},
},
assumeYes: false,
userInput: "y\n",
wantErr: false,
wantPrompt: true,
wantOutput: "\nWarning: This Compose project includes files from remote sources:\n" +
" - oci://registry.example.com/stack:latest\n" +
" - git://github.com/user/repo.git\n" +
"\nRemote includes could potentially be malicious. Make sure you trust the source.\n" +
"Do you want to continue? [y/N]: ",
},
{
name: "user rejects remote includes",
opts: buildOptions{
ProjectOptions: &ProjectOptions{
ConfigPaths: []string{
"oci://registry.example.com/stack:latest",
},
},
},
assumeYes: false,
userInput: "n\n",
wantErr: true,
errMessage: "operation cancelled by user",
wantPrompt: true,
wantOutput: "\nWarning: This Compose project includes files from remote sources:\n" +
" - oci://registry.example.com/stack:latest\n" +
"\nRemote includes could potentially be malicious. Make sure you trust the source.\n" +
"Do you want to continue? [y/N]: ",
},
}
buf := new(bytes.Buffer)
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cli.EXPECT().Out().Return(streams.NewOut(buf)).AnyTimes()
if tt.wantPrompt {
inbuf := io.NopCloser(bytes.NewBufferString(tt.userInput))
cli.EXPECT().In().Return(streams.NewIn(inbuf)).AnyTimes()
}
err := confirmRemoteIncludes(cli, tt.opts, tt.assumeYes)
if tt.wantErr {
require.Error(t, err)
require.Equal(t, tt.errMessage, err.Error())
} else {
require.NoError(t, err)
}
if tt.wantOutput != "" {
require.Equal(t, tt.wantOutput, buf.String())
}
buf.Reset()
})
}
}

View File

@ -19,67 +19,70 @@ package compose
import (
"context"
"github.com/docker/cli/cli/command"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
)
type pauseOptions struct {
*projectOptions
*ProjectOptions
}
func pauseCommand(p *projectOptions, backend api.Service) *cobra.Command {
func pauseCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := pauseOptions{
projectOptions: p,
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "pause [SERVICE...]",
Short: "Pause services",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runPause(ctx, backend, opts, args)
return runPause(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
return cmd
}
func runPause(ctx context.Context, backend api.Service, opts pauseOptions, services []string) error {
project, err := opts.toProjectName()
func runPause(ctx context.Context, dockerCli command.Cli, backend api.Service, opts pauseOptions, services []string) error {
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
return backend.Pause(ctx, project, api.PauseOptions{
return backend.Pause(ctx, name, api.PauseOptions{
Services: services,
Project: project,
})
}
type unpauseOptions struct {
*projectOptions
*ProjectOptions
}
func unpauseCommand(p *projectOptions, backend api.Service) *cobra.Command {
func unpauseCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := unpauseOptions{
projectOptions: p,
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "unpause [SERVICE...]",
Short: "Unpause services",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runUnPause(ctx, backend, opts, args)
return runUnPause(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
return cmd
}
func runUnPause(ctx context.Context, backend api.Service, opts unpauseOptions, services []string) error {
project, err := opts.toProjectName()
func runUnPause(ctx context.Context, dockerCli command.Cli, backend api.Service, opts unpauseOptions, services []string) error {
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
return backend.UnPause(ctx, project, api.PauseOptions{
return backend.UnPause(ctx, name, api.PauseOptions{
Services: services,
Project: project,
})
}

View File

@ -20,47 +20,50 @@ import (
"context"
"fmt"
"strconv"
"strings"
"github.com/docker/cli/cli/command"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
)
type portOptions struct {
*projectOptions
port int
*ProjectOptions
port uint16
protocol string
index int
}
func portCommand(p *projectOptions, backend api.Service) *cobra.Command {
func portCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := portOptions{
projectOptions: p,
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "port [options] [--] SERVICE PRIVATE_PORT",
Short: "Print the public port for a port binding.",
Use: "port [OPTIONS] SERVICE PRIVATE_PORT",
Short: "Print the public port for a port binding",
Args: cobra.MinimumNArgs(2),
PreRunE: Adapt(func(ctx context.Context, args []string) error {
port, err := strconv.Atoi(args[1])
port, err := strconv.ParseUint(args[1], 10, 16)
if err != nil {
return err
}
opts.port = port
opts.port = uint16(port)
opts.protocol = strings.ToLower(opts.protocol)
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
return runPort(ctx, backend, opts, args[0])
return runPort(ctx, dockerCli, backend, opts, args[0])
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
cmd.Flags().StringVar(&opts.protocol, "protocol", "tcp", "tcp or udp")
cmd.Flags().IntVar(&opts.index, "index", 1, "index of the container if service has multiple replicas")
cmd.Flags().IntVar(&opts.index, "index", 0, "Index of the container if service has multiple replicas")
return cmd
}
func runPort(ctx context.Context, backend api.Service, opts portOptions, service string) error {
projectName, err := opts.toProjectName()
func runPort(ctx context.Context, dockerCli command.Cli, backend api.Service, opts portOptions, service string) error {
projectName, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}
@ -72,6 +75,6 @@ func runPort(ctx context.Context, backend api.Service, opts portOptions, service
return err
}
fmt.Printf("%s:%d\n", ip, port)
_, _ = fmt.Fprintf(dockerCli.Out(), "%s:%d\n", ip, port)
return nil
}

View File

@ -18,31 +18,31 @@ package compose
import (
"context"
"errors"
"fmt"
"io"
"os"
"slices"
"sort"
"strconv"
"strings"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/docker/compose/v2/pkg/utils"
formatter2 "github.com/docker/cli/cli/command/formatter"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/cli/cli/command"
cliformatter "github.com/docker/cli/cli/command/formatter"
cliflags "github.com/docker/cli/cli/flags"
"github.com/spf13/cobra"
)
type psOptions struct {
*projectOptions
*ProjectOptions
Format string
All bool
Quiet bool
Services bool
Filter string
Status []string
noTrunc bool
Orphans bool
}
func (p *psOptions) parseFilter() error {
@ -64,54 +64,62 @@ func (p *psOptions) parseFilter() error {
return nil
}
func psCommand(p *projectOptions, backend api.Service) *cobra.Command {
func psCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := psOptions{
projectOptions: p,
ProjectOptions: p,
}
psCmd := &cobra.Command{
Use: "ps [SERVICE...]",
Use: "ps [OPTIONS] [SERVICE...]",
Short: "List containers",
PreRunE: func(cmd *cobra.Command, args []string) error {
return opts.parseFilter()
},
RunE: Adapt(func(ctx context.Context, args []string) error {
return runPs(ctx, backend, args, opts)
return runPs(ctx, dockerCli, backend, args, opts)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := psCmd.Flags()
flags.StringVar(&opts.Format, "format", "pretty", "Format the output. Values: [pretty | json]")
flags.StringVar(&opts.Filter, "filter", "", "Filter services by a property (supported filters: status).")
flags.StringVar(&opts.Format, "format", "table", cliflags.FormatHelp)
flags.StringVar(&opts.Filter, "filter", "", "Filter services by a property (supported filters: status)")
flags.StringArrayVar(&opts.Status, "status", []string{}, "Filter services by status. Values: [paused | restarting | removing | running | dead | created | exited]")
flags.BoolVarP(&opts.Quiet, "quiet", "q", false, "Only display IDs")
flags.BoolVar(&opts.Services, "services", false, "Display services")
flags.BoolVar(&opts.Orphans, "orphans", true, "Include orphaned services (not declared by project)")
flags.BoolVarP(&opts.All, "all", "a", false, "Show all stopped containers (including those created by the run command)")
flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Don't truncate output")
return psCmd
}
func runPs(ctx context.Context, backend api.Service, services []string, opts psOptions) error {
projectName, err := opts.toProjectName()
func runPs(ctx context.Context, dockerCli command.Cli, backend api.Service, services []string, opts psOptions) error {
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
containers, err := backend.Ps(ctx, projectName, api.PsOptions{
All: opts.All,
if project != nil {
names := project.ServiceNames()
if len(services) > 0 {
for _, service := range services {
if !slices.Contains(names, service) {
return fmt.Errorf("no such service: %s", service)
}
}
} else if !opts.Orphans {
// until user asks to list orphaned services, we only include those declared in project
services = names
}
}
containers, err := backend.Ps(ctx, name, api.PsOptions{
Project: project,
All: opts.All || len(opts.Status) != 0,
Services: services,
})
if err != nil {
return err
}
SERVICES:
for _, s := range services {
for _, c := range containers {
if c.Service == s {
continue SERVICES
}
}
return fmt.Errorf("no such service: %s", s)
}
if len(opts.Status) != 0 {
containers = filterByStatus(containers, opts.Status)
}
@ -122,41 +130,33 @@ SERVICES:
if opts.Quiet {
for _, c := range containers {
fmt.Println(c.ID)
_, _ = fmt.Fprintln(dockerCli.Out(), c.ID)
}
return nil
}
if opts.Services {
services := []string{}
for _, s := range containers {
if !utils.StringContains(services, s.Service) {
services = append(services, s.Service)
for _, c := range containers {
s := c.Service
if !slices.Contains(services, s) {
services = append(services, s)
}
}
fmt.Println(strings.Join(services, "\n"))
_, _ = fmt.Fprintln(dockerCli.Out(), strings.Join(services, "\n"))
return nil
}
return formatter.Print(containers, opts.Format, os.Stdout,
writter(containers),
"NAME", "COMMAND", "SERVICE", "STATUS", "PORTS")
}
func writter(containers []api.ContainerSummary) func(w io.Writer) {
return func(w io.Writer) {
for _, container := range containers {
ports := DisplayablePorts(container)
status := container.State
if status == "running" && container.Health != "" {
status = fmt.Sprintf("%s (%s)", container.State, container.Health)
} else if status == "exited" || status == "dead" {
status = fmt.Sprintf("%s (%d)", container.State, container.ExitCode)
}
command := formatter2.Ellipsis(container.Command, 20)
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", container.Name, strconv.Quote(command), container.Service, status, ports)
}
if opts.Format == "" {
opts.Format = dockerCli.ConfigFile().PsFormat
}
containerCtx := cliformatter.Context{
Output: dockerCli.Out(),
Format: formatter.NewContainerFormat(opts.Format, opts.Quiet, false),
Trunc: !opts.noTrunc,
}
return formatter.ContainerWrite(containerCtx, containers)
}
func filterByStatus(containers []api.ContainerSummary, statuses []string) []api.ContainerSummary {
@ -177,73 +177,3 @@ func hasStatus(c api.ContainerSummary, statuses []string) bool {
}
return false
}
type portRange struct {
pStart int
pEnd int
tStart int
tEnd int
IP string
protocol string
}
func (pr portRange) String() string {
var (
pub string
tgt string
)
if pr.pEnd > pr.pStart {
pub = fmt.Sprintf("%s:%d-%d->", pr.IP, pr.pStart, pr.pEnd)
} else if pr.pStart > 0 {
pub = fmt.Sprintf("%s:%d->", pr.IP, pr.pStart)
}
if pr.tEnd > pr.tStart {
tgt = fmt.Sprintf("%d-%d", pr.tStart, pr.tEnd)
} else {
tgt = fmt.Sprintf("%d", pr.tStart)
}
return fmt.Sprintf("%s%s/%s", pub, tgt, pr.protocol)
}
// DisplayablePorts is copy pasted from https://github.com/docker/cli/pull/581/files
func DisplayablePorts(c api.ContainerSummary) string {
if c.Publishers == nil {
return ""
}
sort.Sort(c.Publishers)
pr := portRange{}
ports := []string{}
for _, p := range c.Publishers {
prIsRange := pr.tEnd != pr.tStart
tOverlaps := p.TargetPort <= pr.tEnd
// Start a new port-range if:
// - the protocol is different from the current port-range
// - published or target port are not consecutive to the current port-range
// - the current port-range is a _range_, and the target port overlaps with the current range's target-ports
if p.Protocol != pr.protocol || p.URL != pr.IP || p.PublishedPort-pr.pEnd > 1 || p.TargetPort-pr.tEnd > 1 || prIsRange && tOverlaps {
// start a new port-range, and print the previous port-range (if any)
if pr.pStart > 0 {
ports = append(ports, pr.String())
}
pr = portRange{
pStart: p.PublishedPort,
pEnd: p.PublishedPort,
tStart: p.TargetPort,
tEnd: p.TargetPort,
protocol: p.Protocol,
IP: p.URL,
}
continue
}
pr.pEnd = p.PublishedPort
pr.tEnd = p.TargetPort
}
if pr.tStart > 0 {
ports = append(ports, pr.String())
}
return strings.Join(ports, ", ")
}

87
cmd/compose/ps_test.go Normal file
View File

@ -0,0 +1,87 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"os"
"path/filepath"
"testing"
"github.com/docker/cli/cli/config/configfile"
"github.com/docker/cli/cli/streams"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/mocks"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
func TestPsTable(t *testing.T) {
ctx := context.Background()
dir := t.TempDir()
out := filepath.Join(dir, "output.txt")
f, err := os.Create(out)
if err != nil {
t.Fatal("could not create output file")
}
defer func() { _ = f.Close() }()
ctrl := gomock.NewController(t)
defer ctrl.Finish()
backend := mocks.NewMockService(ctrl)
backend.EXPECT().
Ps(gomock.Eq(ctx), gomock.Any(), gomock.Any()).
DoAndReturn(func(ctx context.Context, projectName string, options api.PsOptions) ([]api.ContainerSummary, error) {
return []api.ContainerSummary{
{
ID: "abc123",
Name: "ABC",
Image: "foo/bar",
Publishers: api.PortPublishers{
{
TargetPort: 8080,
PublishedPort: 8080,
Protocol: "tcp",
},
{
TargetPort: 8443,
PublishedPort: 8443,
Protocol: "tcp",
},
},
},
}, nil
}).AnyTimes()
opts := psOptions{ProjectOptions: &ProjectOptions{ProjectName: "test"}}
stdout := streams.NewOut(f)
cli := mocks.NewMockCli(ctrl)
cli.EXPECT().Out().Return(stdout).AnyTimes()
cli.EXPECT().ConfigFile().Return(&configfile.ConfigFile{}).AnyTimes()
err = runPs(ctx, cli, backend, nil, opts)
require.NoError(t, err)
_, err = f.Seek(0, 0)
require.NoError(t, err)
output, err := os.ReadFile(out)
require.NoError(t, err)
assert.Contains(t, string(output), "8080/tcp, 8443/tcp")
}

84
cmd/compose/publish.go Normal file
View File

@ -0,0 +1,84 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"errors"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/api"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
type publishOptions struct {
*ProjectOptions
resolveImageDigests bool
ociVersion string
withEnvironment bool
assumeYes bool
}
func publishCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := publishOptions{
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "publish [OPTIONS] REPOSITORY[:TAG]",
Short: "Publish compose application",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runPublish(ctx, dockerCli, backend, opts, args[0])
}),
Args: cli.ExactArgs(1),
}
flags := cmd.Flags()
flags.BoolVar(&opts.resolveImageDigests, "resolve-image-digests", false, "Pin image tags to digests")
flags.StringVar(&opts.ociVersion, "oci-version", "", "OCI image/artifact specification version (automatically determined by default)")
flags.BoolVar(&opts.withEnvironment, "with-env", false, "Include environment variables in the published OCI artifact")
flags.BoolVarP(&opts.assumeYes, "yes", "y", false, `Assume "yes" as answer to all prompts`)
flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
// assumeYes was introduced by mistake as `--y`
if name == "y" {
logrus.Warn("--y is deprecated, please use --yes instead")
name = "yes"
}
return pflag.NormalizedName(name)
})
return cmd
}
func runPublish(ctx context.Context, dockerCli command.Cli, backend api.Service, opts publishOptions, repository string) error {
project, metrics, err := opts.ToProject(ctx, dockerCli, nil)
if err != nil {
return err
}
if metrics.CountIncludesLocal > 0 {
return errors.New("cannot publish compose file with local includes")
}
return backend.Publish(ctx, project, repository, api.PublishOptions{
ResolveImageDigests: opts.resolveImageDigests,
OCIVersion: api.OCIVersion(opts.ociVersion),
WithEnvironment: opts.withEnvironment,
AssumeYes: opts.assumeYes,
})
}

View File

@ -21,73 +21,96 @@ import (
"fmt"
"os"
"github.com/compose-spec/compose-go/v2/cli"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
"github.com/morikuni/aec"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/utils"
)
type pullOptions struct {
*projectOptions
*ProjectOptions
composeOptions
quiet bool
parallel bool
noParallel bool
includeDeps bool
ignorePullFailures bool
noBuildable bool
policy string
}
func pullCommand(p *projectOptions, backend api.Service) *cobra.Command {
func pullCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := pullOptions{
projectOptions: p,
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "pull [SERVICE...]",
Use: "pull [OPTIONS] [SERVICE...]",
Short: "Pull service images",
PreRunE: Adapt(func(ctx context.Context, args []string) error {
if opts.noParallel {
PreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("no-parallel") {
fmt.Fprint(os.Stderr, aec.Apply("option '--no-parallel' is DEPRECATED and will be ignored.\n", aec.RedF))
}
if cmd.Flags().Changed("parallel") {
fmt.Fprint(os.Stderr, aec.Apply("option '--parallel' is DEPRECATED and will be ignored.\n", aec.RedF))
}
return nil
}),
},
RunE: Adapt(func(ctx context.Context, args []string) error {
return runPull(ctx, backend, opts, args)
return runPull(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Pull without printing progress information")
cmd.Flags().BoolVar(&opts.includeDeps, "include-deps", false, "Also pull services declared as dependencies")
cmd.Flags().BoolVar(&opts.parallel, "parallel", true, "DEPRECATED pull multiple images in parallel.")
cmd.Flags().BoolVar(&opts.parallel, "parallel", true, "DEPRECATED pull multiple images in parallel")
flags.MarkHidden("parallel") //nolint:errcheck
cmd.Flags().BoolVar(&opts.parallel, "no-parallel", true, "DEPRECATED disable parallel pulling.")
cmd.Flags().BoolVar(&opts.noParallel, "no-parallel", true, "DEPRECATED disable parallel pulling")
flags.MarkHidden("no-parallel") //nolint:errcheck
cmd.Flags().BoolVar(&opts.ignorePullFailures, "ignore-pull-failures", false, "Pull what it can and ignores images with pull failures")
cmd.Flags().BoolVar(&opts.noBuildable, "ignore-buildable", false, "Ignore images that can be built")
cmd.Flags().StringVar(&opts.policy, "policy", "", `Apply pull policy ("missing"|"always")`)
return cmd
}
func runPull(ctx context.Context, backend api.Service, opts pullOptions, services []string) error {
project, err := opts.toProject(services)
func (opts pullOptions) apply(project *types.Project, services []string) (*types.Project, error) {
if !opts.includeDeps {
var err error
project, err = project.WithSelectedServices(services, types.IgnoreDependencies)
if err != nil {
return nil, err
}
}
if opts.policy != "" {
for i, service := range project.Services {
if service.Image == "" {
continue
}
service.PullPolicy = opts.policy
project.Services[i] = service
}
}
return project, nil
}
func runPull(ctx context.Context, dockerCli command.Cli, backend api.Service, opts pullOptions, services []string) error {
project, _, err := opts.ToProject(ctx, dockerCli, services, cli.WithoutEnvironmentResolution)
if err != nil {
return err
}
if !opts.includeDeps {
enabled, err := project.GetServices(services...)
if err != nil {
return err
}
for _, s := range project.Services {
if !utils.StringContains(services, s.Name) {
project.DisabledServices = append(project.DisabledServices, s)
}
}
project.Services = enabled
project, err = opts.apply(project, services)
if err != nil {
return err
}
return backend.Pull(ctx, project, api.PullOptions{
Quiet: opts.quiet,
IgnoreFailures: opts.ignorePullFailures,
Quiet: opts.quiet,
IgnoreFailures: opts.ignorePullFailures,
IgnoreBuildable: opts.noBuildable,
})
}

View File

@ -0,0 +1,57 @@
/*
Copyright 2023 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"testing"
"github.com/compose-spec/compose-go/v2/types"
"gotest.tools/v3/assert"
)
func TestApplyPullOptions(t *testing.T) {
project := &types.Project{
Services: types.Services{
"must-build": {
Name: "must-build",
// No image, local build only
Build: &types.BuildConfig{
Context: ".",
},
},
"has-build": {
Name: "has-build",
Image: "registry.example.com/myservice",
Build: &types.BuildConfig{
Context: ".",
},
},
"must-pull": {
Name: "must-pull",
Image: "registry.example.com/another-service",
},
},
}
project, err := pullOptions{
policy: types.PullPolicyMissing,
}.apply(project, nil)
assert.NilError(t, err)
assert.Equal(t, project.Services["must-build"].PullPolicy, "") // still default
assert.Equal(t, project.Services["has-build"].PullPolicy, types.PullPolicyMissing)
assert.Equal(t, project.Services["must-pull"].PullPolicy, types.PullPolicyMissing)
}

View File

@ -19,42 +19,55 @@ package compose
import (
"context"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
)
type pushOptions struct {
*projectOptions
*ProjectOptions
composeOptions
IncludeDeps bool
Ignorefailures bool
Quiet bool
}
func pushCommand(p *projectOptions, backend api.Service) *cobra.Command {
func pushCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := pushOptions{
projectOptions: p,
ProjectOptions: p,
}
pushCmd := &cobra.Command{
Use: "push [SERVICE...]",
Use: "push [OPTIONS] [SERVICE...]",
Short: "Push service images",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runPush(ctx, backend, opts, args)
return runPush(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
pushCmd.Flags().BoolVar(&opts.Ignorefailures, "ignore-push-failures", false, "Push what it can and ignores images with push failures")
pushCmd.Flags().BoolVar(&opts.IncludeDeps, "include-deps", false, "Also push images of services declared as dependencies")
pushCmd.Flags().BoolVarP(&opts.Quiet, "quiet", "q", false, "Push without printing progress information")
return pushCmd
}
func runPush(ctx context.Context, backend api.Service, opts pushOptions, services []string) error {
project, err := opts.toProject(services)
func runPush(ctx context.Context, dockerCli command.Cli, backend api.Service, opts pushOptions, services []string) error {
project, _, err := opts.ToProject(ctx, dockerCli, services)
if err != nil {
return err
}
if !opts.IncludeDeps {
project, err = project.WithSelectedServices(services, types.IgnoreDependencies)
if err != nil {
return err
}
}
return backend.Push(ctx, project, api.PushOptions{
IgnoreFailures: opts.Ignorefailures,
Quiet: opts.Quiet,
})
}

View File

@ -19,23 +19,24 @@ package compose
import (
"context"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/api"
"github.com/spf13/cobra"
)
type removeOptions struct {
*projectOptions
*ProjectOptions
force bool
stop bool
volumes bool
}
func removeCommand(p *projectOptions, backend api.Service) *cobra.Command {
func removeCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := removeOptions{
projectOptions: p,
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "rm [SERVICE...]",
Use: "rm [OPTIONS] [SERVICE...]",
Short: "Removes stopped service containers",
Long: `Removes stopped service containers
@ -44,9 +45,9 @@ can override this with -v. To list all volumes, use "docker volume ls".
Any data which is not in a volume will be lost.`,
RunE: Adapt(func(ctx context.Context, args []string) error {
return runRemove(ctx, backend, opts, args)
return runRemove(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
f := cmd.Flags()
f.BoolVarP(&opts.force, "force", "f", false, "Don't ask to confirm removal")
@ -58,24 +59,17 @@ Any data which is not in a volume will be lost.`,
return cmd
}
func runRemove(ctx context.Context, backend api.Service, opts removeOptions, services []string) error {
project, err := opts.toProjectName()
func runRemove(ctx context.Context, dockerCli command.Cli, backend api.Service, opts removeOptions, services []string) error {
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
if opts.stop {
err := backend.Stop(ctx, project, api.StopOptions{
Services: services,
})
if err != nil {
return err
}
}
return backend.Remove(ctx, project, api.RemoveOptions{
return backend.Remove(ctx, name, api.RemoveOptions{
Services: services,
Force: opts.force,
Volumes: opts.volumes,
Project: project,
Stop: opts.stop,
})
}

View File

@ -20,43 +20,64 @@ import (
"context"
"time"
"github.com/docker/cli/cli/command"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
)
type restartOptions struct {
*projectOptions
timeout int
*ProjectOptions
timeChanged bool
timeout int
noDeps bool
}
func restartCommand(p *projectOptions, backend api.Service) *cobra.Command {
func restartCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := restartOptions{
projectOptions: p,
ProjectOptions: p,
}
restartCmd := &cobra.Command{
Use: "restart",
Short: "Restart containers",
Use: "restart [OPTIONS] [SERVICE...]",
Short: "Restart service containers",
PreRun: func(cmd *cobra.Command, args []string) {
opts.timeChanged = cmd.Flags().Changed("timeout")
},
RunE: Adapt(func(ctx context.Context, args []string) error {
return runRestart(ctx, backend, opts, args)
return runRestart(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := restartCmd.Flags()
flags.IntVarP(&opts.timeout, "timeout", "t", 10, "Specify a shutdown timeout in seconds")
flags.IntVarP(&opts.timeout, "timeout", "t", 0, "Specify a shutdown timeout in seconds")
flags.BoolVar(&opts.noDeps, "no-deps", false, "Don't restart dependent services")
return restartCmd
}
func runRestart(ctx context.Context, backend api.Service, opts restartOptions, services []string) error {
projectName, err := opts.toProjectName()
func runRestart(ctx context.Context, dockerCli command.Cli, backend api.Service, opts restartOptions, services []string) error {
project, name, err := opts.projectOrName(ctx, dockerCli)
if err != nil {
return err
}
timeout := time.Duration(opts.timeout) * time.Second
return backend.Restart(ctx, projectName, api.RestartOptions{
Timeout: &timeout,
if project != nil && len(services) > 0 {
project, err = project.WithServicesEnabled(services...)
if err != nil {
return err
}
}
var timeout *time.Duration
if opts.timeChanged {
timeoutValue := time.Duration(opts.timeout) * time.Second
timeout = &timeoutValue
}
return backend.Restart(ctx, name, api.RestartOptions{
Timeout: timeout,
Services: services,
Project: project,
NoDeps: opts.noDeps,
})
}

View File

@ -19,12 +19,18 @@ package compose
import (
"context"
"fmt"
"os"
"strings"
cgo "github.com/compose-spec/compose-go/cli"
"github.com/compose-spec/compose-go/loader"
"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/dotenv"
"github.com/compose-spec/compose-go/v2/format"
xprogress "github.com/moby/buildkit/util/progress/progressui"
"github.com/sirupsen/logrus"
cgo "github.com/compose-spec/compose-go/v2/cli"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/opts"
"github.com/mattn/go-shellwords"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
@ -32,6 +38,7 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/progress"
"github.com/docker/compose/v2/pkg/utils"
)
type runOptions struct {
@ -39,14 +46,18 @@ type runOptions struct {
Service string
Command []string
environment []string
envFiles []string
Detach bool
Remove bool
noTty bool
tty bool
interactive bool
user string
workdir string
entrypoint string
entrypointCmd []string
capAdd opts.ListOpts
capDrop opts.ListOpts
labels []string
volumes []string
publish []string
@ -55,115 +66,179 @@ type runOptions struct {
name string
noDeps bool
ignoreOrphans bool
removeOrphans bool
quiet bool
quietPull bool
}
func (opts runOptions) apply(project *types.Project) error {
target, err := project.GetService(opts.Service)
if err != nil {
return err
func (options runOptions) apply(project *types.Project) (*types.Project, error) {
if options.noDeps {
var err error
project, err = project.WithSelectedServices([]string{options.Service}, types.IgnoreDependencies)
if err != nil {
return nil, err
}
}
target.Tty = !opts.noTty
target.StdinOpen = opts.interactive
if !opts.servicePorts {
target.Ports = []types.ServicePortConfig{}
target, err := project.GetService(options.Service)
if err != nil {
return nil, err
}
if len(opts.publish) > 0 {
target.Tty = !options.noTty
target.StdinOpen = options.interactive
// --service-ports and --publish are incompatible
if !options.servicePorts {
if len(target.Ports) > 0 {
logrus.Debug("Running service without ports exposed as --service-ports=false")
}
target.Ports = []types.ServicePortConfig{}
for _, p := range opts.publish {
for _, p := range options.publish {
config, err := types.ParsePortConfig(p)
if err != nil {
return err
return nil, err
}
target.Ports = append(target.Ports, config...)
}
}
if len(opts.volumes) > 0 {
for _, v := range opts.volumes {
volume, err := loader.ParseVolume(v)
if err != nil {
return err
}
target.Volumes = append(target.Volumes, volume)
for _, v := range options.volumes {
volume, err := format.ParseVolume(v)
if err != nil {
return nil, err
}
target.Volumes = append(target.Volumes, volume)
}
if opts.noDeps {
for _, s := range project.Services {
if s.Name != opts.Service {
project.DisabledServices = append(project.DisabledServices, s)
}
}
project.Services = types.Services{target}
}
for i, s := range project.Services {
if s.Name == opts.Service {
project.Services[i] = target
for name := range project.Services {
if name == options.Service {
project.Services[name] = target
break
}
}
return nil
return project, nil
}
func runCommand(p *projectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := runOptions{
func (options runOptions) getEnvironment() (types.Mapping, error) {
environment := types.NewMappingWithEquals(options.environment).Resolve(os.LookupEnv).ToMapping()
for _, file := range options.envFiles {
f, err := os.Open(file)
if err != nil {
return nil, err
}
vars, err := dotenv.ParseWithLookup(f, func(k string) (string, bool) {
value, ok := environment[k]
return value, ok
})
if err != nil {
return nil, nil
}
for k, v := range vars {
if _, ok := environment[k]; !ok {
environment[k] = v
}
}
}
return environment, nil
}
func runCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
options := runOptions{
composeOptions: &composeOptions{
projectOptions: p,
ProjectOptions: p,
},
capAdd: opts.NewListOpts(nil),
capDrop: opts.NewListOpts(nil),
}
createOpts := createOptions{}
buildOpts := buildOptions{
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "run [options] [-v VOLUME...] [-p PORT...] [-e KEY=VAL...] [-l KEY=VALUE...] SERVICE [COMMAND] [ARGS...]",
Short: "Run a one-off command on a service.",
Use: "run [OPTIONS] SERVICE [COMMAND] [ARGS...]",
Short: "Run a one-off command on a service",
Args: cobra.MinimumNArgs(1),
PreRunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
opts.Service = args[0]
options.Service = args[0]
if len(args) > 1 {
opts.Command = args[1:]
options.Command = args[1:]
}
if len(opts.publish) > 0 && opts.servicePorts {
if len(options.publish) > 0 && options.servicePorts {
return fmt.Errorf("--service-ports and --publish are incompatible")
}
if cmd.Flags().Changed("entrypoint") {
command, err := shellwords.Parse(opts.entrypoint)
command, err := shellwords.Parse(options.entrypoint)
if err != nil {
return err
}
opts.entrypointCmd = command
options.entrypointCmd = command
}
if cmd.Flags().Changed("tty") {
if cmd.Flags().Changed("no-TTY") {
return fmt.Errorf("--tty and --no-TTY can't be used together")
} else {
options.noTty = !options.tty
}
}
if options.quiet {
progress.Mode = progress.ModeQuiet
devnull, err := os.Open(os.DevNull)
if err != nil {
return err
}
os.Stdout = devnull
}
createOpts.pullChanged = cmd.Flags().Changed("pull")
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
project, err := p.toProject([]string{opts.Service}, cgo.WithResolvedPaths(true))
project, _, err := p.ToProject(ctx, dockerCli, []string{options.Service}, cgo.WithResolvedPaths(true), cgo.WithoutEnvironmentResolution)
if err != nil {
return err
}
ignore := project.Environment["COMPOSE_IGNORE_ORPHANS"]
opts.ignoreOrphans = strings.ToLower(ignore) == "true"
return runRun(ctx, backend, project, opts)
project, err = project.WithServicesEnvironmentResolved(true)
if err != nil {
return err
}
if createOpts.quietPull {
buildOpts.Progress = string(xprogress.QuietMode)
}
options.ignoreOrphans = utils.StringToBool(project.Environment[ComposeIgnoreOrphans])
return runRun(ctx, backend, project, options, createOpts, buildOpts, dockerCli)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.BoolVarP(&opts.Detach, "detach", "d", false, "Run container in background and print container ID")
flags.StringArrayVarP(&opts.environment, "env", "e", []string{}, "Set environment variables")
flags.StringArrayVarP(&opts.labels, "label", "l", []string{}, "Add or override a label")
flags.BoolVar(&opts.Remove, "rm", false, "Automatically remove the container when it exits")
flags.BoolVarP(&opts.noTty, "no-TTY", "T", !dockerCli.Out().IsTerminal(), "Disable pseudo-TTY allocation (default: auto-detected).")
flags.StringVar(&opts.name, "name", "", " Assign a name to the container")
flags.StringVarP(&opts.user, "user", "u", "", "Run as specified username or uid")
flags.StringVarP(&opts.workdir, "workdir", "w", "", "Working directory inside the container")
flags.StringVar(&opts.entrypoint, "entrypoint", "", "Override the entrypoint of the image")
flags.BoolVar(&opts.noDeps, "no-deps", false, "Don't start linked services.")
flags.StringArrayVarP(&opts.volumes, "volume", "v", []string{}, "Bind mount a volume.")
flags.StringArrayVarP(&opts.publish, "publish", "p", []string{}, "Publish a container's port(s) to the host.")
flags.BoolVar(&opts.useAliases, "use-aliases", false, "Use the service's network useAliases in the network(s) the container connects to.")
flags.BoolVar(&opts.servicePorts, "service-ports", false, "Run command with the service's ports enabled and mapped to the host.")
flags.BoolVar(&opts.quietPull, "quiet-pull", false, "Pull without printing progress information.")
flags.BoolVarP(&options.Detach, "detach", "d", false, "Run container in background and print container ID")
flags.StringArrayVarP(&options.environment, "env", "e", []string{}, "Set environment variables")
flags.StringArrayVar(&options.envFiles, "env-from-file", []string{}, "Set environment variables from file")
flags.StringArrayVarP(&options.labels, "label", "l", []string{}, "Add or override a label")
flags.BoolVar(&options.Remove, "rm", false, "Automatically remove the container when it exits")
flags.BoolVarP(&options.noTty, "no-TTY", "T", !dockerCli.Out().IsTerminal(), "Disable pseudo-TTY allocation (default: auto-detected)")
flags.StringVar(&options.name, "name", "", "Assign a name to the container")
flags.StringVarP(&options.user, "user", "u", "", "Run as specified username or uid")
flags.StringVarP(&options.workdir, "workdir", "w", "", "Working directory inside the container")
flags.StringVar(&options.entrypoint, "entrypoint", "", "Override the entrypoint of the image")
flags.Var(&options.capAdd, "cap-add", "Add Linux capabilities")
flags.Var(&options.capDrop, "cap-drop", "Drop Linux capabilities")
flags.BoolVar(&options.noDeps, "no-deps", false, "Don't start linked services")
flags.StringArrayVarP(&options.volumes, "volume", "v", []string{}, "Bind mount a volume")
flags.StringArrayVarP(&options.publish, "publish", "p", []string{}, "Publish a container's port(s) to the host")
flags.BoolVar(&options.useAliases, "use-aliases", false, "Use the service's network useAliases in the network(s) the container connects to")
flags.BoolVarP(&options.servicePorts, "service-ports", "P", false, "Run command with all service's ports enabled and mapped to the host")
flags.StringVar(&createOpts.Pull, "pull", "policy", `Pull image before running ("always"|"missing"|"never")`)
flags.BoolVarP(&options.quiet, "quiet", "q", false, "Don't print anything to STDOUT")
flags.BoolVar(&buildOpts.quiet, "quiet-build", false, "Suppress progress output from the build process")
flags.BoolVar(&options.quietPull, "quiet-pull", false, "Pull without printing progress information")
flags.BoolVar(&createOpts.Build, "build", false, "Build image before starting container")
flags.BoolVar(&options.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
cmd.Flags().BoolVarP(&opts.interactive, "interactive", "i", true, "Keep STDIN open even if not attached.")
cmd.Flags().BoolP("tty", "t", true, "Allocate a pseudo-TTY.")
cmd.Flags().BoolVarP(&options.interactive, "interactive", "i", true, "Keep STDIN open even if not attached")
cmd.Flags().BoolVarP(&options.tty, "tty", "t", true, "Allocate a pseudo-TTY")
cmd.Flags().MarkHidden("tty") //nolint:errcheck
flags.SetNormalizeFunc(normalizeRunFlags)
@ -181,21 +256,23 @@ func normalizeRunFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
return pflag.NormalizedName(name)
}
func runRun(ctx context.Context, backend api.Service, project *types.Project, opts runOptions) error {
err := opts.apply(project)
func runRun(ctx context.Context, backend api.Service, project *types.Project, options runOptions, createOpts createOptions, buildOpts buildOptions, dockerCli command.Cli) error {
project, err := options.apply(project)
if err != nil {
return err
}
err = progress.Run(ctx, func(ctx context.Context) error {
return startDependencies(ctx, backend, *project, opts.Service, opts.ignoreOrphans)
})
err = createOpts.Apply(project)
if err != nil {
return err
}
if err := checksForRemoteStack(ctx, dockerCli, project, buildOpts, createOpts.AssumeYes, []string{}); err != nil {
return err
}
labels := types.Labels{}
for _, s := range opts.labels {
for _, s := range options.labels {
parts := strings.SplitN(s, "=", 2)
if len(parts) != 2 {
return fmt.Errorf("label must be set as KEY=VALUE")
@ -203,30 +280,51 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op
labels[parts[0]] = parts[1]
}
// start container and attach to container streams
runOpts := api.RunOptions{
Name: opts.name,
Service: opts.Service,
Command: opts.Command,
Detach: opts.Detach,
AutoRemove: opts.Remove,
Tty: !opts.noTty,
Interactive: opts.interactive,
WorkingDir: opts.workdir,
User: opts.user,
Environment: opts.environment,
Entrypoint: opts.entrypointCmd,
Labels: labels,
UseNetworkAliases: opts.useAliases,
NoDeps: opts.noDeps,
Index: 0,
QuietPull: opts.quietPull,
var buildForRun *api.BuildOptions
if !createOpts.noBuild {
bo, err := buildOpts.toAPIBuildOptions(nil)
if err != nil {
return err
}
buildForRun = &bo
}
for i, service := range project.Services {
if service.Name == opts.Service {
service.StdinOpen = opts.interactive
project.Services[i] = service
environment, err := options.getEnvironment()
if err != nil {
return err
}
// start container and attach to container streams
runOpts := api.RunOptions{
CreateOptions: api.CreateOptions{
Build: buildForRun,
RemoveOrphans: options.removeOrphans,
IgnoreOrphans: options.ignoreOrphans,
QuietPull: options.quietPull,
},
Name: options.name,
Service: options.Service,
Command: options.Command,
Detach: options.Detach,
AutoRemove: options.Remove,
Tty: !options.noTty,
Interactive: options.interactive,
WorkingDir: options.workdir,
User: options.user,
CapAdd: options.capAdd.GetSlice(),
CapDrop: options.capDrop.GetSlice(),
Environment: environment.Values(),
Entrypoint: options.entrypointCmd,
Labels: labels,
UseNetworkAliases: options.useAliases,
NoDeps: options.noDeps,
Index: 0,
}
for name, service := range project.Services {
if name == options.Service {
service.StdinOpen = options.interactive
project.Services[name] = service
}
}
@ -240,29 +338,3 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op
}
return err
}
func startDependencies(ctx context.Context, backend api.Service, project types.Project, requestedServiceName string, ignoreOrphans bool) error {
dependencies := types.Services{}
var requestedService types.ServiceConfig
for _, service := range project.Services {
if service.Name != requestedServiceName {
dependencies = append(dependencies, service)
} else {
requestedService = service
}
}
project.Services = dependencies
project.DisabledServices = append(project.DisabledServices, requestedService)
err := backend.Create(ctx, &project, api.CreateOptions{
IgnoreOrphans: ignoreOrphans,
})
if err != nil {
return err
}
if len(dependencies) > 0 {
return backend.Start(ctx, project.Name, api.StartOptions{})
}
return nil
}

100
cmd/compose/scale.go Normal file
View File

@ -0,0 +1,100 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"fmt"
"maps"
"slices"
"strconv"
"strings"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/api"
"github.com/spf13/cobra"
)
type scaleOptions struct {
*ProjectOptions
noDeps bool
}
func scaleCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := scaleOptions{
ProjectOptions: p,
}
scaleCmd := &cobra.Command{
Use: "scale [SERVICE=REPLICAS...]",
Short: "Scale services ",
Args: cobra.MinimumNArgs(1),
RunE: Adapt(func(ctx context.Context, args []string) error {
serviceTuples, err := parseServicesReplicasArgs(args)
if err != nil {
return err
}
return runScale(ctx, dockerCli, backend, opts, serviceTuples)
}),
ValidArgsFunction: completeScaleArgs(dockerCli, p),
}
flags := scaleCmd.Flags()
flags.BoolVar(&opts.noDeps, "no-deps", false, "Don't start linked services")
return scaleCmd
}
func runScale(ctx context.Context, dockerCli command.Cli, backend api.Service, opts scaleOptions, serviceReplicaTuples map[string]int) error {
services := slices.Sorted(maps.Keys(serviceReplicaTuples))
project, _, err := opts.ToProject(ctx, dockerCli, services)
if err != nil {
return err
}
if opts.noDeps {
if project, err = project.WithSelectedServices(services, types.IgnoreDependencies); err != nil {
return err
}
}
for key, value := range serviceReplicaTuples {
service, err := project.GetService(key)
if err != nil {
return err
}
service.SetScale(value)
project.Services[key] = service
}
return backend.Scale(ctx, project, api.ScaleOptions{Services: services})
}
func parseServicesReplicasArgs(args []string) (map[string]int, error) {
serviceReplicaTuples := map[string]int{}
for _, arg := range args {
key, val, ok := strings.Cut(arg, "=")
if !ok || key == "" || val == "" {
return nil, fmt.Errorf("invalid scale specifier: %s", arg)
}
intValue, err := strconv.Atoi(val)
if err != nil {
return nil, fmt.Errorf("invalid scale specifier: can't parse replica value as int: %v", arg)
}
serviceReplicaTuples[key] = intValue
}
return serviceReplicaTuples, nil
}

View File

@ -19,36 +19,39 @@ package compose
import (
"context"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/api"
"github.com/spf13/cobra"
)
type startOptions struct {
*projectOptions
*ProjectOptions
}
func startCommand(p *projectOptions, backend api.Service) *cobra.Command {
func startCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := startOptions{
projectOptions: p,
ProjectOptions: p,
}
startCmd := &cobra.Command{
Use: "start [SERVICE...]",
Short: "Start services",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runStart(ctx, backend, opts, args)
return runStart(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
return startCmd
}
func runStart(ctx context.Context, backend api.Service, opts startOptions, services []string) error {
projectName, err := opts.toProjectName()
func runStart(ctx context.Context, dockerCli command.Cli, backend api.Service, opts startOptions, services []string) error {
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
return backend.Start(ctx, projectName, api.StartOptions{
return backend.Start(ctx, name, api.StartOptions{
AttachTo: services,
Project: project,
Services: services,
})
}

84
cmd/compose/stats.go Normal file
View File

@ -0,0 +1,84 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"fmt"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/container"
"github.com/docker/docker/api/types/filters"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
)
type statsOptions struct {
ProjectOptions *ProjectOptions
all bool
format string
noStream bool
noTrunc bool
}
func statsCommand(p *ProjectOptions, dockerCli command.Cli) *cobra.Command {
opts := statsOptions{
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "stats [OPTIONS] [SERVICE]",
Short: "Display a live stream of container(s) resource usage statistics",
Args: cobra.MaximumNArgs(1),
RunE: Adapt(func(ctx context.Context, args []string) error {
return runStats(ctx, dockerCli, opts, args)
}),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.BoolVarP(&opts.all, "all", "a", false, "Show all containers (default shows just running)")
flags.StringVar(&opts.format, "format", "", `Format output using a custom template:
'table': Print output in table format with column headers (default)
'table TEMPLATE': Print output in table format using the given Go template
'json': Print in JSON format
'TEMPLATE': Print output using the given Go template.
Refer to https://docs.docker.com/engine/cli/formatting/ for more information about formatting output with templates`)
flags.BoolVar(&opts.noStream, "no-stream", false, "Disable streaming stats and only pull the first result")
flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate output")
return cmd
}
func runStats(ctx context.Context, dockerCli command.Cli, opts statsOptions, service []string) error {
name, err := opts.ProjectOptions.toProjectName(ctx, dockerCli)
if err != nil {
return err
}
filter := []filters.KeyValuePair{
filters.Arg("label", fmt.Sprintf("%s=%s", api.ProjectLabel, name)),
}
if len(service) > 0 {
filter = append(filter, filters.Arg("label", fmt.Sprintf("%s=%s", api.ServiceLabel, service[0])))
}
args := filters.NewArgs(filter...)
return container.RunStats(ctx, dockerCli, &container.StatsOptions{
All: opts.all,
NoStream: opts.noStream,
NoTrunc: opts.noTrunc,
Format: opts.format,
Filters: &args,
})
}

View File

@ -20,40 +20,41 @@ import (
"context"
"time"
"github.com/docker/cli/cli/command"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
)
type stopOptions struct {
*projectOptions
*ProjectOptions
timeChanged bool
timeout int
}
func stopCommand(p *projectOptions, backend api.Service) *cobra.Command {
func stopCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := stopOptions{
projectOptions: p,
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "stop [SERVICE...]",
Use: "stop [OPTIONS] [SERVICE...]",
Short: "Stop services",
PreRun: func(cmd *cobra.Command, args []string) {
opts.timeChanged = cmd.Flags().Changed("timeout")
},
RunE: Adapt(func(ctx context.Context, args []string) error {
return runStop(ctx, backend, opts, args)
return runStop(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.IntVarP(&opts.timeout, "timeout", "t", 10, "Specify a shutdown timeout in seconds")
flags.IntVarP(&opts.timeout, "timeout", "t", 0, "Specify a shutdown timeout in seconds")
return cmd
}
func runStop(ctx context.Context, backend api.Service, opts stopOptions, services []string) error {
projectName, err := opts.toProjectName()
func runStop(ctx context.Context, dockerCli command.Cli, backend api.Service, opts stopOptions, services []string) error {
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
@ -63,8 +64,9 @@ func runStop(ctx context.Context, backend api.Service, opts stopOptions, service
timeoutValue := time.Duration(opts.timeout) * time.Second
timeout = &timeoutValue
}
return backend.Stop(ctx, projectName, api.StopOptions{
return backend.Stop(ctx, name, api.StopOptions{
Timeout: timeout,
Services: services,
Project: project,
})
}

View File

@ -20,37 +20,42 @@ import (
"context"
"fmt"
"io"
"os"
"sort"
"strings"
"text/tabwriter"
"github.com/docker/cli/cli/command"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
)
type topOptions struct {
*projectOptions
*ProjectOptions
}
func topCommand(p *projectOptions, backend api.Service) *cobra.Command {
func topCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := topOptions{
projectOptions: p,
ProjectOptions: p,
}
topCmd := &cobra.Command{
Use: "top [SERVICES...]",
Short: "Display the running processes",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runTop(ctx, backend, opts, args)
return runTop(ctx, dockerCli, backend, opts, args)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
return topCmd
}
func runTop(ctx context.Context, backend api.Service, opts topOptions, services []string) error {
projectName, err := opts.toProjectName()
type (
topHeader map[string]int // maps a proc title to its output index
topEntries map[string]string
)
func runTop(ctx context.Context, dockerCli command.Cli, backend api.Service, opts topOptions, services []string) error {
projectName, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}
@ -63,30 +68,76 @@ func runTop(ctx context.Context, backend api.Service, opts topOptions, services
return containers[i].Name < containers[j].Name
})
for _, container := range containers {
fmt.Printf("%s\n", container.Name)
err := psPrinter(os.Stdout, func(w io.Writer) {
for _, proc := range container.Processes {
info := []interface{}{}
for _, p := range proc {
info = append(info, p)
}
_, _ = fmt.Fprintf(w, strings.Repeat("%s\t", len(info))+"\n", info...)
header, entries := collectTop(containers)
return topPrint(dockerCli.Out(), header, entries)
}
func collectTop(containers []api.ContainerProcSummary) (topHeader, []topEntries) {
// map column name to its header (should keep working if backend.Top returns
// varying columns for different containers)
header := topHeader{"SERVICE": 0, "#": 1}
// assume one process per container and grow if needed
entries := make([]topEntries, 0, len(containers))
for _, container := range containers {
for _, proc := range container.Processes {
entry := topEntries{
"SERVICE": container.Service,
"#": container.Replica,
}
fmt.Fprintln(w)
},
container.Titles...)
if err != nil {
return err
for i, title := range container.Titles {
if _, exists := header[title]; !exists {
header[title] = len(header)
}
entry[title] = proc[i]
}
entries = append(entries, entry)
}
}
return nil
// ensure CMD is the right-most column
if pos, ok := header["CMD"]; ok {
maxPos := pos
for h, i := range header {
if i > maxPos {
maxPos = i
}
if i > pos {
header[h] = i - 1
}
}
header["CMD"] = maxPos
}
return header, entries
}
func psPrinter(out io.Writer, printer func(writer io.Writer), headers ...string) error {
w := tabwriter.NewWriter(out, 5, 1, 3, ' ', 0)
_, _ = fmt.Fprintln(w, strings.Join(headers, "\t"))
printer(w)
func topPrint(out io.Writer, headers topHeader, rows []topEntries) error {
if len(rows) == 0 {
return nil
}
w := tabwriter.NewWriter(out, 4, 1, 2, ' ', 0)
// write headers in the order we've encountered them
h := make([]string, len(headers))
for title, index := range headers {
h[index] = title
}
_, _ = fmt.Fprintln(w, strings.Join(h, "\t"))
for _, row := range rows {
// write proc data in header order
r := make([]string, len(headers))
for title, index := range headers {
if v, ok := row[title]; ok {
r[index] = v
} else {
r[index] = "-"
}
}
_, _ = fmt.Fprintln(w, strings.Join(r, "\t"))
}
return w.Flush()
}

329
cmd/compose/top_test.go Normal file
View File

@ -0,0 +1,329 @@
/*
Copyright 2024 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"bytes"
"strings"
"testing"
"github.com/docker/compose/v2/pkg/api"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
var topTestCases = []struct {
name string
titles []string
procs [][]string
header topHeader
entries []topEntries
output string
}{
{
name: "noprocs",
titles: []string{"UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD"},
procs: [][]string{},
header: topHeader{"SERVICE": 0, "#": 1},
entries: []topEntries{},
output: "",
},
{
name: "simple",
titles: []string{"UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD"},
procs: [][]string{{"root", "1", "1", "0", "12:00", "?", "00:00:01", "/entrypoint"}},
header: topHeader{
"SERVICE": 0,
"#": 1,
"UID": 2,
"PID": 3,
"PPID": 4,
"C": 5,
"STIME": 6,
"TTY": 7,
"TIME": 8,
"CMD": 9,
},
entries: []topEntries{
{
"SERVICE": "simple",
"#": "1",
"UID": "root",
"PID": "1",
"PPID": "1",
"C": "0",
"STIME": "12:00",
"TTY": "?",
"TIME": "00:00:01",
"CMD": "/entrypoint",
},
},
output: trim(`
SERVICE # UID PID PPID C STIME TTY TIME CMD
simple 1 root 1 1 0 12:00 ? 00:00:01 /entrypoint
`),
},
{
name: "noppid",
titles: []string{"UID", "PID", "C", "STIME", "TTY", "TIME", "CMD"},
procs: [][]string{{"root", "1", "0", "12:00", "?", "00:00:02", "/entrypoint"}},
header: topHeader{
"SERVICE": 0,
"#": 1,
"UID": 2,
"PID": 3,
"C": 4,
"STIME": 5,
"TTY": 6,
"TIME": 7,
"CMD": 8,
},
entries: []topEntries{
{
"SERVICE": "noppid",
"#": "1",
"UID": "root",
"PID": "1",
"C": "0",
"STIME": "12:00",
"TTY": "?",
"TIME": "00:00:02",
"CMD": "/entrypoint",
},
},
output: trim(`
SERVICE # UID PID C STIME TTY TIME CMD
noppid 1 root 1 0 12:00 ? 00:00:02 /entrypoint
`),
},
{
name: "extra-hdr",
titles: []string{"UID", "GID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD"},
procs: [][]string{{"root", "1", "1", "1", "0", "12:00", "?", "00:00:03", "/entrypoint"}},
header: topHeader{
"SERVICE": 0,
"#": 1,
"UID": 2,
"GID": 3,
"PID": 4,
"PPID": 5,
"C": 6,
"STIME": 7,
"TTY": 8,
"TIME": 9,
"CMD": 10,
},
entries: []topEntries{
{
"SERVICE": "extra-hdr",
"#": "1",
"UID": "root",
"GID": "1",
"PID": "1",
"PPID": "1",
"C": "0",
"STIME": "12:00",
"TTY": "?",
"TIME": "00:00:03",
"CMD": "/entrypoint",
},
},
output: trim(`
SERVICE # UID GID PID PPID C STIME TTY TIME CMD
extra-hdr 1 root 1 1 1 0 12:00 ? 00:00:03 /entrypoint
`),
},
{
name: "multiple",
titles: []string{"UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD"},
procs: [][]string{
{"root", "1", "1", "0", "12:00", "?", "00:00:04", "/entrypoint"},
{"root", "123", "1", "0", "12:00", "?", "00:00:42", "sleep infinity"},
},
header: topHeader{
"SERVICE": 0,
"#": 1,
"UID": 2,
"PID": 3,
"PPID": 4,
"C": 5,
"STIME": 6,
"TTY": 7,
"TIME": 8,
"CMD": 9,
},
entries: []topEntries{
{
"SERVICE": "multiple",
"#": "1",
"UID": "root",
"PID": "1",
"PPID": "1",
"C": "0",
"STIME": "12:00",
"TTY": "?",
"TIME": "00:00:04",
"CMD": "/entrypoint",
},
{
"SERVICE": "multiple",
"#": "1",
"UID": "root",
"PID": "123",
"PPID": "1",
"C": "0",
"STIME": "12:00",
"TTY": "?",
"TIME": "00:00:42",
"CMD": "sleep infinity",
},
},
output: trim(`
SERVICE # UID PID PPID C STIME TTY TIME CMD
multiple 1 root 1 1 0 12:00 ? 00:00:04 /entrypoint
multiple 1 root 123 1 0 12:00 ? 00:00:42 sleep infinity
`),
},
}
// TestRunTopCore only tests the core functionality of runTop: formatting
// and printing of the output of (api.Service).Top().
func TestRunTopCore(t *testing.T) {
t.Parallel()
all := []api.ContainerProcSummary{}
for _, tc := range topTestCases {
summary := api.ContainerProcSummary{
Name: "not used",
Titles: tc.titles,
Processes: tc.procs,
Service: tc.name,
Replica: "1",
}
all = append(all, summary)
t.Run(tc.name, func(t *testing.T) {
header, entries := collectTop([]api.ContainerProcSummary{summary})
assert.Equal(t, tc.header, header)
assert.Equal(t, tc.entries, entries)
var buf bytes.Buffer
err := topPrint(&buf, header, entries)
require.NoError(t, err)
assert.Equal(t, tc.output, buf.String())
})
}
t.Run("all", func(t *testing.T) {
header, entries := collectTop(all)
assert.Equal(t, topHeader{
"SERVICE": 0,
"#": 1,
"UID": 2,
"PID": 3,
"PPID": 4,
"C": 5,
"STIME": 6,
"TTY": 7,
"TIME": 8,
"GID": 9,
"CMD": 10,
}, header)
assert.Equal(t, []topEntries{
{
"SERVICE": "simple",
"#": "1",
"UID": "root",
"PID": "1",
"PPID": "1",
"C": "0",
"STIME": "12:00",
"TTY": "?",
"TIME": "00:00:01",
"CMD": "/entrypoint",
}, {
"SERVICE": "noppid",
"#": "1",
"UID": "root",
"PID": "1",
"C": "0",
"STIME": "12:00",
"TTY": "?",
"TIME": "00:00:02",
"CMD": "/entrypoint",
}, {
"SERVICE": "extra-hdr",
"#": "1",
"UID": "root",
"GID": "1",
"PID": "1",
"PPID": "1",
"C": "0",
"STIME": "12:00",
"TTY": "?",
"TIME": "00:00:03",
"CMD": "/entrypoint",
}, {
"SERVICE": "multiple",
"#": "1",
"UID": "root",
"PID": "1",
"PPID": "1",
"C": "0",
"STIME": "12:00",
"TTY": "?",
"TIME": "00:00:04",
"CMD": "/entrypoint",
}, {
"SERVICE": "multiple",
"#": "1",
"UID": "root",
"PID": "123",
"PPID": "1",
"C": "0",
"STIME": "12:00",
"TTY": "?",
"TIME": "00:00:42",
"CMD": "sleep infinity",
},
}, entries)
var buf bytes.Buffer
err := topPrint(&buf, header, entries)
require.NoError(t, err)
assert.Equal(t, trim(`
SERVICE # UID PID PPID C STIME TTY TIME GID CMD
simple 1 root 1 1 0 12:00 ? 00:00:01 - /entrypoint
noppid 1 root 1 - 0 12:00 ? 00:00:02 - /entrypoint
extra-hdr 1 root 1 1 0 12:00 ? 00:00:03 1 /entrypoint
multiple 1 root 1 1 0 12:00 ? 00:00:04 - /entrypoint
multiple 1 root 123 1 0 12:00 ? 00:00:42 - sleep infinity
`), buf.String())
})
}
func trim(s string) string {
var out bytes.Buffer
for _, line := range strings.Split(strings.TrimSpace(s), "\n") {
out.WriteString(strings.TrimSpace(line))
out.WriteRune('\n')
}
return out.String()
}

View File

@ -18,128 +18,181 @@ package compose
import (
"context"
"errors"
"fmt"
"os"
"strconv"
"strings"
"time"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
xprogress "github.com/moby/buildkit/util/progress/progressui"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/compose-spec/compose-go/types"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
ui "github.com/docker/compose/v2/pkg/progress"
"github.com/docker/compose/v2/pkg/utils"
)
// composeOptions hold options common to `up` and `run` to run compose project
type composeOptions struct {
*projectOptions
*ProjectOptions
}
type upOptions struct {
*composeOptions
Detach bool
noStart bool
noDeps bool
cascadeStop bool
exitCodeFrom string
scale []string
noColor bool
noPrefix bool
attachDependencies bool
attach []string
wait bool
Detach bool
noStart bool
noDeps bool
cascadeStop bool
cascadeFail bool
exitCodeFrom string
noColor bool
noPrefix bool
attachDependencies bool
attach []string
noAttach []string
timestamp bool
wait bool
waitTimeout int
watch bool
navigationMenu bool
navigationMenuChanged bool
}
func (opts upOptions) apply(project *types.Project, services []string) error {
func (opts upOptions) apply(project *types.Project, services []string) (*types.Project, error) {
if opts.noDeps {
enabled, err := project.GetServices(services...)
var err error
project, err = project.WithSelectedServices(services, types.IgnoreDependencies)
if err != nil {
return err
return nil, err
}
for _, s := range project.Services {
if !utils.StringContains(services, s.Name) {
project.DisabledServices = append(project.DisabledServices, s)
}
}
project.Services = enabled
}
if opts.exitCodeFrom != "" {
_, err := project.GetService(opts.exitCodeFrom)
if err != nil {
return err
return nil, err
}
}
for _, scale := range opts.scale {
split := strings.Split(scale, "=")
if len(split) != 2 {
return fmt.Errorf("invalid --scale option %q. Should be SERVICE=NUM", scale)
}
name := split[0]
replicas, err := strconv.Atoi(split[1])
if err != nil {
return err
}
err = setServiceScale(project, name, uint64(replicas))
if err != nil {
return err
}
}
return nil
return project, nil
}
func upCommand(p *projectOptions, backend api.Service) *cobra.Command {
func (opts *upOptions) validateNavigationMenu(dockerCli command.Cli) {
if !dockerCli.Out().IsTerminal() {
opts.navigationMenu = false
return
}
// If --menu flag was not set
if !opts.navigationMenuChanged {
if envVar, ok := os.LookupEnv(ComposeMenu); ok {
opts.navigationMenu = utils.StringToBool(envVar)
return
}
// ...and COMPOSE_MENU env var is not defined we want the default value to be true
opts.navigationMenu = true
}
}
func (opts upOptions) OnExit() api.Cascade {
switch {
case opts.cascadeStop:
return api.CascadeStop
case opts.cascadeFail:
return api.CascadeFail
default:
return api.CascadeIgnore
}
}
func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
up := upOptions{}
create := createOptions{}
build := buildOptions{ProjectOptions: p}
upCmd := &cobra.Command{
Use: "up [SERVICE...]",
Use: "up [OPTIONS] [SERVICE...]",
Short: "Create and start containers",
PreRunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
create.pullChanged = cmd.Flags().Changed("pull")
create.timeChanged = cmd.Flags().Changed("timeout")
up.navigationMenuChanged = cmd.Flags().Changed("menu")
if !cmd.Flags().Changed("remove-orphans") {
create.removeOrphans = utils.StringToBool(os.Getenv(ComposeRemoveOrphans))
}
return validateFlags(&up, &create)
}),
RunE: p.WithServices(func(ctx context.Context, project *types.Project, services []string) error {
create.ignoreOrphans = utils.StringToBool(project.Environment["COMPOSE_IGNORE_ORPHANS"])
RunE: p.WithServices(dockerCli, func(ctx context.Context, project *types.Project, services []string) error {
create.ignoreOrphans = utils.StringToBool(project.Environment[ComposeIgnoreOrphans])
if create.ignoreOrphans && create.removeOrphans {
return fmt.Errorf("COMPOSE_IGNORE_ORPHANS and --remove-orphans cannot be combined")
return fmt.Errorf("cannot combine %s and --remove-orphans", ComposeIgnoreOrphans)
}
return runUp(ctx, backend, create, up, project, services)
if len(up.attach) != 0 && up.attachDependencies {
return errors.New("cannot combine --attach and --attach-dependencies")
}
up.validateNavigationMenu(dockerCli)
if !p.All && len(project.Services) == 0 {
return fmt.Errorf("no service selected")
}
return runUp(ctx, dockerCli, backend, create, up, build, project, services)
}),
ValidArgsFunction: serviceCompletion(p),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := upCmd.Flags()
flags.BoolVarP(&up.Detach, "detach", "d", false, "Detached mode: Run containers in the background")
flags.BoolVar(&create.Build, "build", false, "Build images before starting containers.")
flags.BoolVar(&create.noBuild, "no-build", false, "Don't build an image, even if it's missing.")
flags.BoolVar(&create.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")
flags.StringArrayVar(&up.scale, "scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.")
flags.BoolVar(&up.noColor, "no-color", false, "Produce monochrome output.")
flags.BoolVar(&up.noPrefix, "no-log-prefix", false, "Don't print prefix in logs.")
flags.BoolVar(&create.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed.")
flags.BoolVar(&create.Build, "build", false, "Build images before starting containers")
flags.BoolVar(&create.noBuild, "no-build", false, "Don't build an image, even if it's policy")
flags.StringVar(&create.Pull, "pull", "policy", `Pull image before running ("always"|"missing"|"never")`)
flags.BoolVar(&create.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
flags.StringArrayVar(&create.scale, "scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.")
flags.BoolVar(&up.noColor, "no-color", false, "Produce monochrome output")
flags.BoolVar(&up.noPrefix, "no-log-prefix", false, "Don't print prefix in logs")
flags.BoolVar(&create.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed")
flags.BoolVar(&create.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
flags.BoolVar(&up.noStart, "no-start", false, "Don't start the services after creating them.")
flags.BoolVar(&up.noStart, "no-start", false, "Don't start the services after creating them")
flags.BoolVar(&up.cascadeStop, "abort-on-container-exit", false, "Stops all containers if any container was stopped. Incompatible with -d")
flags.BoolVar(&up.cascadeFail, "abort-on-container-failure", false, "Stops all containers if any container exited with failure. Incompatible with -d")
flags.StringVar(&up.exitCodeFrom, "exit-code-from", "", "Return the exit code of the selected service container. Implies --abort-on-container-exit")
flags.IntVarP(&create.timeout, "timeout", "t", 10, "Use this timeout in seconds for container shutdown when attached or when containers are already running.")
flags.BoolVar(&up.noDeps, "no-deps", false, "Don't start linked services.")
flags.IntVarP(&create.timeout, "timeout", "t", 0, "Use this timeout in seconds for container shutdown when attached or when containers are already running")
flags.BoolVar(&up.timestamp, "timestamps", false, "Show timestamps")
flags.BoolVar(&up.noDeps, "no-deps", false, "Don't start linked services")
flags.BoolVar(&create.recreateDeps, "always-recreate-deps", false, "Recreate dependent containers. Incompatible with --no-recreate.")
flags.BoolVarP(&create.noInherit, "renew-anon-volumes", "V", false, "Recreate anonymous volumes instead of retrieving data from the previous containers.")
flags.BoolVar(&up.attachDependencies, "attach-dependencies", false, "Attach to dependent containers.")
flags.BoolVar(&create.quietPull, "quiet-pull", false, "Pull without printing progress information.")
flags.StringArrayVar(&up.attach, "attach", []string{}, "Attach to service output.")
flags.BoolVarP(&create.noInherit, "renew-anon-volumes", "V", false, "Recreate anonymous volumes instead of retrieving data from the previous containers")
flags.BoolVar(&create.quietPull, "quiet-pull", false, "Pull without printing progress information")
flags.BoolVar(&build.quiet, "quiet-build", false, "Suppress the build output")
flags.StringArrayVar(&up.attach, "attach", []string{}, "Restrict attaching to the specified services. Incompatible with --attach-dependencies.")
flags.StringArrayVar(&up.noAttach, "no-attach", []string{}, "Do not attach (stream logs) to the specified services")
flags.BoolVar(&up.attachDependencies, "attach-dependencies", false, "Automatically attach to log output of dependent services")
flags.BoolVar(&up.wait, "wait", false, "Wait for services to be running|healthy. Implies detached mode.")
flags.IntVar(&up.waitTimeout, "wait-timeout", 0, "Maximum duration in seconds to wait for the project to be running|healthy")
flags.BoolVarP(&up.watch, "watch", "w", false, "Watch source code and rebuild/refresh containers when files are updated.")
flags.BoolVar(&up.navigationMenu, "menu", false, "Enable interactive shortcuts when running attached. Incompatible with --detach. Can also be enable/disable by setting COMPOSE_MENU environment var.")
flags.BoolVarP(&create.AssumeYes, "yes", "y", false, `Assume "yes" as answer to all prompts and run non-interactively`)
flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
// assumeYes was introduced by mistake as `--y`
if name == "y" {
logrus.Warn("--y is deprecated, please use --yes instead")
name = "yes"
}
return pflag.NormalizedName(name)
})
return upCmd
}
//nolint:gocyclo
func validateFlags(up *upOptions, create *createOptions) error {
if up.exitCodeFrom != "" {
if up.exitCodeFrom != "" && !up.cascadeFail {
up.cascadeStop = true
}
if up.cascadeStop && up.cascadeFail {
return fmt.Errorf("--abort-on-container-failure cannot be combined with --abort-on-container-exit")
}
if up.wait {
if up.attachDependencies || up.cascadeStop || len(up.attach) > 0 {
return fmt.Errorf("--wait cannot be combined with --abort-on-container-exit, --attach or --attach-dependencies")
@ -149,8 +202,15 @@ func validateFlags(up *upOptions, create *createOptions) error {
if create.Build && create.noBuild {
return fmt.Errorf("--build and --no-build are incompatible")
}
if up.Detach && (up.attachDependencies || up.cascadeStop || len(up.attach) > 0) {
return fmt.Errorf("--detach cannot be combined with --abort-on-container-exit, --attach or --attach-dependencies")
if up.Detach && (up.attachDependencies || up.cascadeStop || up.cascadeFail || len(up.attach) > 0 || up.watch) {
if up.wait {
return fmt.Errorf("--wait cannot be combined with --abort-on-container-exit, --abort-on-container-failure, --attach, --attach-dependencies or --watch")
} else {
return fmt.Errorf("--detach cannot be combined with --abort-on-container-exit, --abort-on-container-failure, --attach, --attach-dependencies or --watch")
}
}
if create.noInherit && create.noRecreate {
return fmt.Errorf("--no-recreate and --renew-anon-volumes are incompatible")
}
if create.forceRecreate && create.noRecreate {
return fmt.Errorf("--force-recreate and --no-recreate are incompatible")
@ -158,38 +218,57 @@ func validateFlags(up *upOptions, create *createOptions) error {
if create.recreateDeps && create.noRecreate {
return fmt.Errorf("--always-recreate-deps and --no-recreate are incompatible")
}
if create.noBuild && up.watch {
return fmt.Errorf("--no-build and --watch are incompatible")
}
return nil
}
func runUp(ctx context.Context, backend api.Service, createOptions createOptions, upOptions upOptions, project *types.Project, services []string) error {
if len(project.Services) == 0 {
return fmt.Errorf("no service selected")
//nolint:gocyclo
func runUp(
ctx context.Context,
dockerCli command.Cli,
backend api.Service,
createOptions createOptions,
upOptions upOptions,
buildOptions buildOptions,
project *types.Project,
services []string,
) error {
if err := checksForRemoteStack(ctx, dockerCli, project, buildOptions, createOptions.AssumeYes, []string{}); err != nil {
return err
}
createOptions.Apply(project)
err := upOptions.apply(project, services)
err := createOptions.Apply(project)
if err != nil {
return err
}
var consumer api.LogConsumer
if !upOptions.Detach {
consumer = formatter.NewLogConsumer(ctx, os.Stdout, !upOptions.noColor, !upOptions.noPrefix)
project, err = upOptions.apply(project, services)
if err != nil {
return err
}
attachTo := services
if len(upOptions.attach) > 0 {
attachTo = upOptions.attach
}
if upOptions.attachDependencies {
attachTo = project.ServiceNames()
}
if len(attachTo) == 0 {
attachTo = project.ServiceNames()
var build *api.BuildOptions
if !createOptions.noBuild {
if createOptions.quietPull {
buildOptions.Progress = string(xprogress.QuietMode)
}
// BuildOptions here is nested inside CreateOptions, so
// no service list is passed, it will implicitly pick all
// services being created, which includes any explicitly
// specified via "services" arg here as well as deps
bo, err := buildOptions.toAPIBuildOptions(nil)
if err != nil {
return err
}
bo.Services = services
bo.Deps = !upOptions.noDeps
build = &bo
}
create := api.CreateOptions{
Build: build,
Services: services,
RemoveOrphans: createOptions.removeOrphans,
IgnoreOrphans: createOptions.ignoreOrphans,
@ -198,39 +277,72 @@ func runUp(ctx context.Context, backend api.Service, createOptions createOptions
Inherit: !createOptions.noInherit,
Timeout: createOptions.GetTimeout(),
QuietPull: createOptions.quietPull,
AssumeYes: createOptions.AssumeYes,
}
if upOptions.noStart {
return backend.Create(ctx, project, create)
}
var consumer api.LogConsumer
var attach []string
if !upOptions.Detach {
consumer = formatter.NewLogConsumer(ctx, dockerCli.Out(), dockerCli.Err(), !upOptions.noColor, !upOptions.noPrefix, upOptions.timestamp)
var attachSet utils.Set[string]
if len(upOptions.attach) != 0 {
// services are passed explicitly with --attach, verify they're valid and then use them as-is
attachSet = utils.NewSet(upOptions.attach...)
unexpectedSvcs := attachSet.Diff(utils.NewSet(project.ServiceNames()...))
if len(unexpectedSvcs) != 0 {
return fmt.Errorf("cannot attach to services not included in up: %s", strings.Join(unexpectedSvcs.Elements(), ", "))
}
} else {
// mark services being launched (and potentially their deps) for attach
// if they didn't opt-out via Compose YAML
attachSet = utils.NewSet[string]()
var dependencyOpt types.DependencyOption = types.IgnoreDependencies
if upOptions.attachDependencies {
dependencyOpt = types.IncludeDependencies
}
if err := project.ForEachService(services, func(serviceName string, s *types.ServiceConfig) error {
if s.Attach == nil || *s.Attach {
attachSet.Add(serviceName)
}
return nil
}, dependencyOpt); err != nil {
return err
}
}
// filter out any services that have been explicitly marked for ignore with `--no-attach`
attachSet.RemoveAll(upOptions.noAttach...)
attach = attachSet.Elements()
}
timeout := time.Duration(upOptions.waitTimeout) * time.Second
return backend.Up(ctx, project, api.UpOptions{
Create: create,
Start: api.StartOptions{
Project: project,
Attach: consumer,
AttachTo: attachTo,
ExitCodeFrom: upOptions.exitCodeFrom,
CascadeStop: upOptions.cascadeStop,
Wait: upOptions.wait,
Project: project,
Attach: consumer,
AttachTo: attach,
ExitCodeFrom: upOptions.exitCodeFrom,
OnExit: upOptions.OnExit(),
Wait: upOptions.wait,
WaitTimeout: timeout,
Watch: upOptions.watch,
Services: services,
NavigationMenu: upOptions.navigationMenu && ui.Mode != "plain" && dockerCli.In().IsTerminal(),
},
})
}
func setServiceScale(project *types.Project, name string, replicas uint64) error {
for i, s := range project.Services {
if s.Name == name {
service, err := project.GetService(name)
if err != nil {
return err
}
if service.Deploy == nil {
service.Deploy = &types.DeployConfig{}
}
service.Deploy.Replicas = &replicas
project.Services[i] = service
return nil
}
func setServiceScale(project *types.Project, name string, replicas int) error {
service, err := project.GetService(name)
if err != nil {
return err
}
return fmt.Errorf("unknown service %q", name)
service.SetScale(replicas)
project.Services[name] = service
return nil
}

View File

@ -19,25 +19,32 @@ package compose
import (
"testing"
"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
"gotest.tools/v3/assert"
)
func TestApplyScaleOpt(t *testing.T) {
p := types.Project{
Services: []types.ServiceConfig{
{
Services: types.Services{
"foo": {
Name: "foo",
},
{
"bar": {
Name: "bar",
Deploy: &types.DeployConfig{
Mode: "test",
},
},
},
}
opt := upOptions{scale: []string{"foo=2"}}
err := opt.apply(&p, nil)
err := applyScaleOpts(&p, []string{"foo=2", "bar=3"})
assert.NilError(t, err)
foo, err := p.GetService("foo")
assert.NilError(t, err)
assert.Equal(t, *foo.Deploy.Replicas, uint64(2))
assert.Equal(t, *foo.Scale, 2)
bar, err := p.GetService("bar")
assert.NilError(t, err)
assert.Equal(t, *bar.Scale, 3)
assert.Equal(t, *bar.Deploy.Replicas, 3)
}

View File

@ -20,6 +20,7 @@ import (
"fmt"
"strings"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/spf13/cobra"
@ -32,33 +33,38 @@ type versionOptions struct {
short bool
}
func versionCommand() *cobra.Command {
func versionCommand(dockerCli command.Cli) *cobra.Command {
opts := versionOptions{}
cmd := &cobra.Command{
Use: "version",
Use: "version [OPTIONS]",
Short: "Show the Docker Compose version information",
Args: cobra.MaximumNArgs(0),
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
runVersion(opts)
runVersion(opts, dockerCli)
return nil
},
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
// overwrite parent PersistentPreRunE to avoid trying to load
// compose file on version command if COMPOSE_FILE is set
return nil
},
}
// define flags for backward compatibility with com.docker.cli
flags := cmd.Flags()
flags.StringVarP(&opts.format, "format", "f", "", "Format the output. Values: [pretty | json]. (Default: pretty)")
flags.BoolVar(&opts.short, "short", false, "Shows only Compose's version number.")
flags.BoolVar(&opts.short, "short", false, "Shows only Compose's version number")
return cmd
}
func runVersion(opts versionOptions) {
func runVersion(opts versionOptions, dockerCli command.Cli) {
if opts.short {
fmt.Println(strings.TrimPrefix(internal.Version, "v"))
_, _ = fmt.Fprintln(dockerCli.Out(), strings.TrimPrefix(internal.Version, "v"))
return
}
if opts.format == formatter.JSON {
fmt.Printf("{\"version\":%q}\n", internal.Version)
_, _ = fmt.Fprintf(dockerCli.Out(), "{\"version\":%q}\n", internal.Version)
return
}
fmt.Println("Docker Compose version", internal.Version)
_, _ = fmt.Fprintln(dockerCli.Out(), "Docker Compose version", internal.Version)
}

View File

@ -0,0 +1,76 @@
/*
Copyright 2025 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"bytes"
"testing"
"github.com/docker/cli/cli/streams"
"github.com/docker/compose/v2/internal"
"github.com/docker/compose/v2/pkg/mocks"
"go.uber.org/mock/gomock"
"gotest.tools/v3/assert"
)
func TestVersionCommand(t *testing.T) {
originalVersion := internal.Version
defer func() {
internal.Version = originalVersion
}()
internal.Version = "v9.9.9-test"
tests := []struct {
name string
args []string
want string
}{
{
name: "default",
args: []string{},
want: "Docker Compose version v9.9.9-test\n",
},
{
name: "short flag",
args: []string{"--short"},
want: "9.9.9-test\n",
},
{
name: "json flag",
args: []string{"--format", "json"},
want: `{"version":"v9.9.9-test"}` + "\n",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
buf := new(bytes.Buffer)
cli := mocks.NewMockCli(ctrl)
cli.EXPECT().Out().Return(streams.NewOut(buf)).AnyTimes()
cmd := versionCommand(cli)
cmd.SetArgs(test.args)
err := cmd.Execute()
assert.NilError(t, err)
assert.Equal(t, test.want, buf.String())
})
}
}

97
cmd/compose/viz.go Normal file
View File

@ -0,0 +1,97 @@
/*
Copyright 2023 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"fmt"
"os"
"strings"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/api"
"github.com/spf13/cobra"
)
type vizOptions struct {
*ProjectOptions
includeNetworks bool
includePorts bool
includeImageName bool
indentationStr string
}
func vizCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := vizOptions{
ProjectOptions: p,
}
var indentationSize int
var useSpaces bool
cmd := &cobra.Command{
Use: "viz [OPTIONS]",
Short: "EXPERIMENTAL - Generate a graphviz graph from your compose file",
PreRunE: Adapt(func(ctx context.Context, args []string) error {
var err error
opts.indentationStr, err = preferredIndentationStr(indentationSize, useSpaces)
return err
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
return runViz(ctx, dockerCli, backend, &opts)
}),
}
cmd.Flags().BoolVar(&opts.includePorts, "ports", false, "Include service's exposed ports in output graph")
cmd.Flags().BoolVar(&opts.includeNetworks, "networks", false, "Include service's attached networks in output graph")
cmd.Flags().BoolVar(&opts.includeImageName, "image", false, "Include service's image name in output graph")
cmd.Flags().IntVar(&indentationSize, "indentation-size", 1, "Number of tabs or spaces to use for indentation")
cmd.Flags().BoolVar(&useSpaces, "spaces", false, "If given, space character ' ' will be used to indent,\notherwise tab character '\\t' will be used")
return cmd
}
func runViz(ctx context.Context, dockerCli command.Cli, backend api.Service, opts *vizOptions) error {
_, _ = fmt.Fprintln(os.Stderr, "viz command is EXPERIMENTAL")
project, _, err := opts.ToProject(ctx, dockerCli, nil)
if err != nil {
return err
}
// build graph
graphStr, _ := backend.Viz(ctx, project, api.VizOptions{
IncludeNetworks: opts.includeNetworks,
IncludePorts: opts.includePorts,
IncludeImageName: opts.includeImageName,
Indentation: opts.indentationStr,
})
fmt.Println(graphStr)
return nil
}
// preferredIndentationStr returns a single string given the indentation preference
func preferredIndentationStr(size int, useSpace bool) (string, error) {
if size < 0 {
return "", fmt.Errorf("invalid indentation size: %d", size)
}
indentationStr := "\t"
if useSpace {
indentationStr = " "
}
return strings.Repeat(indentationStr, size), nil
}

94
cmd/compose/viz_test.go Normal file
View File

@ -0,0 +1,94 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestPreferredIndentationStr(t *testing.T) {
type args struct {
size int
useSpace bool
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
{
name: "should return '\\t\\t'",
args: args{
size: 2,
useSpace: false,
},
want: "\t\t",
wantErr: false,
},
{
name: "should return ' '",
args: args{
size: 4,
useSpace: true,
},
want: " ",
wantErr: false,
},
{
name: "should return ''",
args: args{
size: 0,
useSpace: false,
},
want: "",
wantErr: false,
},
{
name: "should return ''",
args: args{
size: 0,
useSpace: true,
},
want: "",
wantErr: false,
},
{
name: "should throw error because indentation size < 0",
args: args{
size: -1,
useSpace: false,
},
want: "",
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := preferredIndentationStr(tt.args.size, tt.args.useSpace)
if tt.wantErr {
require.Errorf(t, err, "preferredIndentationStr(%v, %v)", tt.args.size, tt.args.useSpace)
} else {
require.NoError(t, err)
assert.Equalf(t, tt.want, got, "preferredIndentationStr(%v, %v)", tt.args.size, tt.args.useSpace)
}
})
}
}

95
cmd/compose/volumes.go Normal file
View File

@ -0,0 +1,95 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"fmt"
"slices"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/formatter"
"github.com/docker/cli/cli/flags"
"github.com/docker/compose/v2/pkg/api"
"github.com/spf13/cobra"
)
type volumesOptions struct {
*ProjectOptions
Quiet bool
Format string
}
func volumesCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
options := volumesOptions{
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "volumes [OPTIONS] [SERVICE...]",
Short: "List volumes",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runVol(ctx, dockerCli, backend, args, options)
}),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
cmd.Flags().BoolVarP(&options.Quiet, "quiet", "q", false, "Only display volume names")
cmd.Flags().StringVar(&options.Format, "format", "table", flags.FormatHelp)
return cmd
}
func runVol(ctx context.Context, dockerCli command.Cli, backend api.Service, services []string, options volumesOptions) error {
project, _, err := options.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
names := project.ServiceNames()
if len(services) == 0 {
services = names
}
for _, service := range services {
if !slices.Contains(names, service) {
return fmt.Errorf("no such service: %s", service)
}
}
volumes, err := backend.Volumes(ctx, project, api.VolumesOptions{
Services: services,
})
if err != nil {
return err
}
if options.Quiet {
for _, v := range volumes {
_, _ = fmt.Fprintln(dockerCli.Out(), v.Name)
}
return nil
}
volumeCtx := formatter.Context{
Output: dockerCli.Out(),
Format: formatter.NewVolumeFormat(options.Format, options.Quiet),
}
return formatter.VolumeWrite(volumeCtx, volumes)
}

73
cmd/compose/wait.go Normal file
View File

@ -0,0 +1,73 @@
/*
Copyright 2023 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"os"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/api"
"github.com/spf13/cobra"
)
type waitOptions struct {
*ProjectOptions
services []string
downProject bool
}
func waitCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
opts := waitOptions{
ProjectOptions: p,
}
var statusCode int64
var err error
cmd := &cobra.Command{
Use: "wait SERVICE [SERVICE...] [OPTIONS]",
Short: "Block until containers of all (or specified) services stop.",
Args: cli.RequiresMinArgs(1),
RunE: Adapt(func(ctx context.Context, services []string) error {
opts.services = services
statusCode, err = runWait(ctx, dockerCli, backend, &opts)
return err
}),
PostRun: func(cmd *cobra.Command, args []string) {
os.Exit(int(statusCode))
},
}
cmd.Flags().BoolVar(&opts.downProject, "down-project", false, "Drops project when the first container stops")
return cmd
}
func runWait(ctx context.Context, dockerCli command.Cli, backend api.Service, opts *waitOptions) (int64, error) {
_, name, err := opts.projectOrName(ctx, dockerCli)
if err != nil {
return 0, err
}
return backend.Wait(ctx, name, api.WaitOptions{
Services: opts.services,
DownProjectOnContainerExit: opts.downProject,
})
}

126
cmd/compose/watch.go Normal file
View File

@ -0,0 +1,126 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package compose
import (
"context"
"fmt"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/internal/locker"
"github.com/docker/compose/v2/pkg/api"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
type watchOptions struct {
*ProjectOptions
prune bool
noUp bool
}
func watchCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
watchOpts := watchOptions{
ProjectOptions: p,
}
buildOpts := buildOptions{
ProjectOptions: p,
}
cmd := &cobra.Command{
Use: "watch [SERVICE...]",
Short: "Watch build context for service and rebuild/refresh containers when files are updated",
PreRunE: Adapt(func(ctx context.Context, args []string) error {
return nil
}),
RunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
if cmd.Parent().Name() == "alpha" {
logrus.Warn("watch command is now available as a top level command")
}
return runWatch(ctx, dockerCli, backend, watchOpts, buildOpts, args)
}),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
cmd.Flags().BoolVar(&buildOpts.quiet, "quiet", false, "hide build output")
cmd.Flags().BoolVar(&watchOpts.prune, "prune", true, "Prune dangling images on rebuild")
cmd.Flags().BoolVar(&watchOpts.noUp, "no-up", false, "Do not build & start services before watching")
return cmd
}
func runWatch(ctx context.Context, dockerCli command.Cli, backend api.Service, watchOpts watchOptions, buildOpts buildOptions, services []string) error {
project, _, err := watchOpts.ToProject(ctx, dockerCli, services)
if err != nil {
return err
}
if err := applyPlatforms(project, true); err != nil {
return err
}
build, err := buildOpts.toAPIBuildOptions(nil)
if err != nil {
return err
}
// validation done -- ensure we have the lockfile for this project before doing work
l, err := locker.NewPidfile(project.Name)
if err != nil {
return fmt.Errorf("cannot take exclusive lock for project %q: %w", project.Name, err)
}
if err := l.Lock(); err != nil {
return fmt.Errorf("cannot take exclusive lock for project %q: %w", project.Name, err)
}
if !watchOpts.noUp {
for index, service := range project.Services {
if service.Build != nil && service.Develop != nil {
service.PullPolicy = types.PullPolicyBuild
}
project.Services[index] = service
}
upOpts := api.UpOptions{
Create: api.CreateOptions{
Build: &build,
Services: services,
RemoveOrphans: false,
Recreate: api.RecreateDiverged,
RecreateDependencies: api.RecreateNever,
Inherit: true,
QuietPull: buildOpts.quiet,
},
Start: api.StartOptions{
Project: project,
Attach: nil,
Services: services,
},
}
if err := backend.Up(ctx, project, upOpts); err != nil {
return err
}
}
consumer := formatter.NewLogConsumer(ctx, dockerCli.Out(), dockerCli.Err(), false, false, false)
return backend.Watch(ctx, project, api.WatchOptions{
Build: &build,
LogTo: consumer,
Prune: watchOpts.prune,
Services: services,
})
}

100
cmd/formatter/ansi.go Normal file
View File

@ -0,0 +1,100 @@
/*
Copyright 2024 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package formatter
import (
"fmt"
"github.com/acarl005/stripansi"
)
var disableAnsi bool
func ansi(code string) string {
return fmt.Sprintf("\033%s", code)
}
func saveCursor() {
if disableAnsi {
return
}
fmt.Print(ansi("7"))
}
func restoreCursor() {
if disableAnsi {
return
}
fmt.Print(ansi("8"))
}
func showCursor() {
if disableAnsi {
return
}
fmt.Print(ansi("[?25h"))
}
func moveCursor(y, x int) {
if disableAnsi {
return
}
fmt.Print(ansi(fmt.Sprintf("[%d;%dH", y, x)))
}
func carriageReturn() {
if disableAnsi {
return
}
fmt.Print(ansi(fmt.Sprintf("[%dG", 0)))
}
func clearLine() {
if disableAnsi {
return
}
// Does not move cursor from its current position
fmt.Print(ansi("[2K"))
}
func moveCursorUp(lines int) {
if disableAnsi {
return
}
// Does not add new lines
fmt.Print(ansi(fmt.Sprintf("[%dA", lines)))
}
func moveCursorDown(lines int) {
if disableAnsi {
return
}
// Does not add new lines
fmt.Print(ansi(fmt.Sprintf("[%dB", lines)))
}
func newLine() {
// Like \n
fmt.Print("\012")
}
func lenAnsi(s string) int {
// len has into consideration ansi codes, if we want
// the len of the actual len(string) we need to strip
// all ansi codes
return len(stripansi.Strip(s))
}

View File

@ -18,10 +18,11 @@ package formatter
import (
"fmt"
"os"
"strconv"
"strings"
"sync"
"github.com/mattn/go-isatty"
"github.com/docker/cli/cli/command"
)
var names = []string{
@ -35,6 +36,18 @@ var names = []string{
"white",
}
const (
BOLD = "1"
FAINT = "2"
ITALIC = "3"
UNDERLINE = "4"
)
const (
RESET = "0"
CYAN = "36"
)
const (
// Never use ANSI codes
Never = "never"
@ -46,21 +59,25 @@ const (
Auto = "auto"
)
// ansiColorOffset is the offset for basic foreground colors in ANSI escape codes.
const ansiColorOffset = 30
// SetANSIMode configure formatter for colored output on ANSI-compliant console
func SetANSIMode(ansi string) {
if !useAnsi(ansi) {
func SetANSIMode(streams command.Streams, ansi string) {
if !useAnsi(streams, ansi) {
nextColor = func() colorFunc {
return monochrome
}
disableAnsi = true
}
}
func useAnsi(ansi string) bool {
func useAnsi(streams command.Streams, ansi string) bool {
switch ansi {
case Always:
return true
case Auto:
return isatty.IsTerminal(os.Stdout.Fd())
return streams.Out().IsTerminal()
}
return false
}
@ -72,12 +89,21 @@ var monochrome = func(s string) string {
return s
}
func ansiColor(code, s string) string {
return fmt.Sprintf("%s%s%s", ansi(code), s, ansi("0"))
func ansiColor(code, s string, formatOpts ...string) string {
return fmt.Sprintf("%s%s%s", ansiColorCode(code, formatOpts...), s, ansiColorCode("0"))
}
func ansi(code string) string {
return fmt.Sprintf("\033[%sm", code)
// Everything about ansiColorCode color https://hyperskill.org/learn/step/18193
func ansiColorCode(code string, formatOpts ...string) string {
var sb strings.Builder
sb.WriteString("\033[")
for _, c := range formatOpts {
sb.WriteString(c)
sb.WriteString(";")
}
sb.WriteString(code)
sb.WriteString("m")
return sb.String()
}
func makeColorFunc(code string) colorFunc {
@ -86,39 +112,37 @@ func makeColorFunc(code string) colorFunc {
}
}
var nextColor = rainbowColor
var (
nextColor = rainbowColor
rainbow []colorFunc
currentIndex = 0
mutex sync.Mutex
)
func rainbowColor() colorFunc {
return <-loop
mutex.Lock()
defer mutex.Unlock()
result := rainbow[currentIndex]
currentIndex = (currentIndex + 1) % len(rainbow)
return result
}
var loop = make(chan colorFunc)
func init() {
colors := map[string]colorFunc{}
for i, name := range names {
colors[name] = makeColorFunc(strconv.Itoa(30 + i))
colors["intense_"+name] = makeColorFunc(strconv.Itoa(30+i) + ";1")
colors[name] = makeColorFunc(strconv.Itoa(ansiColorOffset + i))
colors["intense_"+name] = makeColorFunc(strconv.Itoa(ansiColorOffset+i) + ";1")
}
rainbow = []colorFunc{
colors["cyan"],
colors["yellow"],
colors["green"],
colors["magenta"],
colors["blue"],
colors["intense_cyan"],
colors["intense_yellow"],
colors["intense_green"],
colors["intense_magenta"],
colors["intense_blue"],
}
go func() {
i := 0
rainbow := []colorFunc{
colors["cyan"],
colors["yellow"],
colors["green"],
colors["magenta"],
colors["blue"],
colors["intense_cyan"],
colors["intense_yellow"],
colors["intense_green"],
colors["intense_magenta"],
colors["intense_blue"],
}
for {
loop <- rainbow[i]
i = (i + 1) % len(rainbow)
}
}()
}

View File

@ -17,10 +17,13 @@
package formatter
const (
// JSON is the constant for Json formats on list commands
// JSON Print in JSON format
JSON = "json"
// TemplateLegacyJSON the legacy json formatting value using go template
TemplateLegacyJSON = "{{json.}}"
// PRETTY is the constant for default formats on list commands
// Deprecated: use TABLE
PRETTY = "pretty"
// TABLE Print output in table format with column headers (default)
TABLE = "table"
)

287
cmd/formatter/container.go Normal file
View File

@ -0,0 +1,287 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package formatter
import (
"fmt"
"strconv"
"strings"
"time"
"github.com/docker/cli/cli/command/formatter"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/go-units"
)
const (
defaultContainerTableFormat = "table {{.Name}}\t{{.Image}}\t{{.Command}}\t{{.Service}}\t{{.RunningFor}}\t{{.Status}}\t{{.Ports}}"
nameHeader = "NAME"
projectHeader = "PROJECT"
serviceHeader = "SERVICE"
commandHeader = "COMMAND"
runningForHeader = "CREATED"
mountsHeader = "MOUNTS"
localVolumes = "LOCAL VOLUMES"
networksHeader = "NETWORKS"
)
// NewContainerFormat returns a Format for rendering using a Context
func NewContainerFormat(source string, quiet bool, size bool) formatter.Format {
switch source {
case formatter.TableFormatKey, "": // table formatting is the default if none is set.
if quiet {
return formatter.DefaultQuietFormat
}
format := defaultContainerTableFormat
if size {
format += `\t{{.Size}}`
}
return formatter.Format(format)
case formatter.RawFormatKey:
if quiet {
return `container_id: {{.ID}}`
}
format := `container_id: {{.ID}}
image: {{.Image}}
command: {{.Command}}
created_at: {{.CreatedAt}}
state: {{- pad .State 1 0}}
status: {{- pad .Status 1 0}}
names: {{.Names}}
labels: {{- pad .Labels 1 0}}
ports: {{- pad .Ports 1 0}}
`
if size {
format += `size: {{.Size}}\n`
}
return formatter.Format(format)
default: // custom format
if quiet {
return formatter.DefaultQuietFormat
}
return formatter.Format(source)
}
}
// ContainerWrite renders the context for a list of containers
func ContainerWrite(ctx formatter.Context, containers []api.ContainerSummary) error {
render := func(format func(subContext formatter.SubContext) error) error {
for _, container := range containers {
err := format(&ContainerContext{trunc: ctx.Trunc, c: container})
if err != nil {
return err
}
}
return nil
}
return ctx.Write(NewContainerContext(), render)
}
// ContainerContext is a struct used for rendering a list of containers in a Go template.
type ContainerContext struct {
formatter.HeaderContext
trunc bool
c api.ContainerSummary
// FieldsUsed is used in the pre-processing step to detect which fields are
// used in the template. It's currently only used to detect use of the .Size
// field which (if used) automatically sets the '--size' option when making
// the API call.
FieldsUsed map[string]interface{}
}
// NewContainerContext creates a new context for rendering containers
func NewContainerContext() *ContainerContext {
containerCtx := ContainerContext{}
containerCtx.Header = formatter.SubHeaderContext{
"ID": formatter.ContainerIDHeader,
"Name": nameHeader,
"Project": projectHeader,
"Service": serviceHeader,
"Image": formatter.ImageHeader,
"Command": commandHeader,
"CreatedAt": formatter.CreatedAtHeader,
"RunningFor": runningForHeader,
"Ports": formatter.PortsHeader,
"State": formatter.StateHeader,
"Status": formatter.StatusHeader,
"Size": formatter.SizeHeader,
"Labels": formatter.LabelsHeader,
}
return &containerCtx
}
// MarshalJSON makes ContainerContext implement json.Marshaler
func (c *ContainerContext) MarshalJSON() ([]byte, error) {
return formatter.MarshalJSON(c)
}
// ID returns the container's ID as a string. Depending on the `--no-trunc`
// option being set, the full or truncated ID is returned.
func (c *ContainerContext) ID() string {
if c.trunc {
return stringid.TruncateID(c.c.ID)
}
return c.c.ID
}
func (c *ContainerContext) Name() string {
return c.c.Name
}
// Names returns a comma-separated string of the container's names, with their
// slash (/) prefix stripped. Additional names for the container (related to the
// legacy `--link` feature) are omitted.
func (c *ContainerContext) Names() string {
names := formatter.StripNamePrefix(c.c.Names)
if c.trunc {
for _, name := range names {
if len(strings.Split(name, "/")) == 1 {
names = []string{name}
break
}
}
}
return strings.Join(names, ",")
}
func (c *ContainerContext) Service() string {
return c.c.Service
}
func (c *ContainerContext) Project() string {
return c.c.Project
}
func (c *ContainerContext) Image() string {
return c.c.Image
}
func (c *ContainerContext) Command() string {
command := c.c.Command
if c.trunc {
command = formatter.Ellipsis(command, 20)
}
return strconv.Quote(command)
}
func (c *ContainerContext) CreatedAt() string {
return time.Unix(c.c.Created, 0).String()
}
func (c *ContainerContext) RunningFor() string {
createdAt := time.Unix(c.c.Created, 0)
return units.HumanDuration(time.Now().UTC().Sub(createdAt)) + " ago"
}
func (c *ContainerContext) ExitCode() int {
return c.c.ExitCode
}
func (c *ContainerContext) State() string {
return c.c.State
}
func (c *ContainerContext) Status() string {
return c.c.Status
}
func (c *ContainerContext) Health() string {
return c.c.Health
}
func (c *ContainerContext) Publishers() api.PortPublishers {
return c.c.Publishers
}
func (c *ContainerContext) Ports() string {
var ports []container.Port
for _, publisher := range c.c.Publishers {
ports = append(ports, container.Port{
IP: publisher.URL,
PrivatePort: uint16(publisher.TargetPort),
PublicPort: uint16(publisher.PublishedPort),
Type: publisher.Protocol,
})
}
return formatter.DisplayablePorts(ports)
}
// Labels returns a comma-separated string of labels present on the container.
func (c *ContainerContext) Labels() string {
if c.c.Labels == nil {
return ""
}
var joinLabels []string
for k, v := range c.c.Labels {
joinLabels = append(joinLabels, fmt.Sprintf("%s=%s", k, v))
}
return strings.Join(joinLabels, ",")
}
// Label returns the value of the label with the given name or an empty string
// if the given label does not exist.
func (c *ContainerContext) Label(name string) string {
if c.c.Labels == nil {
return ""
}
return c.c.Labels[name]
}
// Mounts returns a comma-separated string of mount names present on the container.
// If the trunc option is set, names can be truncated (ellipsized).
func (c *ContainerContext) Mounts() string {
var mounts []string
for _, name := range c.c.Mounts {
if c.trunc {
name = formatter.Ellipsis(name, 15)
}
mounts = append(mounts, name)
}
return strings.Join(mounts, ",")
}
// LocalVolumes returns the number of volumes using the "local" volume driver.
func (c *ContainerContext) LocalVolumes() string {
return fmt.Sprintf("%d", c.c.LocalVolumes)
}
// Networks returns a comma-separated string of networks that the container is
// attached to.
func (c *ContainerContext) Networks() string {
return strings.Join(c.c.Networks, ",")
}
// Size returns the container's size and virtual size (e.g. "2B (virtual 21.5MB)")
func (c *ContainerContext) Size() string {
if c.FieldsUsed == nil {
c.FieldsUsed = map[string]interface{}{}
}
c.FieldsUsed["Size"] = struct{}{}
srw := units.HumanSizeWithPrecision(float64(c.c.SizeRw), 3)
sv := units.HumanSizeWithPrecision(float64(c.c.SizeRootFs), 3)
sf := srw
if c.c.SizeRootFs > 0 {
sf = fmt.Sprintf("%s (virtual %s)", srw, sv)
}
return sf
}

View File

@ -23,14 +23,12 @@ import (
"strings"
"github.com/docker/compose/v2/pkg/api"
"github.com/pkg/errors"
)
// Print prints formatted lists in different formats
func Print(toJSON interface{}, format string, outWriter io.Writer, writerFn func(w io.Writer), headers ...string) error {
switch strings.ToLower(format) {
case PRETTY, "":
case TABLE, PRETTY, "":
return PrintPrettySection(outWriter, writerFn, headers...)
case TemplateLegacyJSON:
switch reflect.TypeOf(toJSON).Kind() {
@ -67,7 +65,7 @@ func Print(toJSON interface{}, format string, outWriter io.Writer, writerFn func
_, _ = fmt.Fprintln(outWriter, outJSON)
}
default:
return errors.Wrapf(api.ErrParsingFailed, "format value %q could not be parsed", format)
return fmt.Errorf("format value %q could not be parsed: %w", format, api.ErrParsingFailed)
}
return nil
}

View File

@ -22,7 +22,8 @@ import (
"io"
"testing"
"gotest.tools/assert"
"go.uber.org/goleak"
"gotest.tools/v3/assert"
)
type testStruct struct {
@ -71,3 +72,7 @@ func TestPrint(t *testing.T) {
{"Name":"myName2","Status":"myStatus2"}
`)
}
func TestColorsGoroutinesLeak(t *testing.T) {
goleak.VerifyNone(t)
}

View File

@ -23,38 +23,69 @@ import (
"strconv"
"strings"
"sync"
"time"
"github.com/buger/goterm"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/docker/pkg/jsonmessage"
)
// LogConsumer consume logs from services and format them
type logConsumer struct {
ctx context.Context
presenters sync.Map // map[string]*presenter
width int
stdout io.Writer
stderr io.Writer
color bool
prefix bool
timestamp bool
}
// NewLogConsumer creates a new LogConsumer
func NewLogConsumer(ctx context.Context, w io.Writer, color bool, prefix bool) api.LogConsumer {
func NewLogConsumer(ctx context.Context, stdout, stderr io.Writer, color, prefix, timestamp bool) api.LogConsumer {
return &logConsumer{
ctx: ctx,
presenters: sync.Map{},
width: 0,
writer: w,
stdout: stdout,
stderr: stderr,
color: color,
prefix: prefix,
timestamp: timestamp,
}
}
func (l *logConsumer) Register(name string) {
l.register(name)
}
func (l *logConsumer) register(name string) *presenter {
cf := monochrome
if l.color {
cf = nextColor()
}
p := &presenter{
colors: cf,
name: name,
var p *presenter
root, _, found := strings.Cut(name, " ")
if found {
parent := l.getPresenter(root)
p = &presenter{
colors: parent.colors,
name: name,
prefix: parent.prefix,
}
} else {
cf := monochrome
if l.color {
switch name {
case "":
cf = monochrome
case api.WatchLogger:
cf = makeColorFunc("92")
default:
cf = nextColor()
}
}
p = &presenter{
colors: cf,
name: name,
}
}
l.presenters.Store(name, p)
l.computeWidth()
if l.prefix {
l.computeWidth()
l.presenters.Range(func(key, value interface{}) bool {
p := value.(*presenter)
p.setPrefix(l.width)
@ -73,20 +104,34 @@ func (l *logConsumer) getPresenter(container string) *presenter {
}
// Log formats a log message as received from name/container
func (l *logConsumer) Log(container, service, message string) {
func (l *logConsumer) Log(container, message string) {
l.write(l.stdout, container, message)
}
// Err formats a log message as received from name/container
func (l *logConsumer) Err(container, message string) {
l.write(l.stderr, container, message)
}
func (l *logConsumer) write(w io.Writer, container, message string) {
if l.ctx.Err() != nil {
return
}
p := l.getPresenter(container)
timestamp := time.Now().Format(jsonmessage.RFC3339NanoFixed)
for _, line := range strings.Split(message, "\n") {
fmt.Fprintf(l.writer, "%s%s\n", p.prefix, line) // nolint:errcheck
if l.timestamp {
_, _ = fmt.Fprintf(w, "%s%s %s\n", p.prefix, timestamp, line)
} else {
_, _ = fmt.Fprintf(w, "%s%s\n", p.prefix, line)
}
}
}
func (l *logConsumer) Status(container, msg string) {
p := l.getPresenter(container)
s := p.colors(fmt.Sprintf("%s %s\n", container, msg))
l.writer.Write([]byte(s)) // nolint:errcheck
s := p.colors(fmt.Sprintf("%s%s %s\n", goterm.RESET_LINE, container, msg))
l.stdout.Write([]byte(s)) //nolint:errcheck
}
func (l *logConsumer) computeWidth() {
@ -101,16 +146,6 @@ func (l *logConsumer) computeWidth() {
l.width = width + 1
}
// LogConsumer consume logs from services and format them
type logConsumer struct {
ctx context.Context
presenters sync.Map // map[string]*presenter
width int
writer io.Writer
color bool
prefix bool
}
type presenter struct {
colors colorFunc
name string
@ -118,5 +153,33 @@ type presenter struct {
}
func (p *presenter) setPrefix(width int) {
if p.name == api.WatchLogger {
p.prefix = p.colors(strings.Repeat(" ", width) + " ⦿ ")
return
}
p.prefix = p.colors(fmt.Sprintf("%-"+strconv.Itoa(width)+"s | ", p.name))
}
type logDecorator struct {
decorated api.LogConsumer
Before func()
After func()
}
func (l logDecorator) Log(containerName, message string) {
l.Before()
l.decorated.Log(containerName, message)
l.After()
}
func (l logDecorator) Err(containerName, message string) {
l.Before()
l.decorated.Err(containerName, message)
l.After()
}
func (l logDecorator) Status(container, msg string) {
l.Before()
l.decorated.Status(container, msg)
l.After()
}

359
cmd/formatter/shortcut.go Normal file
View File

@ -0,0 +1,359 @@
/*
Copyright 2024 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package formatter
import (
"context"
"errors"
"fmt"
"math"
"os"
"syscall"
"time"
"github.com/buger/goterm"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/compose/v2/internal/tracing"
"github.com/docker/compose/v2/pkg/api"
"github.com/eiannone/keyboard"
"github.com/skratchdot/open-golang/open"
)
const DISPLAY_ERROR_TIME = 10
type KeyboardError struct {
err error
timeStart time.Time
}
func (ke *KeyboardError) shouldDisplay() bool {
return ke.err != nil && int(time.Since(ke.timeStart).Seconds()) < DISPLAY_ERROR_TIME
}
func (ke *KeyboardError) printError(height int, info string) {
if ke.shouldDisplay() {
errMessage := ke.err.Error()
moveCursor(height-1-extraLines(info)-extraLines(errMessage), 0)
clearLine()
fmt.Print(errMessage)
}
}
func (ke *KeyboardError) addError(prefix string, err error) {
ke.timeStart = time.Now()
prefix = ansiColor(CYAN, fmt.Sprintf("%s →", prefix), BOLD)
errorString := fmt.Sprintf("%s %s", prefix, err.Error())
ke.err = errors.New(errorString)
}
func (ke *KeyboardError) error() string {
return ke.err.Error()
}
type KeyboardWatch struct {
Watching bool
Watcher Feature
}
// Feature is an compose feature that can be started/stopped by a menu command
type Feature interface {
Start(context.Context) error
Stop() error
}
type KEYBOARD_LOG_LEVEL int
const (
NONE KEYBOARD_LOG_LEVEL = 0
INFO KEYBOARD_LOG_LEVEL = 1
DEBUG KEYBOARD_LOG_LEVEL = 2
)
type LogKeyboard struct {
kError KeyboardError
Watch *KeyboardWatch
IsDockerDesktopActive bool
logLevel KEYBOARD_LOG_LEVEL
signalChannel chan<- os.Signal
}
func NewKeyboardManager(isDockerDesktopActive bool, sc chan<- os.Signal) *LogKeyboard {
return &LogKeyboard{
IsDockerDesktopActive: isDockerDesktopActive,
logLevel: INFO,
signalChannel: sc,
}
}
func (lk *LogKeyboard) Decorate(l api.LogConsumer) api.LogConsumer {
return logDecorator{
decorated: l,
Before: lk.clearNavigationMenu,
After: lk.PrintKeyboardInfo,
}
}
func (lk *LogKeyboard) PrintKeyboardInfo() {
if lk.logLevel == INFO {
lk.printNavigationMenu()
}
}
// Creates space to print error and menu string
func (lk *LogKeyboard) createBuffer(lines int) {
if lk.kError.shouldDisplay() {
extraLines := extraLines(lk.kError.error()) + 1
lines += extraLines
}
// get the string
infoMessage := lk.navigationMenu()
// calculate how many lines we need to display the menu info
// might be needed a line break
extraLines := extraLines(infoMessage) + 1
lines += extraLines
if lines > 0 {
allocateSpace(lines)
moveCursorUp(lines)
}
}
func (lk *LogKeyboard) printNavigationMenu() {
offset := 1
lk.clearNavigationMenu()
lk.createBuffer(offset)
if lk.logLevel == INFO {
height := goterm.Height()
menu := lk.navigationMenu()
carriageReturn()
saveCursor()
lk.kError.printError(height, menu)
moveCursor(height-extraLines(menu), 0)
clearLine()
fmt.Print(menu)
carriageReturn()
restoreCursor()
}
}
func (lk *LogKeyboard) navigationMenu() string {
var openDDInfo string
if lk.IsDockerDesktopActive {
openDDInfo = shortcutKeyColor("v") + navColor(" View in Docker Desktop")
}
var openDDUI string
if openDDInfo != "" {
openDDUI = navColor(" ")
}
if lk.IsDockerDesktopActive {
openDDUI = openDDUI + shortcutKeyColor("o") + navColor(" View Config")
}
var watchInfo string
if openDDInfo != "" || openDDUI != "" {
watchInfo = navColor(" ")
}
isEnabled := " Enable"
if lk.Watch != nil && lk.Watch.Watching {
isEnabled = " Disable"
}
watchInfo = watchInfo + shortcutKeyColor("w") + navColor(isEnabled+" Watch")
return openDDInfo + openDDUI + watchInfo
}
func (lk *LogKeyboard) clearNavigationMenu() {
height := goterm.Height()
carriageReturn()
saveCursor()
// clearLine()
for i := 0; i < height; i++ {
moveCursorDown(1)
clearLine()
}
restoreCursor()
}
func (lk *LogKeyboard) openDockerDesktop(ctx context.Context, project *types.Project) {
if !lk.IsDockerDesktopActive {
return
}
go func() {
_ = tracing.EventWrapFuncForErrGroup(ctx, "menu/gui", tracing.SpanOptions{},
func(ctx context.Context) error {
link := fmt.Sprintf("docker-desktop://dashboard/apps/%s", project.Name)
err := open.Run(link)
if err != nil {
err = fmt.Errorf("could not open Docker Desktop")
lk.keyboardError("View", err)
}
return err
})()
}()
}
func (lk *LogKeyboard) openDDComposeUI(ctx context.Context, project *types.Project) {
if !lk.IsDockerDesktopActive {
return
}
go func() {
_ = tracing.EventWrapFuncForErrGroup(ctx, "menu/gui/composeview", tracing.SpanOptions{},
func(ctx context.Context) error {
link := fmt.Sprintf("docker-desktop://dashboard/docker-compose/%s", project.Name)
err := open.Run(link)
if err != nil {
err = fmt.Errorf("could not open Docker Desktop Compose UI")
lk.keyboardError("View Config", err)
}
return err
})()
}()
}
func (lk *LogKeyboard) openDDWatchDocs(ctx context.Context, project *types.Project) {
go func() {
_ = tracing.EventWrapFuncForErrGroup(ctx, "menu/gui/watch", tracing.SpanOptions{},
func(ctx context.Context) error {
link := fmt.Sprintf("docker-desktop://dashboard/docker-compose/%s/watch", project.Name)
err := open.Run(link)
if err != nil {
err = fmt.Errorf("could not open Docker Desktop Compose UI")
lk.keyboardError("Watch Docs", err)
}
return err
})()
}()
}
func (lk *LogKeyboard) keyboardError(prefix string, err error) {
lk.kError.addError(prefix, err)
lk.printNavigationMenu()
timer1 := time.NewTimer((DISPLAY_ERROR_TIME + 1) * time.Second)
go func() {
<-timer1.C
lk.printNavigationMenu()
}()
}
func (lk *LogKeyboard) ToggleWatch(ctx context.Context, options api.UpOptions) {
if lk.Watch == nil {
return
}
if lk.Watch.Watching {
err := lk.Watch.Watcher.Stop()
if err != nil {
options.Start.Attach.Err(api.WatchLogger, err.Error())
} else {
lk.Watch.Watching = false
}
} else {
go func() {
_ = tracing.EventWrapFuncForErrGroup(ctx, "menu/watch", tracing.SpanOptions{},
func(ctx context.Context) error {
err := lk.Watch.Watcher.Start(ctx)
if err != nil {
options.Start.Attach.Err(api.WatchLogger, err.Error())
} else {
lk.Watch.Watching = true
}
return err
})()
}()
}
}
func (lk *LogKeyboard) HandleKeyEvents(ctx context.Context, event keyboard.KeyEvent, project *types.Project, options api.UpOptions) {
switch kRune := event.Rune; kRune {
case 'v':
lk.openDockerDesktop(ctx, project)
case 'w':
if lk.Watch == nil {
// we try to open watch docs if DD is installed
if lk.IsDockerDesktopActive {
lk.openDDWatchDocs(ctx, project)
}
// either way we mark menu/watch as an error
go func() {
_ = tracing.EventWrapFuncForErrGroup(ctx, "menu/watch", tracing.SpanOptions{},
func(ctx context.Context) error {
err := fmt.Errorf("watch is not yet configured. Learn more: %s", ansiColor(CYAN, "https://docs.docker.com/compose/file-watch/"))
lk.keyboardError("Watch", err)
return err
})()
}()
}
lk.ToggleWatch(ctx, options)
case 'o':
lk.openDDComposeUI(ctx, project)
}
switch key := event.Key; key {
case keyboard.KeyCtrlC:
_ = keyboard.Close()
lk.clearNavigationMenu()
showCursor()
lk.logLevel = NONE
// will notify main thread to kill and will handle gracefully
lk.signalChannel <- syscall.SIGINT
case keyboard.KeyEnter:
newLine()
lk.printNavigationMenu()
}
}
func (lk *LogKeyboard) EnableWatch(enabled bool, watcher Feature) {
lk.Watch = &KeyboardWatch{
Watching: enabled,
Watcher: watcher,
}
}
func allocateSpace(lines int) {
for i := 0; i < lines; i++ {
clearLine()
newLine()
carriageReturn()
}
}
func extraLines(s string) int {
return int(math.Floor(float64(lenAnsi(s)) / float64(goterm.Width())))
}
func shortcutKeyColor(key string) string {
foreground := "38;2"
black := "0;0;0"
background := "48;2"
white := "255;255;255"
return ansiColor(foreground+";"+black+";"+background+";"+white, key, BOLD)
}
func navColor(key string) string {
return ansiColor(FAINT, key)
}

View File

@ -20,48 +20,77 @@ import (
"os"
dockercli "github.com/docker/cli/cli"
"github.com/docker/cli/cli-plugins/manager"
"github.com/docker/cli/cli-plugins/metadata"
"github.com/docker/cli/cli-plugins/plugin"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/cmd/cmdtrace"
"github.com/docker/docker/client"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/cmd/compatibility"
commands "github.com/docker/compose/v2/cmd/compose"
"github.com/docker/compose/v2/internal"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/compose"
)
func pluginMain() {
plugin.Run(func(dockerCli command.Cli) *cobra.Command {
lazyInit := api.NewServiceProxy()
cmd := commands.RootCommand(dockerCli, lazyInit)
originalPreRun := cmd.PersistentPreRunE
// TODO(milas): this cast is safe but we should not need to do this,
// we should expose the concrete service type so that we do not need
// to rely on the `api.Service` interface internally
backend := compose.NewComposeService(dockerCli).(commands.Backend)
cmd := commands.RootCommand(dockerCli, backend)
originalPreRunE := cmd.PersistentPreRunE
cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
// initialize the dockerCli instance
if err := plugin.PersistentPreRunE(cmd, args); err != nil {
return err
}
lazyInit.WithService(compose.NewComposeService(dockerCli))
if originalPreRun != nil {
return originalPreRun(cmd, args)
// compose-specific initialization
dockerCliPostInitialize(dockerCli)
if err := cmdtrace.Setup(cmd, dockerCli, os.Args[1:]); err != nil {
logrus.Debugf("failed to enable tracing: %v", err)
}
if originalPreRunE != nil {
return originalPreRunE(cmd, args)
}
return nil
}
cmd.SetFlagErrorFunc(func(c *cobra.Command, err error) error {
return dockercli.StatusError{
StatusCode: compose.CommandSyntaxFailure.ExitCode,
StatusCode: 1,
Status: err.Error(),
}
})
return cmd
},
manager.Metadata{
metadata.Metadata{
SchemaVersion: "0.1.0",
Vendor: "Docker Inc.",
Version: internal.Version,
})
}
// dockerCliPostInitialize performs Compose-specific configuration for the
// command.Cli instance provided by the plugin.Run() initialization.
//
// NOTE: This must be called AFTER plugin.PersistentPreRunE.
func dockerCliPostInitialize(dockerCli command.Cli) {
// HACK(milas): remove once docker/cli#4574 is merged; for now,
// set it in a rather roundabout way by grabbing the underlying
// concrete client and manually invoking an option on it
_ = dockerCli.Apply(func(cli *command.DockerCli) error {
if mobyClient, ok := cli.Client().(*client.Client); ok {
_ = client.WithUserAgent("compose/" + internal.Version)(mobyClient)
}
return nil
})
}
func main() {
if plugin.RunningStandalone() {
os.Args = append([]string{"docker"}, compatibility.Convert(os.Args[1:])...)

21
codecov.yml Normal file
View File

@ -0,0 +1,21 @@
coverage:
status:
project:
default:
informational: true
target: auto
threshold: 2%
patch:
default:
informational: true
comment:
require_changes: true
ignore:
- "packaging"
- "docs"
- "bin"
- "e2e"
- "pkg/e2e"
- "**/*_test.go"

148
docker-bake.hcl Normal file
View File

@ -0,0 +1,148 @@
// Copyright 2022 Docker Compose CLI authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
variable "GO_VERSION" {
# default ARG value set in Dockerfile
default = null
}
variable "BUILD_TAGS" {
default = "e2e"
}
variable "DOCS_FORMATS" {
default = "md,yaml"
}
# Defines the output folder to override the default behavior.
# See Makefile for details, this is generally only useful for
# the packaging scripts and care should be taken to not break
# them.
variable "DESTDIR" {
default = ""
}
function "outdir" {
params = [defaultdir]
result = DESTDIR != "" ? DESTDIR : "${defaultdir}"
}
# Special target: https://github.com/docker/metadata-action#bake-definition
target "meta-helper" {}
target "_common" {
args = {
GO_VERSION = GO_VERSION
BUILD_TAGS = BUILD_TAGS
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
}
}
group "default" {
targets = ["binary"]
}
group "validate" {
targets = ["lint", "vendor-validate", "license-validate"]
}
target "lint" {
inherits = ["_common"]
target = "lint"
output = ["type=cacheonly"]
}
target "license-validate" {
target = "license-validate"
output = ["type=cacheonly"]
}
target "license-update" {
target = "license-update"
output = ["."]
}
target "vendor-validate" {
inherits = ["_common"]
target = "vendor-validate"
output = ["type=cacheonly"]
}
target "vendor-update" {
inherits = ["_common"]
target = "vendor-update"
output = ["."]
}
target "test" {
inherits = ["_common"]
target = "test-coverage"
output = [outdir("./bin/coverage/unit")]
}
target "binary-with-coverage" {
inherits = ["_common"]
target = "binary"
args = {
BUILD_FLAGS = "-cover -covermode=atomic"
}
output = [outdir("./bin/build")]
platforms = ["local"]
}
target "binary" {
inherits = ["_common"]
target = "binary"
output = [outdir("./bin/build")]
platforms = ["local"]
}
target "binary-cross" {
inherits = ["binary"]
platforms = [
"darwin/amd64",
"darwin/arm64",
"linux/amd64",
"linux/arm/v6",
"linux/arm/v7",
"linux/arm64",
"linux/ppc64le",
"linux/riscv64",
"linux/s390x",
"windows/amd64",
"windows/arm64"
]
}
target "release" {
inherits = ["binary-cross"]
target = "release"
output = [outdir("./bin/release")]
}
target "docs-validate" {
inherits = ["_common"]
target = "docs-validate"
output = ["type=cacheonly"]
}
target "docs-update" {
inherits = ["_common"]
target = "docs-update"
output = ["./docs"]
}
target "image-cross" {
inherits = ["meta-helper", "binary-cross"]
output = ["type=image"]
}

View File

@ -1,57 +0,0 @@
# syntax=docker/dockerfile:1.3-labs
# Copyright 2020 Docker Compose CLI authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG GO_VERSION=1.18.2
ARG FORMATS=md,yaml
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine AS docsgen
WORKDIR /src
RUN --mount=target=. \
--mount=target=/root/.cache,type=cache \
go build -o /out/docsgen ./docs/yaml/main/generate.go
FROM --platform=${BUILDPLATFORM} alpine AS gen
RUN apk add --no-cache rsync git
WORKDIR /src
COPY --from=docsgen /out/docsgen /usr/bin
ARG FORMATS
RUN --mount=target=/context \
--mount=target=.,type=tmpfs <<EOT
set -e
rsync -a /context/. .
docsgen --formats "$FORMATS" --source "docs/reference"
mkdir /out
cp -r docs/reference /out
EOT
FROM scratch AS update
COPY --from=gen /out /out
FROM gen AS validate
RUN --mount=target=/context \
--mount=target=.,type=tmpfs <<EOT
set -e
rsync -a /context/. .
git add -A
rm -rf docs/reference/*
cp -rf /out/* ./docs/
if [ -n "$(git status --porcelain -- docs/reference)" ]; then
echo >&2 'ERROR: Docs result differs. Please update with "make docs"'
git status --porcelain -- docs/reference
exit 1
fi
EOT

152
docs/examples/provider.go Normal file
View File

@ -0,0 +1,152 @@
/*
Copyright 2020 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"encoding/json"
"fmt"
"os"
"time"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
func main() {
cmd := &cobra.Command{
Short: "Compose Provider Example",
Use: "demo",
}
cmd.AddCommand(composeCommand())
err := cmd.Execute()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
type options struct {
db string
size int
}
func composeCommand() *cobra.Command {
c := &cobra.Command{
Use: "compose EVENT",
TraverseChildren: true,
}
c.PersistentFlags().String("project-name", "", "compose project name") // unused
var options options
upCmd := &cobra.Command{
Use: "up",
Run: func(_ *cobra.Command, args []string) {
up(options, args)
},
Args: cobra.ExactArgs(1),
}
upCmd.Flags().StringVar(&options.db, "type", "", "Database type (mysql, postgres, etc.)")
_ = upCmd.MarkFlagRequired("type")
upCmd.Flags().IntVar(&options.size, "size", 10, "Database size in GB")
upCmd.Flags().String("name", "", "Name of the database to be created")
_ = upCmd.MarkFlagRequired("name")
downCmd := &cobra.Command{
Use: "down",
Run: down,
Args: cobra.ExactArgs(1),
}
downCmd.Flags().String("name", "", "Name of the database to be deleted")
_ = downCmd.MarkFlagRequired("name")
c.AddCommand(upCmd, downCmd)
c.AddCommand(metadataCommand(upCmd, downCmd))
return c
}
const lineSeparator = "\n"
func up(options options, args []string) {
servicename := args[0]
fmt.Printf(`{ "type": "debug", "message": "Starting %s" }%s`, servicename, lineSeparator)
for i := 0; i < options.size; i += 10 {
time.Sleep(1 * time.Second)
fmt.Printf(`{ "type": "info", "message": "Processing ... %d%%" }%s`, i*100/options.size, lineSeparator)
}
fmt.Printf(`{ "type": "setenv", "message": "URL=https://magic.cloud/%s" }%s`, servicename, lineSeparator)
}
func down(_ *cobra.Command, _ []string) {
fmt.Printf(`{ "type": "error", "message": "Permission error" }%s`, lineSeparator)
}
func metadataCommand(upCmd, downCmd *cobra.Command) *cobra.Command {
return &cobra.Command{
Use: "metadata",
Run: func(cmd *cobra.Command, _ []string) {
metadata(upCmd, downCmd)
},
Args: cobra.NoArgs,
}
}
func metadata(upCmd, downCmd *cobra.Command) {
metadata := ProviderMetadata{}
metadata.Description = "Manage services on AwesomeCloud"
metadata.Up = commandParameters(upCmd)
metadata.Down = commandParameters(downCmd)
jsonMetadata, err := json.Marshal(metadata)
if err != nil {
panic(err)
}
fmt.Println(string(jsonMetadata))
}
func commandParameters(cmd *cobra.Command) CommandMetadata {
cmdMetadata := CommandMetadata{}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
_, isRequired := f.Annotations[cobra.BashCompOneRequiredFlag]
cmdMetadata.Parameters = append(cmdMetadata.Parameters, Metadata{
Name: f.Name,
Description: f.Usage,
Required: isRequired,
Type: f.Value.Type(),
Default: f.DefValue,
})
})
return cmdMetadata
}
type ProviderMetadata struct {
Description string `json:"description"`
Up CommandMetadata `json:"up"`
Down CommandMetadata `json:"down"`
}
type CommandMetadata struct {
Parameters []Metadata `json:"parameters"`
}
type Metadata struct {
Name string `json:"name"`
Description string `json:"description"`
Required bool `json:"required"`
Type string `json:"type"`
Default string `json:"default,omitempty"`
}

176
docs/extension.md Normal file
View File

@ -0,0 +1,176 @@
# About
The Compose application model defines `service` as an abstraction for a computing unit managing (a subset of)
application needs, which can interact with other service by relying on network(s). Docker Compose is designed
to use the Docker Engine ("Moby") API to manage services as containers, but the abstraction _could_ also cover
many other runtimes, typically cloud services or services natively provided by host.
The Compose extensibility model has been designed to extend the `service` support to runtimes accessible through
third-party tooling.
# Architecture
Compose extensibility relies on the `provider` attribute to select the actual binary responsible for managing
the resource(s) needed to run a service.
```yaml
database:
provider:
type: awesomecloud
options:
type: mysql
size: 256
name: myAwesomeCloudDB
```
`provider.type` tells Compose the binary to run, which can be either:
- Another Docker CLI plugin (typically, `model` to run `docker-model`)
- An executable in user's `PATH`
If `provider.type` doesn't resolve into any of those, Compose will report an error and interrupt the `up` command.
To be a valid Compose extension, provider command *MUST* accept a `compose` command (which can be hidden)
with subcommands `up` and `down`.
## Up lifecycle
To execute an application's `up` lifecycle, Compose executes the provider's `compose up` command, passing
the project name, service name, and additional options. The `provider.options` are translated
into command line flags. For example:
```console
awesomecloud compose --project-name <NAME> up --type=mysql --size=256 "database"
```
> __Note:__ `project-name` _should_ be used by the provider to tag resources
> set for project, so that later execution with `down` subcommand releases
> all allocated resources set for the project.
## Communication with Compose
Providers can interact with Compose using `stdout` as a channel, sending JSON line delimited messages.
JSON messages MUST include a `type` and a `message` attribute.
```json
{ "type": "info", "message": "preparing mysql ..." }
```
`type` can be either:
- `info`: Reports status updates to the user. Compose will render message as the service state in the progress UI
- `error`: Let's the user know something went wrong with details about the error. Compose will render the message as the reason for the service failure.
- `setenv`: Let's the plugin tell Compose how dependent services can access the created resource. See next section for further details.
- `debug`: Those messages could help debugging the provider, but are not rendered to the user by default. They are rendered when Compose is started with `--verbose` flag.
```mermaid
sequenceDiagram
Shell->>Compose: docker compose up
Compose->>Provider: compose up --project-name=xx --foo=bar "database"
Provider--)Compose: json { "info": "pulling 25%" }
Compose-)Shell: pulling 25%
Provider--)Compose: json { "info": "pulling 50%" }
Compose-)Shell: pulling 50%
Provider--)Compose: json { "info": "pulling 75%" }
Compose-)Shell: pulling 75%
Provider--)Compose: json { "setenv": "URL=http://cloud.com/abcd:1234" }
Compose-)Compose: set DATABASE_URL
Provider-)Compose: EOF (command complete) exit 0
Compose-)Shell: service started
```
## Connection to a service managed by a provider
A service in the Compose application can declare dependency on a service managed by an external provider:
```yaml
services:
app:
image: myapp
depends_on:
- database
database:
provider:
type: awesomecloud
```
When the provider command sends a `setenv` JSON message, Compose injects the specified variable into any dependent service,
automatically prefixing it with the service name. For example, if `awesomecloud compose up` returns:
```json
{"type": "setenv", "message": "URL=https://awesomecloud.com/db:1234"}
```
Then the `app` service, which depends on the service managed by the provider, will receive a `DATABASE_URL` environment variable injected
into its runtime environment.
> __Note:__ The `compose up` provider command _MUST_ be idempotent. If resource is already running, the command _MUST_ set
> the same environment variables to ensure consistent configuration of dependent services.
## Down lifecycle
`down` lifecycle is equivalent to `up` with the `<provider> compose --project-name <NAME> down <SERVICE>` command.
The provider is responsible for releasing all resources associated with the service.
## Provide metadata about options
Compose extensions *MAY* optionally implement a `metadata` subcommand to provide information about the parameters accepted by the `up` and `down` commands.
The `metadata` subcommand takes no parameters and returns a JSON structure on the `stdout` channel that describes the parameters accepted by both the `up` and `down` commands, including whether each parameter is mandatory or optional.
```console
awesomecloud compose metadata
```
The expected JSON output format is:
```json
{
"description": "Manage services on AwesomeCloud",
"up": {
"parameters": [
{
"name": "type",
"description": "Database type (mysql, postgres, etc.)",
"required": true,
"type": "string"
},
{
"name": "size",
"description": "Database size in GB",
"required": false,
"type": "integer",
"default": "10"
},
{
"name": "name",
"description": "Name of the database to be created",
"required": true,
"type": "string"
}
]
},
"down": {
"parameters": [
{
"name": "name",
"description": "Name of the database to be removed",
"required": true,
"type": "string"
}
]
}
}
```
The top elements are:
- `description`: Human-readable description of the provider
- `up`: Object describing the parameters accepted by the `up` command
- `down`: Object describing the parameters accepted by the `down` command
And for each command parameter, you should include the following properties:
- `name`: The parameter name (without `--` prefix)
- `description`: Human-readable description of the parameter
- `required`: Boolean indicating if the parameter is mandatory
- `type`: Parameter type (`string`, `integer`, `boolean`, etc.)
- `default`: Default value (optional, only for non-required parameters)
- `enum`: List of possible values supported by the parameter separated by `,` (optional, only for parameters with a limited set of values)
This metadata allows Compose and other tools to understand the provider's interface and provide better user experience, such as validation, auto-completion, and documentation generation.
## Examples
See [example](examples/provider.go) for illustration on implementing this API in a command line

View File

@ -1,62 +1,76 @@
# docker compose
```text
docker compose [-f <arg>...] [options] [COMMAND] [ARGS...]
```
<!---MARKER_GEN_START-->
Docker Compose
Define and run multi-container applications with Docker
### Subcommands
| Name | Description |
| --- | --- |
| [`build`](compose_build.md) | Build or rebuild services |
| [`convert`](compose_convert.md) | Converts the compose file to platform's canonical format |
| [`cp`](compose_cp.md) | Copy files/folders between a service container and the local filesystem |
| [`create`](compose_create.md) | Creates containers for a service. |
| [`down`](compose_down.md) | Stop and remove containers, networks |
| [`events`](compose_events.md) | Receive real time events from containers. |
| [`exec`](compose_exec.md) | Execute a command in a running container. |
| [`images`](compose_images.md) | List images used by the created containers |
| [`kill`](compose_kill.md) | Force stop service containers. |
| [`logs`](compose_logs.md) | View output from containers |
| [`ls`](compose_ls.md) | List running compose projects |
| [`pause`](compose_pause.md) | Pause services |
| [`port`](compose_port.md) | Print the public port for a port binding. |
| [`ps`](compose_ps.md) | List containers |
| [`pull`](compose_pull.md) | Pull service images |
| [`push`](compose_push.md) | Push service images |
| [`restart`](compose_restart.md) | Restart containers |
| [`rm`](compose_rm.md) | Removes stopped service containers |
| [`run`](compose_run.md) | Run a one-off command on a service. |
| [`start`](compose_start.md) | Start services |
| [`stop`](compose_stop.md) | Stop services |
| [`top`](compose_top.md) | Display the running processes |
| [`unpause`](compose_unpause.md) | Unpause services |
| [`up`](compose_up.md) | Create and start containers |
| [`version`](compose_version.md) | Show the Docker Compose version information |
| Name | Description |
|:--------------------------------|:----------------------------------------------------------------------------------------|
| [`attach`](compose_attach.md) | Attach local standard input, output, and error streams to a service's running container |
| [`bridge`](compose_bridge.md) | Convert compose files into another model |
| [`build`](compose_build.md) | Build or rebuild services |
| [`commit`](compose_commit.md) | Create a new image from a service container's changes |
| [`config`](compose_config.md) | Parse, resolve and render compose file in canonical format |
| [`cp`](compose_cp.md) | Copy files/folders between a service container and the local filesystem |
| [`create`](compose_create.md) | Creates containers for a service |
| [`down`](compose_down.md) | Stop and remove containers, networks |
| [`events`](compose_events.md) | Receive real time events from containers |
| [`exec`](compose_exec.md) | Execute a command in a running container |
| [`export`](compose_export.md) | Export a service container's filesystem as a tar archive |
| [`images`](compose_images.md) | List images used by the created containers |
| [`kill`](compose_kill.md) | Force stop service containers |
| [`logs`](compose_logs.md) | View output from containers |
| [`ls`](compose_ls.md) | List running compose projects |
| [`pause`](compose_pause.md) | Pause services |
| [`port`](compose_port.md) | Print the public port for a port binding |
| [`ps`](compose_ps.md) | List containers |
| [`publish`](compose_publish.md) | Publish compose application |
| [`pull`](compose_pull.md) | Pull service images |
| [`push`](compose_push.md) | Push service images |
| [`restart`](compose_restart.md) | Restart service containers |
| [`rm`](compose_rm.md) | Removes stopped service containers |
| [`run`](compose_run.md) | Run a one-off command on a service |
| [`scale`](compose_scale.md) | Scale services |
| [`start`](compose_start.md) | Start services |
| [`stats`](compose_stats.md) | Display a live stream of container(s) resource usage statistics |
| [`stop`](compose_stop.md) | Stop services |
| [`top`](compose_top.md) | Display the running processes |
| [`unpause`](compose_unpause.md) | Unpause services |
| [`up`](compose_up.md) | Create and start containers |
| [`version`](compose_version.md) | Show the Docker Compose version information |
| [`volumes`](compose_volumes.md) | List volumes |
| [`wait`](compose_wait.md) | Block until containers of all (or specified) services stop. |
| [`watch`](compose_watch.md) | Watch build context for service and rebuild/refresh containers when files are updated |
### Options
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `--ansi` | `string` | `auto` | Control when to print ANSI control characters ("never"\|"always"\|"auto") |
| `--compatibility` | | | Run compose in backward compatibility mode |
| `--env-file` | `string` | | Specify an alternate environment file. |
| `-f`, `--file` | `stringArray` | | Compose configuration files |
| `--profile` | `stringArray` | | Specify a profile to enable |
| `--project-directory` | `string` | | Specify an alternate working directory
(default: the path of the, first specified, Compose file) |
| `-p`, `--project-name` | `string` | | Project name |
| Name | Type | Default | Description |
|:-----------------------|:--------------|:--------|:----------------------------------------------------------------------------------------------------|
| `--all-resources` | `bool` | | Include all resources, even those not used by services |
| `--ansi` | `string` | `auto` | Control when to print ANSI control characters ("never"\|"always"\|"auto") |
| `--compatibility` | `bool` | | Run compose in backward compatibility mode |
| `--dry-run` | `bool` | | Execute command in dry run mode |
| `--env-file` | `stringArray` | | Specify an alternate environment file |
| `-f`, `--file` | `stringArray` | | Compose configuration files |
| `--parallel` | `int` | `-1` | Control max parallelism, -1 for unlimited |
| `--profile` | `stringArray` | | Specify a profile to enable |
| `--progress` | `string` | | Set type of progress output (auto, tty, plain, json, quiet) |
| `--project-directory` | `string` | | Specify an alternate working directory<br>(default: the path of the, first specified, Compose file) |
| `-p`, `--project-name` | `string` | | Project name |
<!---MARKER_GEN_END-->
## Description
## Examples
You can use compose subcommand, `docker compose [-f <arg>...] [options] [COMMAND] [ARGS...]`, to build and manage
multiple services in Docker containers.
### Use `-f` to specify name and path of one or more Compose files
Use the `-f` flag to specify the location of a Compose configuration file.
### Use `-f` to specify the name and path of one or more Compose files
Use the `-f` flag to specify the location of a Compose [configuration file](/reference/compose-file/).
#### Specifying multiple Compose files
You can supply multiple `-f` configuration files. When you supply multiple files, Compose combines them into a single
@ -66,10 +80,10 @@ to their predecessors.
For example, consider this command line:
```console
$ docker compose -f docker-compose.yml -f docker-compose.admin.yml run backup_db
$ docker compose -f compose.yaml -f compose.admin.yaml run backup_db
```
The `docker-compose.yml` file might specify a `webapp` service.
The `compose.yaml` file might specify a `webapp` service.
```yaml
services:
@ -80,7 +94,7 @@ services:
volumes:
- "/data"
```
If the `docker-compose.admin.yml` also specifies this same service, any matching fields override the previous file.
If the `compose.admin.yaml` also specifies this same service, any matching fields override the previous file.
New values, add to the `webapp` service configuration.
```yaml
@ -114,12 +128,19 @@ $ docker compose -f ~/sandbox/rails/compose.yaml pull db
### Use `-p` to specify a project name
Each configuration has a project name. If you supply a `-p` flag, you can specify a project name. If you dont
specify the flag, Compose uses the current directory name.
Project name can also be set by `COMPOSE_PROJECT_NAME` environment variable.
Most compose subcommand can be ran without a compose file, just passing
project name to retrieve the relevant resources.
Each configuration has a project name. Compose sets the project name using
the following mechanisms, in order of precedence:
- The `-p` command line flag
- The `COMPOSE_PROJECT_NAME` environment variable
- The top level `name:` variable from the config file (or the last `name:`
from a series of config files specified using `-f`)
- The `basename` of the project directory containing the config file (or
containing the first config file specified using `-f`)
- The `basename` of the current directory if no config file is specified
Project names must contain only lowercase letters, decimal digits, dashes,
and underscores, and must begin with a lowercase letter or decimal digit. If
the `basename` of the project directory or current directory violates this
constraint, you must use one of the other mechanisms.
```console
$ docker compose -p my_project ps -a
@ -134,21 +155,58 @@ demo_1 | 64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.095 ms
### Use profiles to enable optional services
Use `--profile` to specify one or more active profiles
Calling `docker compose --profile frontend up` will start the services with the profile `frontend` and services
Calling `docker compose --profile frontend up` starts the services with the profile `frontend` and services
without any specified profiles.
You can also enable multiple profiles, e.g. with `docker compose --profile frontend --profile debug up` the profiles `frontend` and `debug` will be enabled.
You can also enable multiple profiles, e.g. with `docker compose --profile frontend --profile debug up` the profiles `frontend` and `debug` is enabled.
Profiles can also be set by `COMPOSE_PROFILES` environment variable.
### Configuring parallelism
Use `--parallel` to specify the maximum level of parallelism for concurrent engine calls.
Calling `docker compose --parallel 1 pull` pulls the pullable images defined in the Compose file
one at a time. This can also be used to control build concurrency.
Parallelism can also be set by the `COMPOSE_PARALLEL_LIMIT` environment variable.
### Set up environment variables
You can set environment variables for various docker compose options, including the `-f`, `-p` and `--profiles` flags.
Setting the `COMPOSE_FILE` environment variable is equivalent to passing the `-f` flag,
`COMPOSE_PROJECT_NAME` environment variable does the same for to the `-p` flag,
and so does `COMPOSE_PROFILES` environment variable for to the `--profiles` flag.
`COMPOSE_PROJECT_NAME` environment variable does the same as the `-p` flag,
`COMPOSE_PROFILES` environment variable is equivalent to the `--profiles` flag
and `COMPOSE_PARALLEL_LIMIT` does the same as the `--parallel` flag.
If flags are explicitly set on command line, associated environment variable is ignored
If flags are explicitly set on the command line, the associated environment variable is ignored.
Setting the `COMPOSE_IGNORE_ORPHANS` environment variable to `true` will stop docker compose from detecting orphaned
Setting the `COMPOSE_IGNORE_ORPHANS` environment variable to `true` stops docker compose from detecting orphaned
containers for the project.
Setting the `COMPOSE_MENU` environment variable to `false` disables the helper menu when running `docker compose up`
in attached mode. Alternatively, you can also run `docker compose up --menu=false` to disable the helper menu.
### Use Dry Run mode to test your command
Use `--dry-run` flag to test a command without changing your application stack state.
Dry Run mode shows you all the steps Compose applies when executing a command, for example:
```console
$ docker compose --dry-run up --build -d
[+] Pulling 1/1
✔ DRY-RUN MODE - db Pulled 0.9s
[+] Running 10/8
✔ DRY-RUN MODE - build service backend 0.0s
✔ DRY-RUN MODE - ==> ==> writing image dryRun-754a08ddf8bcb1cf22f310f09206dd783d42f7dd 0.0s
✔ DRY-RUN MODE - ==> ==> naming to nginx-golang-mysql-backend 0.0s
✔ DRY-RUN MODE - Network nginx-golang-mysql_default Created 0.0s
✔ DRY-RUN MODE - Container nginx-golang-mysql-db-1 Created 0.0s
✔ DRY-RUN MODE - Container nginx-golang-mysql-backend-1 Created 0.0s
✔ DRY-RUN MODE - Container nginx-golang-mysql-proxy-1 Created 0.0s
✔ DRY-RUN MODE - Container nginx-golang-mysql-db-1 Healthy 0.5s
✔ DRY-RUN MODE - Container nginx-golang-mysql-backend-1 Started 0.0s
✔ DRY-RUN MODE - Container nginx-golang-mysql-proxy-1 Started Started
```
From the example above, you can see that the first step is to pull the image defined by `db` service, then build the `backend` service.
Next, the containers are created. The `db` service is started, and the `backend` and `proxy` wait until the `db` service is healthy before starting.
Dry Run mode works with almost all commands. You cannot use Dry Run mode with a command that doesn't change the state of a Compose stack such as `ps`, `ls`, `logs` for example.

View File

@ -0,0 +1,22 @@
# docker compose alpha
<!---MARKER_GEN_START-->
Experimental commands
### Subcommands
| Name | Description |
|:----------------------------------|:-----------------------------------------------------------------------------------------------------|
| [`viz`](compose_alpha_viz.md) | EXPERIMENTAL - Generate a graphviz graph from your compose file |
| [`watch`](compose_alpha_watch.md) | EXPERIMENTAL - Watch build context for service and rebuild/refresh containers when files are updated |
### Options
| Name | Type | Default | Description |
|:------------|:-----|:--------|:--------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
<!---MARKER_GEN_END-->

View File

@ -0,0 +1,8 @@
# docker compose alpha dry-run
<!---MARKER_GEN_START-->
Dry run command allows you to test a command without applying changes
<!---MARKER_GEN_END-->

View File

@ -0,0 +1,17 @@
# docker compose alpha generate
<!---MARKER_GEN_START-->
EXPERIMENTAL - Generate a Compose file from existing containers
### Options
| Name | Type | Default | Description |
|:----------------|:---------|:--------|:------------------------------------------|
| `--dry-run` | `bool` | | Execute command in dry run mode |
| `--format` | `string` | `yaml` | Format the output. Values: [yaml \| json] |
| `--name` | `string` | | Project name to set in the Compose file |
| `--project-dir` | `string` | | Directory to use for the project |
<!---MARKER_GEN_END-->

Some files were not shown because too many files have changed in this diff Show More