Skip to content

DockerComposeV0: replace docker-compose to docker cli #19814

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
869 changes: 551 additions & 318 deletions Tasks/DockerComposeV0/_buildConfigs/Node20/package-lock.json

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions Tasks/DockerComposeV0/dockercomposeconnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ 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 @@ -91,6 +93,12 @@ export default class DockerComposeConnection extends ContainerConnection {

public createComposeCommand(): tr.ToolRunner {
var command = tl.tool(this.dockerComposePath);

if (this.useDockerComposeV2) {
command.arg("compose");
command.arg("--compatibility");
}

command.arg(["-f", this.dockerComposeFile]);
var basePath = path.dirname(this.dockerComposeFile);
this.additionalDockerComposeFiles.forEach(file => {
Expand Down Expand Up @@ -177,8 +185,13 @@ 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
this.dockerComposePath = tl.which("docker-compose");
// If not use the docker-compose avilable on agent
if (this.useDockerComposeV2) {
this.dockerComposePath = tl.which("docker");
} else {
this.dockerComposePath = tl.which("docker-compose");
}

if (!this.dockerComposePath) {
throw new Error("Docker Compose was not found. You can provide the path to docker-compose via 'dockerComposePath' ");
}
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DockerComposeV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 238,
"Minor": 239,
"Patch": 0
},
"demands": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DockerComposeV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 238,
"Minor": 239,
"Patch": 0
},
"demands": [],
Expand Down
4 changes: 2 additions & 2 deletions _generated/DockerComposeV0.versionmap.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Default|0.238.0
Node20_229_2|0.238.1
Default|0.239.0
Node20_229_2|0.239.1
17 changes: 15 additions & 2 deletions _generated/DockerComposeV0/dockercomposeconnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ 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 @@ -91,6 +93,12 @@ export default class DockerComposeConnection extends ContainerConnection {

public createComposeCommand(): tr.ToolRunner {
var command = tl.tool(this.dockerComposePath);

if (this.useDockerComposeV2) {
command.arg("compose");
command.arg("--compatibility");
}

command.arg(["-f", this.dockerComposeFile]);
var basePath = path.dirname(this.dockerComposeFile);
this.additionalDockerComposeFiles.forEach(file => {
Expand Down Expand Up @@ -177,8 +185,13 @@ 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
this.dockerComposePath = tl.which("docker-compose");
// If not use the docker-compose avilable on agent
if (this.useDockerComposeV2) {
this.dockerComposePath = tl.which("docker");
} else {
this.dockerComposePath = tl.which("docker-compose");
}

if (!this.dockerComposePath) {
throw new Error("Docker Compose was not found. You can provide the path to docker-compose via 'dockerComposePath' ");
}
Expand Down
6 changes: 3 additions & 3 deletions _generated/DockerComposeV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 238,
"Minor": 239,
"Patch": 0
},
"demands": [],
Expand Down Expand Up @@ -358,7 +358,7 @@
"WritingDockerConfigToTempFile": "Writing Docker config to temp file. File path: %s, Docker config: %s"
},
"_buildConfigMapping": {
"Default": "0.238.0",
"Node20_229_2": "0.238.1"
"Default": "0.239.0",
"Node20_229_2": "0.239.1"
}
}
6 changes: 3 additions & 3 deletions _generated/DockerComposeV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 238,
"Minor": 239,
"Patch": 0
},
"demands": [],
Expand Down Expand Up @@ -358,7 +358,7 @@
"WritingDockerConfigToTempFile": "ms-resource:loc.messages.WritingDockerConfigToTempFile"
},
"_buildConfigMapping": {
"Default": "0.238.0",
"Node20_229_2": "0.238.1"
"Default": "0.239.0",
"Node20_229_2": "0.239.1"
}
}
17 changes: 15 additions & 2 deletions _generated/DockerComposeV0_Node20/dockercomposeconnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ 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 @@ -91,6 +93,12 @@ export default class DockerComposeConnection extends ContainerConnection {

public createComposeCommand(): tr.ToolRunner {
var command = tl.tool(this.dockerComposePath);

if (this.useDockerComposeV2) {
command.arg("compose");
command.arg("--compatibility");
}

command.arg(["-f", this.dockerComposeFile]);
var basePath = path.dirname(this.dockerComposeFile);
this.additionalDockerComposeFiles.forEach(file => {
Expand Down Expand Up @@ -177,8 +185,13 @@ 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
this.dockerComposePath = tl.which("docker-compose");
// If not use the docker-compose avilable on agent
if (this.useDockerComposeV2) {
this.dockerComposePath = tl.which("docker");
} else {
this.dockerComposePath = tl.which("docker-compose");
}

if (!this.dockerComposePath) {
throw new Error("Docker Compose was not found. You can provide the path to docker-compose via 'dockerComposePath' ");
}
Expand Down
Loading
Loading