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

Unable to set --project-name using docker-compose task #3436

Closed
Xitric opened this issue Feb 18, 2022 · 3 comments · Fixed by #3440
Closed

Unable to set --project-name using docker-compose task #3436

Xitric opened this issue Feb 18, 2022 · 3 comments · Fixed by #3440

Comments

@Xitric
Copy link
Contributor

Xitric commented Feb 18, 2022

First of all, thank you for creating such a brilliant plugin.

We are in the process of setting up Visual Studio Code tasks to simplify complex docker compose commands within my team. Because we use a mono-repository, we are layering multiple compose files on top of one another, the base file which is located in a docker repository like this:

root/
├─ docker/
│  ├─ docker-compose.yaml
│  ├─ .env
├─ project1/
│  ├─ docker-compose.yaml

docker-compose.yaml files inside the project directories include modifications to the base compose file. Since docker/docker-compose.yaml is always the first compose file in our docker compose commands, the project name is inferred as docker regardless of which product we spin up.

We would instead like the ability to specify the --project-name argument on a task-by-task basis, such as:

{
    "label": "Compose up: Project 1",
    "type": "docker-compose",
    "dockerCompose": {
        "up": {
            "detached": true,
            "build": true,
            "projectName": "Project1"
        },
        "files": [
            "${workspaceFolder}/docker/docker-compose.yaml",
            "${workspaceFolder}/project1/docker-compose.yaml"
        ],
        "envFile": "${workspaceFolder}/docker/.env"
    }
}

Using "customOptions": "--project-name product1" is not possible, since that will place the argument incorrectly in the resulting command:

docker compose up -f docker/docker-compose.yaml -f project1/docker-compose.yaml --env-file docker/.env up -d --project-name product1

As opposed to:

docker compose up -f docker/docker-compose.yaml -f project1/docker-compose.yaml --env-file docker/.env --project-name product1 up -d

If this is within scope, I would be happy to open a PR.

@Xitric Xitric changed the title Unable to set --project-name using dockerCompose task Unable to set --project-name using docker-compose task Feb 18, 2022
@bwateratmsft
Copy link
Collaborator

Good suggestion!

If this is within scope, I would be happy to open a PR.

Totally! We love user contributions. For this, we should also do a small documentation update in https://github.com/microsoft/vscode-docs/blob/main/docs/containers/reference.md#compose-task-reference; you can submit that or we can.

@Xitric
Copy link
Contributor Author

Xitric commented Feb 18, 2022

Thanks, I will look into it and open a PR

@bwateratmsft
Copy link
Collaborator

This has now been released in version 1.21.0 of the Docker extension.

@microsoft microsoft locked and limited conversation to collaborators Apr 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants