Development Containers that follow thoughtbot's conventions, covering images and features for both local development (if desired) and GitHub Codespaces.
By building and publishing custom images, we can dramatically speed up the time taken to spin up a new development environment, and keep the project-specific overrides to a minimum.
Dev Containers are Docker images intended for development and testing, formed from a base image along with "features" which provide additional functionality, such as building and installing the most recent release version of Git.
A project has it's own configuration based on this image, with overrides specific to the project (like additional features for functionality not baked into the image being used) and potentially a Docker Compose file for additional services (like PostgreSQL).
Some examples are live and being regularly used, some in this repo are there to demonstrate different configuration approaches that we've seen on projects.
- This repo has a configuration based on our
debianbase image which can be used to work on the Dev Containers themselves, codespaces-demo: shows a simple Rails app running with a Dev Container on GitHub Codespaces (but not these images and features),
debianis a barebones image without any development environments- It's based on images provided by the
buildpack-depsproject, - Images are tagged by date of build, the most recent also tagged as
latest,
- It's based on images provided by the
universalis a bigger image, inspired bylaptop, which should be everything you need for a web project- It's based on the most recent build of
debian, - Images are tagged by date of build, along with a single
latestpointed to the most recent
- It's based on the most recent build of
We currently only build amd64 images, as this is enough to work with
Codespaces.
These features are intended to be used with our images, but should be compatible with any image.
asdf: the tool version managerasdf-plugin-nodejs: plugin to support Node.jsasdf-plugin-ruby: plugin to support Ruby
browsers: headless browsers commonly used in tests
Build the image:
$ devcontainer build \
--image-name ghcr.io/thoughtbot/devcontainers/images/debian \
--workspace-folder images/debianThis builds an image tagged as latest. This can be tested by starting the
container and running the tests:
$ devcontainer up \
--id-label test-container=debian \
--workspace-folder "images/debian"
$ devcontainer exec \
--id-label test-container=debian \
--workspace-folder images/debian \
/bin/sh test/test.shAnd published:
$ docker push ghcr.io/thoughtbot/devcontainers/images/debian:latestWe don't need an explicit build step before testing, which can be done with:
$ devcontainer features test \
--project-folder features \
--features asdf \
--base-image ghcr.io/thoughtbot/devcontainers/images/debianPublishing can be done with:
$ devcontainer features publish features/src/asdf \
--namespace thoughtbot/devcontainers/featuresDepending on the version of the feature, this will publish tags like: 1, 1.0, 1.0.7, latest, if the feature version was "1.0.7".
- The
devcontainersCLI doesn't properly support Podman (builds will fail), - In addition, images need to exist for your current architecture;
buildpack-depsisn't currently built for Apple Silicon (arm64), which is partly why this doesn't, - To pull private packages from GitHub Packages, "inherit access from source repository" should be enabled in package settings,
- To publish packages from GitHub Actions, we also need to enable write access to the package from the repository