microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.67k stars 289 forks source link

Wrong devcontainer schema: no docker-compose scenario support #4806

Closed ThePlenkov closed 3 years ago

ThePlenkov commented 3 years ago

Hi,

when I swtich from build to docker-compose in my devcontainer.json file - now I always have 3 warnings:

Luckily it's just warnings and actual workflow works

However it could be really nice if we could update devcontainer schema to get rid of those messages.

Thank you!

chrmarti commented 3 years ago

The schema supports both. You probably have some other property that makes the validator pick the "wrong" part of the schema. Could you append your devcontainer.json?

ThePlenkov commented 3 years ago

sure, here is my file

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.158.0/containers/javascript-node
{
    "name": "Node.js",
    "dockerComposeFile": [
        "docker-compose.yml"
    ],
    // The 'service' property is the name of the service for the container that VS Code should
    // use. Update this value and .devcontainer/docker-compose.yml to the real service name.
    "service": "devcontainer",
    // The optional 'workspaceFolder' property is the path VS Code should open by default when
    // connected. This is typically a file mount in .devcontainer/docker-compose.yml
    "workspaceFolder": "/workspace",
    // "build": {
    //  "dockerfile": "Dockerfile",
    //  // Update 'VARIANT' to pick a Node version: 10, 12, 14
    //  "args": {
    //      "VARIANT": "12",
    //      "HTTP_PROXY": "${localEnv:HTTP_PROXY}",
    //      "HTTPS_PROXY": "${localEnv:HTTPS_PROXY}",
    //      "NO_PROXY": "${localEnv:NO_PROXY}",
    //  },
    // },
    "forwardPorts": [
        4004,
        5000,
        8080
    ],
    "remoteEnv": {
        "HTTP_PROXY": "${localEnv:HTTP_PROXY}",
        "HTTPS_PROXY": "${localEnv:HTTPS_PROXY}",
        "NO_PROXY": "${localEnv:NO_PROXY}",
    },
    "mounts": [
        "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
        "source=${localWorkspaceFolder}/secrets,target=/etc/secrets,type=bind"
    ],
    // Set *default* container specific settings.json values on container create.
    "settings": {
        "terminal.integrated.shell.linux": "/bin/bash"
    },
    // Add the IDs of extensions you want installed when the container is created.
    "extensions": [
        "dbaeumer.vscode-eslint",
        "sapse.vscode-cds",
        "ms-azuretools.vscode-docker"
    ],
    // Use 'forwardPorts' to make a list of ports inside the container available locally.
    // "forwardPorts": [],
    // Use 'postCreateCommand' to run commands after the container is created.
    "postCreateCommand": "sudo chmod 666 /var/run/docker.sock",
    // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
    "remoteUser": "node",
    "containerEnv": {
        "HTTP_PROXY": "${localEnv:HTTP_PROXY}",
        "HTTPS_PROXY": "${localEnv:HTTPS_PROXY}",
        "DOCKER_CWD": "${localWorkspaceFolder}"
    },
}
ThePlenkov commented 3 years ago

image

ThePlenkov commented 3 years ago

i have most recent version

ThePlenkov commented 3 years ago

ok - you're right, this is containerEnv.

ThePlenkov commented 3 years ago

may be then we can use this case to add one more message that containerEnv is not valid when dockerComposeFile is used

chrmarti commented 3 years ago

@aeschli Is there an issue tracking to improve which part of the JSON schema is taken based on all given properties?

aeschli commented 3 years ago

@chrmarti No, there's no such issue. If you want to file one, please add a suggestion on how the JSON schema validator should weight the different alternatives.

chrmarti commented 3 years ago

Continuing in https://github.com/microsoft/vscode/issues/120629.