Support with repos with multiple devcontainer configurations
dustinchilson opened this issue · 8 comments
I have a repo that has a couple services in it each with their own devcontainer config it looks kinda like this
.devcontainer
service1
devcontainer.json
service2
devcontainer.json
src
service1
...
service2
...
When I run the app to launch my editor it doesn't detect any of the configurations
version 0.1.7
https://containers.dev/implementors/spec/#devcontainerjson
https://github.com/microsoft/vscode-docs/blob/main/remote-release-notes/v1_75.md#folders-with-multiple-devcontainerjson-files
Very interesting, I didn't know about this feature yet - but I definitely want to use it in future.
So I have the following idea in mind about how this could work:
We add an arg --select container_name
, which will then open the specified devcontainer.
If you open a multi-container project without this arg, we will detect that and reply with a list of available devcontainers. Later we could also use a TUI (similar to the recent-ui feature) for that.
Let me know what you think.
I suspect this solution will work, I started to work on on something to handle that scenario. Still new with rust so still wrapping my head around the code so no promises.
So that the app crashed (panicked) was actually a bug, which is now fixed.
The fix is available in v0.1.13.
So when opening a multi-devcontainer environment now, this error will show:
I: Devcontainer not found, opening the classic way...
I currently work on v0.2, which will add support for multi-devcontainer environments.
I created this: #36
Basically craws all devcontainers, assigns them an index and adds a command that can be used to select them.
However, I am not quite sure if this is actually possible.
The way to open a devcontainer boils down to call vscode-remote://dev-container+{hex encoded path to workspace}{folder inside the container}
I am not quite sure how one would tell vscode which devcontainer to actually use.
Okay, I found a way by basically disassembling the vscode devcontainer extension. And its a bit more involved than I thought, but it is indeed possible!
So the implementation is done and works. It can be tested on the multi-devcontainers
branch: https://github.com/michidk/vscli/tree/multi-devcontainers
In this branch, I also changed a bunch of other stuff. Basically, the code is a lot better now and the behavior is clearer to understand.
Oh and this is a breaking change. The commands changed (it's now vscli open
to open dev containers) and the history file was renamed.
This was implemented with the release of version 0.2.0.
Since this was a really interesting journey, I made a write-up of how I figured that one out. You can read it over here: https://blog.lohr.dev/launching-dev-containers-from-code-is-impossible
Works great, thanks.
Interesting read on the blog.