theia icon indicating copy to clipboard operation
theia copied to clipboard

Dev-Container support

Open jonah-iden opened this issue 1 year ago • 0 comments

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
  • 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

  1. open a folder in theia
  2. create a new .devcontainer folder at the root
  3. 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

  1. execute Dev Containers: Reopen in Container
  2. 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

Reminder for reviewers

jonah-iden avatar Feb 09 '24 13:02 jonah-iden