Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add useDockerComposeV2 property #410

Merged
merged 1 commit into from
Aug 8, 2023

Conversation

joecotton-wk
Copy link
Contributor

@joecotton-wk joecotton-wk commented Aug 8, 2023

Overview

As has been discussed in #322, #401, and this PR, Docker Compose V1 has reached its deprecation date and is no longer supported. While there are several workarounds (including one provided by Docker), these workarounds do not work for everyone and are not desirable in all cases. To this end, this PR adds the ability for ComposeExecutor to be configured to run using docker compose instead of docker-compose.

Additionally, this PR had the following goals:

  • Provide a clear and easy way for consumers to opt into using Compose V2
  • Make sure Compose V1 is enabled by default
  • Make sure the changes did not break any existing APIs
  • Make sure the functionality is properly tested
  • Make sure the new option is properly documented

Usage

To use Compose V2, all the user needs to do is add the useDockerComposeV2 property to the dockerCompose section of their build.gradle file:

dockerCompose {
  useDockerComposeV2 = true
}

Verification

In addition to the unit test added in this PR, the code changes proposed here have been tested and verified to work in a real-world project before the PR was submitted.

Test Procedure

The following are the steps I used to test these changes in a real-world project:

  • Build and publish the plugin to maven local using the following command:
# Signing tasks are excluded for local development purposes
$ ./gradlew clean publishToMavenLocal \
  --exclude-task signDockerComposePluginPluginMarkerMavenPublication \
  --exclude-task signPluginMavenPublication \
  -Pversion=0.16.13-SNAPSHOT
  • Consume the snapshot version from the local maven repository within a real-world project:
[plugins]
avast-docker-compose = { id = "com.avast.gradle.docker-compose", version = "0.16.13-SNAPSHOT" }

Note: In my case, I had to add the following lines to the top of my project's settings.gradle file so that the project would pick up the plugin from the local maven repository:

pluginManagement {
    repositories {
        mavenLocal()
        gradlePluginPortal()
    }
}
  • Run ./gradlew clean composeUp and ./gradlew clean composeDown

Test Results

Running the test version of the plugin without the useDockerComposeV2 property set resulted in the following console output. It can plainly be seen that the plugin is using Compose V1 to stand up the stack by the presence of the WARNING lines.

use-docker-compose-v2-not-specified

Running the test version of the plugin with useDockerComposeV2 = false resulted in the following console output. Once again, it's clear that the plugin is using Compose V1.

use-docker-compose-v2-set-to-false

Running the test version of the plugin with useDockerComposeV2 = true resulted in the following console output. In this case, it's clear the plugin was using Compose V2 because the WARNING lines are no longer present.

use-docker-compose-v2-set-to-true

These tests were performed on a MacBook Pro M1 Max running OSX 13.4.1 (Ventura), using gradle 7.5.1 and Java 17 (Amazon Corretto 17.0.8).

Copy link
Member

@augi augi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for this PR! I have just minor comments, and I'm going to test it on Windows (with Docker Desktop).

README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
@augi
Copy link
Member

augi commented Aug 8, 2023

I can confirm it works on Windows 10 with Docker Desktop 4.21.1, with both V1 and V2.

@augi augi merged commit 38a1e72 into avast:main Aug 8, 2023
1 check passed
@joecotton-wk
Copy link
Contributor Author

Just getting to this, as it's relatively early morning my time. @augi thank you for merging this! Do you want me to open a new PR to address the comments?

@joecotton-wk
Copy link
Contributor Author

Nevermind, it appears that you already beat me to it (link). Thank you for your help getting this merged!

@joecotton-wk joecotton-wk deleted the use-docker-compose-v2-flag branch August 8, 2023 13:43
@augi
Copy link
Member

augi commented Aug 8, 2023

Yeah, and it is released 🎉 I'm also performing more updates of the project now, and will release the 0.17.0 version soon, and it will use V2 as default. It makes IMHO sense as V1 is deprecated now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants