Commit Graph

134 Commits

Author SHA1 Message Date
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 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
MohammadHasan Akbari 9eaba55973 feat: add commit command
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2024-11-27 07:39:46 +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 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 82b41b9ebd introduce service hooks
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-10-07 16:06:41 +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
Nathan Baulch 524a97e553 Fix typos
Signed-off-by: Nathan Baulch <nathan.baulch@gmail.com>
2024-09-11 11:21:24 +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
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
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 29692b5921 Introduce --abort-on-container-failure
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-08 15:40:54 +02: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 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 8ab8df86e0 introduce --watch
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-28 19:04:58 +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
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
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
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
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 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 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
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
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
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
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
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 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
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
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
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
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
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
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
cui fliter 25ca75db4d fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-07-04 11:34:49 +08: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 edd76bfd70 Add `docker compose wait`
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2023-06-30 16:07:03 +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 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 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
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 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
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
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
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