This article is part of a series to help newcomers to get started with Eclipse Theia development by setting up a local docker-based development environment for Theia.
After having written the previous article Getting started with Eclipse Theia (1): Starting Theia Development in a Docker Dev Environment, I have tried the same setup on a different machine which does not have a Docker Desktop installation, but which uses docker-machine to manage its containers in a boot2docker VM.
My goal was to achieve a similarly easy startup on this machine (and also on Linux machines for which Docker Desktop is not available). By digging a bit deeper into the inner workings of the Docker Dev Environments feature, I have learned that most of the functionality is also available in VS Code directly via the Remote Containers Extension.
Similar to the Docker Dev Environments feature, you can add a folder .devcontainer
to a repository containing a file called devcontainer.json
. Then, anyone can directly clone this repository and start working on it inside a docker container with VS Code. This is how my devcontainer.json
file looks like:
{
"name": "theia-dev",
"context": "../docker-container",
"dockerFile": "../docker-container/Dockerfile",
"forwardPorts": [3000],
"postCreateCommand": "yarn && yarn theia build",
"remoteUser": "node"
}
The Dockerfile
referenced here is the same we have used for the Docker Dev Environments in the last article.
To get started, after installing the Remote Containers Extension in VS Code, follow these steps:
- From the Command Palette (F3), run "Remote-Containers: Clone Repository in Container Volume“.
- Enter the URL to the repository (or clone my repository
github.com/xpomul/theia-boilerplate.git
) and follow the navigation to select your GitHub repository - Now wait. The container will be built, the repository will be cloned in a volume, and even the
yarn
andyarn theia build
commands will be executed automatically (as specified in thedevcontainer.json
). - After everything is done, you can close the Terminal, open a new one and just run
yarn theia start --plugins=local-dir:plugins
and your Eclipse Theia instance will come up athttp://localhost:3000
Again, from here, you can follow the usual Theia tutorials and start experimenting.
Have fun!