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 DockerComposeV1 task and refactoring DockerComposeV0 #20085

Merged
merged 30 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a4894d4
Update task.loc messages
ivanduplenskikh Jun 28, 2024
994334e
Add DockerComposeV1
ivanduplenskikh Jun 28, 2024
206d89a
Add DockerComposeV1 to the CODEOWNERS
ivanduplenskikh Jun 28, 2024
3f709f6
Set the docker compose v2 util as default for the DockerComposeV1 task
ivanduplenskikh Jun 28, 2024
04fa1d1
Add condition for COMPATIBILITY flag
ivanduplenskikh Jun 28, 2024
a777df1
Remove useDockerComposeV2 FF
ivanduplenskikh Jun 28, 2024
b54a4bb
Merge branch 'master' into users/v-ivandu/add-DockerComposeV1-task
ivanduplenskikh Jul 1, 2024
6711b53
Add DockerComposemV1 task to make-options
ivanduplenskikh Jun 28, 2024
5fcb61d
Remove buildConfig from DockerComposeV1 and add Node20 handler as def…
ivanduplenskikh Jun 28, 2024
33f70e1
Update DockerComposeV1 task version
ivanduplenskikh Jul 1, 2024
9d70007
Bump DockerComposeV0 task version
ivanduplenskikh Jul 1, 2024
eca67f1
Changed if empty condition for docker which result
ivanduplenskikh Jul 1, 2024
a729c8d
Build DockerComposeV0
ivanduplenskikh Jul 1, 2024
ced45da
Update resjson manually
ivanduplenskikh Jul 1, 2024
079825e
Update DockerComposeV1
ivanduplenskikh Jul 1, 2024
e14685c
Update unit tests
ivanduplenskikh Jul 1, 2024
720c5e4
Check in unit tests if docker cli exists
ivanduplenskikh Jul 1, 2024
e5f8d8b
Update unit tests and deprecationMessage
ivanduplenskikh Jul 1, 2024
1121b69
Add unit tests
ivanduplenskikh Jul 1, 2024
bbd59a3
Update unit tests DockerComposeV1
ivanduplenskikh Jul 1, 2024
e48d51f
Remove compatibility answers
ivanduplenskikh Jul 1, 2024
f2a07cb
Update DockerComposeV1 resources.resjson
ivanduplenskikh Jul 1, 2024
97dd38d
Update L0Linux
ivanduplenskikh Jul 1, 2024
0d43fa2
Show stdout & stderr in tests
DmitriiBobreshev Jul 1, 2024
9c094ad
Add console.log with composeCommand
ivanduplenskikh Jul 1, 2024
47c982d
Merge branch 'users/v-ivandu/add-DockerComposeV1-task' of https://git…
ivanduplenskikh Jul 1, 2024
c104646
Generated task
ivanduplenskikh Jul 1, 2024
a69623f
Enable system debug
DmitriiBobreshev Jul 1, 2024
77a552d
Update
ivanduplenskikh Jul 1, 2024
81da5b6
Change Node20 to Node20_1
ivanduplenskikh Jul 1, 2024
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
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
Loading