gradle-docker-compose-plugin icon indicating copy to clipboard operation
gradle-docker-compose-plugin copied to clipboard

Add support for `docker compose`

Open henrik242 opened this issue 2 years ago • 12 comments

Enable using dockerComposeV2.set(true)

Should fix https://github.com/avast/gradle-docker-compose-plugin/issues/322, but hasn't been thoroughly tested

henrik242 avatar Mar 15 '22 15:03 henrik242

@augi Have you given this some more thought?

henrik242 avatar Mar 22 '22 12:03 henrik242

Sorry, we had the discussion in #322

What should be done in order to finish this PR:

  1. Add the information about this to README.
  2. Add some kind of testing of this new feature. E.g. prepare also a new GitHub Action with ComposeV2 environment. But I guess this would be hard 😢

augi avatar Mar 22 '22 12:03 augi

Sorry, we had the discussion in https://github.com/avast/gradle-docker-compose-plugin/issues/322

I know, but it kinda stopped there :D

I'll take a look at the readme

henrik242 avatar Mar 22 '22 12:03 henrik242

@augi I've added some info to the README. I don't know if more info is needed?

henrik242 avatar Mar 23 '22 09:03 henrik242

Thank you! 👍 Which platform do you use, please? I'm asking just because it would be nice to test this feature at least manually. I'm on Windows, so I could cover this.

I would test it manually in this way:

  1. Execute publishLocal to publish the plugin to local Maven (on your computer).
  2. Try to use this version on a few real-world projects.

augi avatar Mar 23 '22 11:03 augi

I'm on macOS. I'll check out publishLocal:)

henrik242 avatar Mar 23 '22 12:03 henrik242

publishToMavenLocal worked better. But somehow it still seems to use /usr/local/bin/docker-compose even though I've set dockerComposeV2.set(true). Does it work for you? I'll investigate some more.

henrik242 avatar Mar 23 '22 13:03 henrik242

Obviously dockerComposeV2 will always be set to false when we set the executable because of this line: https://github.com/henrik242/gradle-docker-compose-plugin/blob/36d4e2c47eac67b5fe6ca19950578fa9382a8654/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy#L127

So how do we get it to honor the configurated value?

henrik242 avatar Mar 23 '22 13:03 henrik242

Ah, got it, at least the testing makes sense 😄

We have to have a new getter for accessing executable, and compute the value based on the current value (so not in constructor).

But we still have to provide the property to allow to set this value to a custom value. And we don't want to rename it now because it would break backward compatibility.

I'm now stuck on naming, I'm not sure how to name the new computed property 🤔

Btw. we already have something similar for the projectName already: https://github.com/henrik242/gradle-docker-compose-plugin/blob/36d4e2c47eac67b5fe6ca19950578fa9382a8654/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy#L92

augi avatar Mar 23 '22 13:03 augi

Btw. this PR is actually breaking the backward compatibility because the executable property is transformed to a ListProperty. This is also something we could try to avoid 🤔

augi avatar Mar 23 '22 13:03 augi

I've pushed changes so that executable doesn't break backward compatibility. I haven't looked into fixing dockerComposeV2 yet.

henrik242 avatar Mar 23 '22 13:03 henrik242

Thank you very much for your effort! 👍

I'm still not sure what is the best way how to introduce the V2 support 🤔 Actually, maybe it is so big change that we could break the backward compatibility (and release a new major version).

augi avatar Mar 30 '22 08:03 augi

It would be great to get something like this merged in. I've tested out shimming docker-compose to point to docker compose (v2), and the plugin is able to handle the output (thanks to https://github.com/avast/gradle-docker-compose-plugin/pull/339, and a few other PRs).

devinrsmith avatar Jan 10 '23 18:01 devinrsmith

I would also think it'd be great if support for the docker compose plugin could be merged. I could help with testing this on Linux. IMO, a dockerComposeV2 option sounds better than abandoning backwards compatibility and releasing a new major version (but I haven't looked at the code to see how hard it would be to keep backwards compatibility, so I don't know).

darioseidl avatar May 03 '23 12:05 darioseidl

+1 for this.

We're getting the following when running:

$ ./gradlew composeUp

> Task :app:composeBuild
WARNING: Compose V1 is no longer supported and will be removed from Docker Desktop in an upcoming release. See https://docs.docker.com/go/compose-v1-eol/
WARNING: Compose V1 is no longer supported and will be removed from Docker Desktop in an upcoming release. See https://docs.docker.com/go/compose-v1-eol/

> Task :app:composeUp
WARNING: Compose V1 is no longer supported and will be removed from Docker Desktop in an upcoming release. See https://docs.docker.com/go/compose-v1-eol/

The sooner we can get this, the better 😁

joecotton-wk avatar Aug 07 '23 18:08 joecotton-wk

Given that this PR is over a year old, I've opened a new PR to add this feature. The new PR attempts to address the comments mentioned in this PR as well, so hopefully we won't have to backtrack.

If anyone has time to do additional testing or to review, it would be much appreciated.

joecotton-wk avatar Aug 08 '23 05:08 joecotton-wk

Addressed in #410

augi avatar Aug 08 '23 12:08 augi