theia
theia copied to clipboard
Dev-Container support
What it does
This implements a first version of the Dev-Container Support vscode offers for Theia.
The devcontainer.json format offers alot of configuration option of which currently only a certain few are implemented.
Implemented properties are:
-
image
-
dockerfile
/build.dockerfile
(dockerfile support still needs some more testing and work regarding its options)- including
build.args
which are just passed to docker as is
- including
-
forwardPorts
-
mounts
currently the communication with the theia backend inside the container is done through forwarding a random port when creating the container. There is a tiny chance that this may collide with an application running in the container. Vscode uses some kind of proxy service using unix sockets for communication with its backend and to forward arbitrary ports at container runtime which is not possible with this current implementation.
I would love some feedback on this, especially what missing features would be most important to make it most useful.
How to test
You need docker installed and started on your machine
- open a folder in theia
- create a new
.devcontainer
folder at the root - add a
devcontainer.json
and neccessary resources for it here is an example file using a image wich is automaticly pulled by docker
{
"name": "test_container",
"image": "nikolaik/python-nodejs:python3.11-nodejs20-slim",
"forwardPorts": [4000, "3000:3003"],
"mounts": [{"source": "some/path", "target": "/workspaces", "type": "bind" }]
}
or here is a dockerfile with its respective devcontainer.json file for testing dockerfile support: devcontainer.json Dockerfile.txt
- execute
Dev Containers: Reopen in Container
- your workspace should then open inside the container
Follow-ups
Things not implemented yet which vscodes supports:
- Port forwarding at runtime (including using this for communicating with the backend)
- Docker Compose support
- variables inside
dockerconfig.json
- Showing the docker ouput, especially for when images are build through dockerfiles or pulled
- lots of smaller configuration options
Review checklist
- [x] As an author, I have thoroughly tested my changes and carefully followed the review guidelines
Reminder for reviewers
- As a reviewer, I agree to behave in accordance with the review guidelines