Development using devcontainers?

Hi all,

Does anyone use devcontainers for their local development? https://containers.dev/

IE: It is a standard fille format that you can include in your code repo and services such as Github Codespaces will build a container environment for you on the fly with all of your tooling installed so you have a consistent dev platform at all times.

I switch between a handful of computers a lot and this would be very helpful, as I’m messing around in a bunch of different tracks right now, and trying to consistently setup a bunch of different language tooling is a bit of a timesink.

The only issue I have is I have all of my exercises just cloned via the exercism cli tool to a repo, so all of the languages exist in the same branch just under their ruby, python, haskell, subdirectories.

To build a devcontainer I can include a bunch of tooling for all of these languages to be installed but this seems to cause issues, one the main docker image (if it actually builds without errors) is massive, and if I try and just split everything out and keep python projects in their own branch etc, I’m not sure if I can easily create a container per branch (plus I’ll have tons of containers everywhere). It seems like Codespaces and a local version of this named DevPod just build from the default branch of your repo.

Has anyone else tried anything like this?

Yeah I tried it out when I had to learn Docker for the Clojure track tooling. I think I used this tutorial: Developing inside a Container using Visual Studio Code Remote Development

That is a good tutorial for sure. Also this is a good link for reference, here are a ton of tools you can use out of the box just with a simple bit of json code added to your config file: Features

Does anyone use devcontainers for their local development?

I am using devcontainers for local development with Elixir with a custom docker image with predefined extensions and settings. You can see this in my repository.

The only issue I have is I have all of my exercises just cloned via the exercism cli tool to a repo, so all of the languages exist in the same branch just under their ruby, python, haskell, subdirectories.

Having one language per branch is a nice idea, because you could also setup extensions and settings per language.

But personally, I would make a repository per language. If your repositories are public, your code will be easier to find and better showcased for each language with extensions and settings per repository.

Another more advanced solution would be to have a single repository and one image as workspace which will have something like docker-in-docker or docker-outside-docker. Then instead of having all binaries in the big image, each binary would be inside a dedicated container. Finally you would start everything with docker compose. The result would be to call the binaries (e.g. python, ruby, …) but from their container. I have not done that yet but I plan to do that for some of my repositories.

By the way, if you use devcontainer features, you can add exercism and other binaries as features where they will be preinstalled after the container initialization. For example for exercism:

"features": {
    "ghcr.io/devcontainers-contrib/features/exercism-cli:1": {}
}

You can find more about devcontainer features here and here. You can find the full list of features here (including python, ruby, exercism, docker-in-docker and docker-outside-of-docker).

3 Likes