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.64k stars 282 forks source link

Readme badges for monorepo #9143

Open ben3441 opened 11 months ago

ben3441 commented 11 months ago

I have a setup like this: monorepo

backend

 .devcontainer
  Dockerfile
  devcontainer.json

README.md frontend .devcontainer Dockerfile devcontainer.json README.md

In the README.md files I want to put 'open in dev container' badges like this: https://code.visualstudio.com/docs/devcontainers/create-dev-container#_add-an-open-in-dev-container-badge

However when I try this for example in the backend README.md the dev-container fails as it looks in the root of the repo for the dev-container definition files with logs like this: [4277 ms] Start: Run in container: cat /workspaces/monorepo/.devcontainer/devcontainer.json 2>/dev/null [4279 ms] Start: Run in container: cat /workspaces/monorepo/.devcontainer.json 2>/dev/null [4280 ms] Repository unknown-owner/componentcatalogue has no dev container files.

The same thing can be reproduced without the badge through ctrl+shift+P and then selecting 'Dev Containers: Clone Repository in Container Volume' and going through the steps there.

I'm not sure if I'm missing something or if this isn't supported? I couldn't find any documentation or similar issues on it.

chrmarti commented 11 months ago

Having multiple .devcontainer folders in subfolders is currently not supported. You could move the two devcontainer.json to a top-level .devcontainer folder with subfolders:

You can keep the top-level frontend and backend folders. The devcontainer.jsons might need some adjustments, e.g., you can control the workspace folder inside the container with the "workspaceFolder" property.

ben3441 commented 11 months ago

Ahh ok thanks I'll try that instead in general šŸ‘.

Having multiple devcontainer.json files under different subfolders from the common .devcontainer folder at root when I try to open the dev container in vscode for example by going ctrl+shift+P >> 'Dev Containers: Open Folder in Container' I am prompted to select which container to pick from backend or front end.

I guess as this selection is required it isn't possible to fully automate the download and opening of a subproject of a repo as I am trying as the user would still have to make this selection? (still very nice functionality if this is the case) My badge is defined like so:

Open in Dev Containers

I can't see a way to specify which dev container to open here?

Thanks again for your help.

ben3441 commented 11 months ago

ofcourse the badge is just rendered in the comment above šŸ¤¦ā€ā™‚ļø. The bit doing the redirect and opening into the dev container is here: https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=git@gitlab.**somerepo**.git

chrmarti commented 11 months ago

We could add a folder parameter to the URI to support opening subfolders. šŸ¤”