Skip to content

Commit 5f3e0bc

Browse files
DockerComposeV0: replace docker-compose to docker cli (#19814)
* Replace docker-compose to docker cli
1 parent c2d533c commit 5f3e0bc

File tree

12 files changed

+1163
-658
lines changed

12 files changed

+1163
-658
lines changed

Tasks/DockerComposeV0/_buildConfigs/Node20/package-lock.json

+551-318
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tasks/DockerComposeV0/dockercomposeconnection.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ export default class DockerComposeConnection extends ContainerConnection {
1919
private requireAdditionalDockerComposeFiles: boolean;
2020
private projectName: string;
2121
private finalComposeFile: string;
22+
private useDockerComposeV2: boolean;
2223

2324
constructor() {
2425
super();
26+
this.useDockerComposeV2 = tl.getBoolFeatureFlag('USE_DOCKER_COMPOSE_V2_COMPATIBLE_MODE');
2527
this.setDockerComposePath();
2628
this.dockerComposeFile = DockerComposeUtils.findDockerFile(tl.getInput("dockerComposeFile", true), tl.getInput("cwd"));
2729
if (!this.dockerComposeFile) {
@@ -91,6 +93,12 @@ export default class DockerComposeConnection extends ContainerConnection {
9193

9294
public createComposeCommand(): tr.ToolRunner {
9395
var command = tl.tool(this.dockerComposePath);
96+
97+
if (this.useDockerComposeV2) {
98+
command.arg("compose");
99+
command.arg("--compatibility");
100+
}
101+
94102
command.arg(["-f", this.dockerComposeFile]);
95103
var basePath = path.dirname(this.dockerComposeFile);
96104
this.additionalDockerComposeFiles.forEach(file => {
@@ -177,8 +185,13 @@ export default class DockerComposeConnection extends ContainerConnection {
177185
//Priority to docker-compose path provided by user
178186
this.dockerComposePath = tl.getInput('dockerComposePath');
179187
if (!this.dockerComposePath) {
180-
//If not use the docker-compose avilable on agent
181-
this.dockerComposePath = tl.which("docker-compose");
188+
// If not use the docker-compose avilable on agent
189+
if (this.useDockerComposeV2) {
190+
this.dockerComposePath = tl.which("docker");
191+
} else {
192+
this.dockerComposePath = tl.which("docker-compose");
193+
}
194+
182195
if (!this.dockerComposePath) {
183196
throw new Error("Docker Compose was not found. You can provide the path to docker-compose via 'dockerComposePath' ");
184197
}

Tasks/DockerComposeV0/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 0,
16-
"Minor": 238,
16+
"Minor": 239,
1717
"Patch": 0
1818
},
1919
"demands": [],

Tasks/DockerComposeV0/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 0,
16-
"Minor": 238,
16+
"Minor": 239,
1717
"Patch": 0
1818
},
1919
"demands": [],
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|0.238.0
2-
Node20_229_2|0.238.1
1+
Default|0.239.0
2+
Node20_229_2|0.239.1

_generated/DockerComposeV0/dockercomposeconnection.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ export default class DockerComposeConnection extends ContainerConnection {
1919
private requireAdditionalDockerComposeFiles: boolean;
2020
private projectName: string;
2121
private finalComposeFile: string;
22+
private useDockerComposeV2: boolean;
2223

2324
constructor() {
2425
super();
26+
this.useDockerComposeV2 = tl.getBoolFeatureFlag('USE_DOCKER_COMPOSE_V2_COMPATIBLE_MODE');
2527
this.setDockerComposePath();
2628
this.dockerComposeFile = DockerComposeUtils.findDockerFile(tl.getInput("dockerComposeFile", true), tl.getInput("cwd"));
2729
if (!this.dockerComposeFile) {
@@ -91,6 +93,12 @@ export default class DockerComposeConnection extends ContainerConnection {
9193

9294
public createComposeCommand(): tr.ToolRunner {
9395
var command = tl.tool(this.dockerComposePath);
96+
97+
if (this.useDockerComposeV2) {
98+
command.arg("compose");
99+
command.arg("--compatibility");
100+
}
101+
94102
command.arg(["-f", this.dockerComposeFile]);
95103
var basePath = path.dirname(this.dockerComposeFile);
96104
this.additionalDockerComposeFiles.forEach(file => {
@@ -177,8 +185,13 @@ export default class DockerComposeConnection extends ContainerConnection {
177185
//Priority to docker-compose path provided by user
178186
this.dockerComposePath = tl.getInput('dockerComposePath');
179187
if (!this.dockerComposePath) {
180-
//If not use the docker-compose avilable on agent
181-
this.dockerComposePath = tl.which("docker-compose");
188+
// If not use the docker-compose avilable on agent
189+
if (this.useDockerComposeV2) {
190+
this.dockerComposePath = tl.which("docker");
191+
} else {
192+
this.dockerComposePath = tl.which("docker-compose");
193+
}
194+
182195
if (!this.dockerComposePath) {
183196
throw new Error("Docker Compose was not found. You can provide the path to docker-compose via 'dockerComposePath' ");
184197
}

_generated/DockerComposeV0/task.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 0,
16-
"Minor": 238,
16+
"Minor": 239,
1717
"Patch": 0
1818
},
1919
"demands": [],
@@ -358,7 +358,7 @@
358358
"WritingDockerConfigToTempFile": "Writing Docker config to temp file. File path: %s, Docker config: %s"
359359
},
360360
"_buildConfigMapping": {
361-
"Default": "0.238.0",
362-
"Node20_229_2": "0.238.1"
361+
"Default": "0.239.0",
362+
"Node20_229_2": "0.239.1"
363363
}
364364
}

_generated/DockerComposeV0/task.loc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 0,
16-
"Minor": 238,
16+
"Minor": 239,
1717
"Patch": 0
1818
},
1919
"demands": [],
@@ -358,7 +358,7 @@
358358
"WritingDockerConfigToTempFile": "ms-resource:loc.messages.WritingDockerConfigToTempFile"
359359
},
360360
"_buildConfigMapping": {
361-
"Default": "0.238.0",
362-
"Node20_229_2": "0.238.1"
361+
"Default": "0.239.0",
362+
"Node20_229_2": "0.239.1"
363363
}
364364
}

_generated/DockerComposeV0_Node20/dockercomposeconnection.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ export default class DockerComposeConnection extends ContainerConnection {
1919
private requireAdditionalDockerComposeFiles: boolean;
2020
private projectName: string;
2121
private finalComposeFile: string;
22+
private useDockerComposeV2: boolean;
2223

2324
constructor() {
2425
super();
26+
this.useDockerComposeV2 = tl.getBoolFeatureFlag('USE_DOCKER_COMPOSE_V2_COMPATIBLE_MODE');
2527
this.setDockerComposePath();
2628
this.dockerComposeFile = DockerComposeUtils.findDockerFile(tl.getInput("dockerComposeFile", true), tl.getInput("cwd"));
2729
if (!this.dockerComposeFile) {
@@ -91,6 +93,12 @@ export default class DockerComposeConnection extends ContainerConnection {
9193

9294
public createComposeCommand(): tr.ToolRunner {
9395
var command = tl.tool(this.dockerComposePath);
96+
97+
if (this.useDockerComposeV2) {
98+
command.arg("compose");
99+
command.arg("--compatibility");
100+
}
101+
94102
command.arg(["-f", this.dockerComposeFile]);
95103
var basePath = path.dirname(this.dockerComposeFile);
96104
this.additionalDockerComposeFiles.forEach(file => {
@@ -177,8 +185,13 @@ export default class DockerComposeConnection extends ContainerConnection {
177185
//Priority to docker-compose path provided by user
178186
this.dockerComposePath = tl.getInput('dockerComposePath');
179187
if (!this.dockerComposePath) {
180-
//If not use the docker-compose avilable on agent
181-
this.dockerComposePath = tl.which("docker-compose");
188+
// If not use the docker-compose avilable on agent
189+
if (this.useDockerComposeV2) {
190+
this.dockerComposePath = tl.which("docker");
191+
} else {
192+
this.dockerComposePath = tl.which("docker-compose");
193+
}
194+
182195
if (!this.dockerComposePath) {
183196
throw new Error("Docker Compose was not found. You can provide the path to docker-compose via 'dockerComposePath' ");
184197
}

0 commit comments

Comments
 (0)