Skip to content

Commit

Permalink
Add DockerComposeV1 task and refactoring DockerComposeV0 (#20085)
Browse files Browse the repository at this point in the history
* Update task.loc messages

* Add DockerComposeV1

* Add DockerComposeV1 to the CODEOWNERS

* Set the docker compose v2 util as default for the DockerComposeV1 task

* Add condition for COMPATIBILITY flag

* Remove useDockerComposeV2 FF

* Add DockerComposemV1 task to make-options

* Remove buildConfig from DockerComposeV1 and add Node20 handler as default

* Update DockerComposeV1 task version

* Bump DockerComposeV0 task version

* Changed if empty condition for docker which result

* Build DockerComposeV0

* Update resjson manually

* Update DockerComposeV1

* Update unit tests

* Check in unit tests if docker cli exists

* Update unit tests and deprecationMessage

* Add unit tests

* Update unit tests DockerComposeV1

* Remove compatibility answers

* Update DockerComposeV1 resources.resjson

* Update L0Linux

* Show stdout & stderr in tests

* Add console.log with composeCommand

* Generated task

* Enable system debug

* Update

* Change Node20 to Node20_1

---------

Co-authored-by: Dmitrii Bobreshev (Akvelon INC) <v-bobreshevd@microsoft.com>
  • Loading branch information
ivanduplenskikh and DmitriiBobreshev authored Jul 1, 2024
1 parent fa50b3a commit d8e6a2e
Show file tree
Hide file tree
Showing 59 changed files with 6,500 additions and 1,156 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ Tasks/DockerV2/ @microsoft/release-management-task-team @manolerazvan

Tasks/DockerComposeV0/ @microsoft/release-management-task-team @manolerazvan

Tasks/DockerComposeV1/ @microsoft/release-management-task-team @manolerazvan

Tasks/DockerInstallerV0/ @microsoft/release-management-task-team @manolerazvan

Tasks/DotNetCoreCLIV2/ @microsoft/akvelon-build-task-team @DergachevE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@
"loc.messages.ImageNameWithoutTag": "Image name not specified with tag, pushing all tags of the image specified.",
"loc.messages.WritingDockerConfigToTempFile": "Writing Docker config to temp file. File path: %s, Docker config: %s",
"loc.messages.InvalidProjectName": "The project name \"%s\" must be a valid docker compose project name. Follow the link for more details: https://docs.docker.com/compose/project-name/#set-a-project-name",
"loc.messages.MigrateToDockerComposeV2": "The task is utilizing Docker Compose V1, but there are plans to transition to Docker Compose V2. It's necessary to investigate how to adapt your project to Docker Compose V2. For guidance on this migration, you can refer to the official Docker Compose documentation at the provided link: https://docs.docker.com/compose/migrate/"
"loc.messages.MigrateToDockerComposeV2": "The task is using Docker Compose V1, which is end-of-life and will be removed from Microsoft-hosted agents July 24. Pipelines running on Microsoft-hosted agents should be updated for Docker Compose v2 compatibility e.g. use compatible container names. For guidance on required updates, please refer to the official Docker Compose documentation at https://docs.docker.com/compose/migrate/"
}
650 changes: 310 additions & 340 deletions Tasks/DockerComposeV0/Tests/L0.ts

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions Tasks/DockerComposeV0/Tests/L0Linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ process.env["ENDPOINT_AUTH_PARAMETER_AzureRMSpn_SERVICEPRINCIPALID"] = "spId";
process.env["ENDPOINT_AUTH_PARAMETER_AzureRMSpn_SERVICEPRINCIPALKEY"] = "spKey";
process.env["ENDPOINT_AUTH_PARAMETER_AzureRMSpn_TENANTID"] = "tenant";
process.env["ENDPOINT_DATA_AzureRMSpn_SUBSCRIPTIONNAME"] = "sName";
process.env["ENDPOINT_DATA_AzureRMSpn_SUBSCRIPTIONID"] = "sId";
process.env["ENDPOINT_DATA_AzureRMSpn_SPNOBJECTID"] = "oId";
process.env["ENDPOINT_DATA_AzureRMSpn_SUBSCRIPTIONID"] = "sId";
process.env["ENDPOINT_DATA_AzureRMSpn_SPNOBJECTID"] = "oId";
process.env['AGENT_HOMEDIRECTORY'] = '/tmp/tempdir/100/';

// provide answers for task mock
Expand All @@ -48,27 +48,27 @@ let a: any = <any>{
"docker-compose": true
},
"exec": {
"docker-compose -f /tmp/tempdir/100/docker-compose.yml build" :{
"docker-compose -f /tmp/tempdir/100/docker-compose.yml build": {
"code": 0,
"stdout": "sucessfully built the service images"
},
"docker compose --compatibility -f /tmp/tempdir/100/docker-compose.yml build" :{
"docker compose -f /tmp/tempdir/100/docker-compose.yml build": {
"code": 0,
"stdout": "sucessfully built the service images"
},
"docker-compose-userdefined -f /tmp/tempdir/100/docker-compose.yml build" :{
"docker-compose-userdefined -f /tmp/tempdir/100/docker-compose.yml build": {
"code": 0,
"stdout": "sucessfully built the service images"
},
"docker-compose -f /tmp/tempdir/100/docker-compose.yml config" :{
"docker-compose -f /tmp/tempdir/100/docker-compose.yml config": {
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: /tmp/tempdir/100\n ports:\n - 5000:5000/tcp\n volumes:\n - /tmp/tempdir/100:/code:rw\nversion: '2.0'"
},
"docker compose --compatibility -f /tmp/tempdir/100/docker-compose.yml config" :{
"docker compose -f /tmp/tempdir/100/docker-compose.yml config": {
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: /tmp/tempdir/100\n ports:\n - 5000:5000/tcp\n volumes:\n - /tmp/tempdir/100:/code:rw\nversion: '2.0'"
},
"docker-compose-userdefined -f /tmp/tempdir/100/docker-compose.yml config" :{
"docker-compose-userdefined -f /tmp/tempdir/100/docker-compose.yml config": {
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: /tmp/tempdir/100\n ports:\n - 5000:5000/tcp\n volumes:\n - /tmp/tempdir/100:/code:rw\nversion: '2.0'"
},
Expand All @@ -80,59 +80,59 @@ let a: any = <any>{
"code": 0,
"stdout": "sucessfully ran services"
},
"docker compose --compatibility -f /tmp/tempdir/100/docker-compose.yml up": {
"docker compose -f /tmp/tempdir/100/docker-compose.yml up": {
"code": 0,
"stdout": "sucessfully ran services"
},
"docker push ajgtestacr1.azurecr.io/100_web":{
"docker push ajgtestacr1.azurecr.io/100_web": {
"code": 0,
"stdout": "successfully pushed with qualified image"
},
"docker-compose -f /tmp/tempdir/100/docker-compose.yml -f /tmp/tempdir/100/docker-compose.override.yml up -d":{
"docker-compose -f /tmp/tempdir/100/docker-compose.yml -f /tmp/tempdir/100/docker-compose.override.yml up -d": {
"code": 0,
"stdout": "successfully ran up command"
},
"docker compose --compatibility -f /tmp/tempdir/100/docker-compose.yml -f /tmp/tempdir/100/docker-compose.override.yml up -d":{
"docker compose -f /tmp/tempdir/100/docker-compose.yml -f /tmp/tempdir/100/docker-compose.override.yml up -d": {
"code": 0,
"stdout": "successfully ran up command"
},
"docker-compose -f /tmp/tempdir/100/docker-compose.yml up -d":{
"docker-compose -f /tmp/tempdir/100/docker-compose.yml up -d": {
"code": 0,
"stdout": "successfully ran up command"
},
"docker compose --compatibility -f /tmp/tempdir/100/docker-compose.yml up -d":{
"docker compose -f /tmp/tempdir/100/docker-compose.yml up -d": {
"code": 0,
"stdout": "successfully ran up command"
},
"docker-compose -f /tmp/tempdir/100/docker-compose.yml build --pull --parallel" :{
"docker-compose -f /tmp/tempdir/100/docker-compose.yml build --pull --parallel": {
"code": 0,
"stdout": "sucessfully built the service images"
},
"docker compose --compatibility -f /tmp/tempdir/100/docker-compose.yml build --pull --parallel" :{
"docker compose -f /tmp/tempdir/100/docker-compose.yml build --pull --parallel": {
"code": 0,
"stdout": "sucessfully built the service images"
},
"docker-compose -f /tmp/tempdir/100/docker-compose.yml pull service1 service2" :{
"docker-compose -f /tmp/tempdir/100/docker-compose.yml pull service1 service2": {
"code": 0,
"stdout": "successfully pulled the passed service images"
},
"docker compose --compatibility -f /tmp/tempdir/100/docker-compose.yml pull service1 service2" :{
"docker compose -f /tmp/tempdir/100/docker-compose.yml pull service1 service2": {
"code": 0,
"stdout": "successfully pulled the passed service images"
},
"docker-compose -f /tmp/tempdir/100/docker-compose.yml -f /tmp/tempdir/100/.docker-compose.12345.yml config":{
"docker-compose -f /tmp/tempdir/100/docker-compose.yml -f /tmp/tempdir/100/.docker-compose.12345.yml config": {
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: /tmp/tempdir/100\n image: ajgtestacr1.azurecr.io/100_web\n ports:\n - 5000:5000/tcp\n volumes:\n - /tmp/tempdir/100:/code:rw\nversion: '2.0'"
},
"docker compose --compatibility -f /tmp/tempdir/100/docker-compose.yml -f /tmp/tempdir/100/.docker-compose.12345.yml config":{
"docker compose -f /tmp/tempdir/100/docker-compose.yml -f /tmp/tempdir/100/.docker-compose.12345.yml config": {
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: /tmp/tempdir/100\n image: ajgtestacr1.azurecr.io/100_web\n ports:\n - 5000:5000/tcp\n volumes:\n - /tmp/tempdir/100:/code:rw\nversion: '2.0'"
},
"docker-compose -f /tmp/tempdir/100/docker-compose.yml -f /tmp/tempdir/100/docker-compose.override.yml config":{
"docker-compose -f /tmp/tempdir/100/docker-compose.yml -f /tmp/tempdir/100/docker-compose.override.yml config": {
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: /tmp/tempdir/100\n image: ajgtestacr1.azurecr.io/100_web\n ports:\n - 5000:5000/tcp\n volumes:\n - /tmp/tempdir/100:/code:rw\nversion: '2.0'"
},
"docker compose --compatibility -f /tmp/tempdir/100/docker-compose.yml -f /tmp/tempdir/100/docker-compose.override.yml config":{
"docker compose -f /tmp/tempdir/100/docker-compose.yml -f /tmp/tempdir/100/docker-compose.override.yml config": {
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: /tmp/tempdir/100\n image: ajgtestacr1.azurecr.io/100_web\n ports:\n - 5000:5000/tcp\n volumes:\n - /tmp/tempdir/100:/code:rw\nversion: '2.0'"
}
Expand Down
20 changes: 12 additions & 8 deletions Tasks/DockerComposeV0/Tests/L0Windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ let a: any = <any>{
"code": 0,
"stdout": "sucessfully built the service images"
},
"docker compose --compatibility -f F:\\dir2\\docker-compose.yml build" : {
"docker compose -f F:\\dir2\\docker-compose.yml build" : {
"code": 0,
"stdout": "sucessfully built the service images"
},
Expand All @@ -64,7 +64,7 @@ let a: any = <any>{
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: C:\\docketest\n ports:\n - 5000:5000/tcp\n volumes:\n - C:\\docketest:/code:rw\nversion: '2.0'"
},
"docker compose --compatibility -f F:\\dir2\\docker-compose.yml config" : {
"docker compose -f F:\\dir2\\docker-compose.yml config" : {
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: C:\\docketest\n ports:\n - 5000:5000/tcp\n volumes:\n - C:\\docketest:/code:rw\nversion: '2.0'"
},
Expand All @@ -80,19 +80,23 @@ let a: any = <any>{
"code": 0,
"stdout": "sucessfully ran services"
},
"docker compose -f F:\\dir2\\docker-compose.yml up": {
"code": 0,
"stdout": "sucessfully ran services"
},
"docker-compose -f F:\\dir2\\docker-compose.yml build --pull --parallel" : {
"code": 0,
"stdout": "sucessfully built the service images"
},
"docker compose --compatibility -f F:\\dir2\\docker-compose.yml build --pull --parallel" : {
"docker compose -f F:\\dir2\\docker-compose.yml build --pull --parallel" : {
"code": 0,
"stdout": "sucessfully built the service images"
},
"docker-compose -f F:\\dir2\\docker-compose.yml -f F:\\dir2\\.docker-compose.12345.yml config": {
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: F:\\dir2\n image: ajgtestacr1.azurecr.io/dir2_web\n ports:\n - 5000:5000/tcp\n volumes:\n - F:\\dir2:/code:rw\nversion: '2.0'"
},
"docker compose --compatibility -f F:\\dir2\\docker-compose.yml -f F:\\dir2\\.docker-compose.12345.yml config": {
"docker compose -f F:\\dir2\\docker-compose.yml -f F:\\dir2\\.docker-compose.12345.yml config": {
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: F:\\dir2\n image: ajgtestacr1.azurecr.io/dir2_web\n ports:\n - 5000:5000/tcp\n volumes:\n - F:\\dir2:/code:rw\nversion: '2.0'"
},
Expand All @@ -104,31 +108,31 @@ let a: any = <any>{
"code": 0,
"stdout": "successfully ran up command"
},
"docker compose --compatibility -f F:\\dir2\\docker-compose.yml -f F:\\dir2\\docker-compose.override.yml up -d": {
"docker compose -f F:\\dir2\\docker-compose.yml -f F:\\dir2\\docker-compose.override.yml up -d": {
"code": 0,
"stdout": "successfully ran up command"
},
"docker-compose -f F:\\dir2\\docker-compose.yml -f F:\\dir2\\docker-compose.override.yml config": {
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: F:\\dir2\n image: ajgtestacr1.azurecr.io/dir2_web\n ports:\n - 5000:5000/tcp\n volumes:\n - F:\\dir2:/code:rw\nversion: '2.0'"
},
"docker compose --compatibility -f F:\\dir2\\docker-compose.yml -f F:\\dir2\\docker-compose.override.yml config": {
"docker compose -f F:\\dir2\\docker-compose.yml -f F:\\dir2\\docker-compose.override.yml config": {
"code": 0,
"stdout": "services:\n redis:\n image: redis:alpine\n web:\n build:\n context: F:\\dir2\n image: ajgtestacr1.azurecr.io/dir2_web\n ports:\n - 5000:5000/tcp\n volumes:\n - F:\\dir2:/code:rw\nversion: '2.0'"
},
"docker-compose -f F:\\dir2\\docker-compose.yml up -d": {
"code": 0,
"stdout": "successfully ran up command"
},
"docker compose --compatibility -f F:\\dir2\\docker-compose.yml up -d": {
"docker compose -f F:\\dir2\\docker-compose.yml up -d": {
"code": 0,
"stdout": "successfully ran up command"
},
"docker-compose -f F:\\dir2\\docker-compose.yml pull service1 service2" : {
"code": 0,
"stdout": "successfully pulled the passed service images"
},
"docker compose --compatibility -f F:\\dir2\\docker-compose.yml pull service1 service2" : {
"docker compose -f F:\\dir2\\docker-compose.yml pull service1 service2" : {
"code": 0,
"stdout": "successfully pulled the passed service images"
}
Expand Down
13 changes: 5 additions & 8 deletions Tasks/DockerComposeV0/dockercomposeconnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ export default class DockerComposeConnection extends ContainerConnection {
private requireAdditionalDockerComposeFiles: boolean;
private projectName: string;
private finalComposeFile: string;
private useDockerComposeV2: boolean;

constructor() {
super();
this.useDockerComposeV2 = tl.getBoolFeatureFlag("USE_DOCKER_COMPOSE_V2_COMPATIBLE_MODE");
this.setDockerComposePath();
this.dockerComposeFile = DockerComposeUtils.findDockerFile(tl.getInput("dockerComposeFile", true), tl.getInput("cwd"));
if (!this.dockerComposeFile) {
Expand Down Expand Up @@ -95,7 +93,7 @@ export default class DockerComposeConnection extends ContainerConnection {
public createComposeCommand(): tr.ToolRunner {
var command = tl.tool(this.dockerComposePath);

if (this.useDockerComposeV2 && !tl.getInput('dockerComposePath')) {
if (!tl.getInput('dockerComposePath')) {
command.arg("compose");
process.env["COMPOSE_COMPATIBILITY"] = "true";
}
Expand Down Expand Up @@ -186,10 +184,9 @@ export default class DockerComposeConnection extends ContainerConnection {
//Priority to docker-compose path provided by user
this.dockerComposePath = tl.getInput('dockerComposePath');
if (!this.dockerComposePath) {
// If not use the docker-compose avilable on agent
if (this.useDockerComposeV2) {
this.dockerComposePath = tl.which("docker");
} else {
this.dockerComposePath = tl.which("docker");

if (!this.dockerComposePath) {
this.dockerComposePath = tl.which("docker-compose");
}

Expand All @@ -204,7 +201,7 @@ export default class DockerComposeConnection extends ContainerConnection {
private validateProjectNameDockerComposeV2() {
tl.debug(`Start validating project name ${this.projectName}`);

if (this.dockerComposePath.includes("docker-compose") || !this.useDockerComposeV2) {
if (this.dockerComposePath.includes("docker-compose")) {
tl.warning(tl.loc("MigrateToDockerComposeV2"));
return;
}
Expand Down
6 changes: 4 additions & 2 deletions Tasks/DockerComposeV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
"version": {
"Major": 0,
"Minor": 242,
"Patch": 2
"Patch": 4
},
"demands": [],
"preview": "false",
"deprecated": true,
"deprecationMessage": "The DockerCompose@0 task is deprecated. The task uses docker-compose v1 which no longer receives update since July 2023. To use docker compose v2, use the DockerCompose@1 task.",
"groups": [
{
"name": "advanced",
Expand Down Expand Up @@ -357,6 +359,6 @@
"ImageNameWithoutTag": "Image name not specified with tag, pushing all tags of the image specified.",
"WritingDockerConfigToTempFile": "Writing Docker config to temp file. File path: %s, Docker config: %s",
"InvalidProjectName": "The project name \"%s\" must be a valid docker compose project name. Follow the link for more details: https://docs.docker.com/compose/project-name/#set-a-project-name",
"MigrateToDockerComposeV2": "The task is utilizing Docker Compose V1, but there are plans to transition to Docker Compose V2. It's necessary to investigate how to adapt your project to Docker Compose V2. For guidance on this migration, you can refer to the official Docker Compose documentation at the provided link: https://docs.docker.com/compose/migrate/"
"MigrateToDockerComposeV2": "The task is using Docker Compose V1, which is end-of-life and will be removed from Microsoft-hosted agents July 24. Pipelines running on Microsoft-hosted agents should be updated for Docker Compose v2 compatibility e.g. use compatible container names. For guidance on required updates, please refer to the official Docker Compose documentation at https://docs.docker.com/compose/migrate/"
}
}
4 changes: 3 additions & 1 deletion Tasks/DockerComposeV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
"version": {
"Major": 0,
"Minor": 242,
"Patch": 2
"Patch": 4
},
"demands": [],
"preview": "false",
"deprecated": true,
"deprecationMessage": "The DockerCompose@0 task is deprecated. The task uses docker-compose v1 which no longer receives update since July 2023. To use docker compose v2, use the DockerCompose@1 task.",
"groups": [
{
"name": "advanced",
Expand Down
Loading

0 comments on commit d8e6a2e

Please sign in to comment.