Skip to content

georglauterbach/dev-container-base

Repository files navigation

Custom Development Container Base Image

About

A custom Development Container base image packed with as many as necessary and as few as possible configurations and applications to make development a breeze.

This image is built for amd64 and arm64.

Additional Setup

Proper Caching

To properly persist data that should be cached, you need to provide volumes in devcontainer.json for the following directories:

{
  // Persist the VS Code extension cache
  "source": "<PROJECT>-cache-vscode_extensions",
  "target": "/home/ubuntu/.vscode-server/extensions",
  "type": "volume"
},
{
  // Persist the `${HOME}/.cache` directory
  "source": "<PROJECT>-cache-home_cache",
  "target": "/home/ubuntu/.cache",
  "type": "volume"
}
Important

While this image performs permission adjustments for /home/ubuntu/.vscode-server, you should mount the volume for caching extensions to /home/ubuntu/.vscode-server/extensions. Otherwise, the Development Container settings are cached as well, which may leed to these settings not being updated.

Image Entrypoint & Setup

Note

We do not set a custom ENTRYPOINT with this image because

  1. the entrypoint is overwritten by Development Containers anyway, and

  2. we want to make the additional setup optional.

There is a script that you can execute via

"postCreateCommand": "/usr/local/devcontainer_base/bin/entrypoint.sh"

in your devcontainer.json file. This script performs additional setup procedures:

  1. Run all scripts in /usr/local/devcontainer_base/init_scripts/ if there are any. You can copy scripts into this directory when you build on top of this image, or you can mount a volume to this directory.