jimkoen / devcontainer-images

Personal devcontainer images I use for my projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Development Container Images

What are devcontainers?

From the official devcontainers repo:

A development container is a running Docker container with a well-defined tool/runtime stack and its prerequisites. It allows you to use a container as a full-featured development environment which can be used to run an application, to separate tools, libraries, or runtimes needed for working with a codebase, and to aid in continuous integration and testing.



This repository contains a set of dev container images which are Docker images built with [dev container features](https://github.com/devcontainers/features).

As hinted at in the text above, the idea is to containerize your development environment. Devcontainers introduce nothing new about this concept, and if you have worked with Docker before, you'll pretty much already know what there is to know.

Devcontainers basicially just mean adding some meta-information to a project with a Dockerfile, that enables the container image resulting from the dockerfile to integrate with some special VSCode features. They are essentially just regular Docker containers with some patched stuff here and there, to allow the injection of custom scripts after startup.

The above enables project maintainers to define a common "baseline" in terms of VSCode extensions used in their project.

For example: You are on Linux and your project makes heavy use of the Jupyter Notebook Extension for VSCode in order to run iPython notebooks. The extension works fine on your end, but alot of MacOS users report non functioning installs in your projects issue tracker. For MacOS, this is the main source of issues, and legitimate problems with your app tend do drown in the waves of troubleshooting issues.

With devcontainers you can force your MacOS users to use Linux under the hood (but they don't really notice) and have the extension and additional configuration automatically installed. VSCode will detect it in the container, and work like it would when things run on the actual computer.

Using devcontainers in your project

Adding necessary files

To containerize your project in a devcontainer, add a .devcontainer directory to your project layout:

project_root/
├─ .devcontainer/
│  ├─ devcontainer.json
│  ├─ Dockerfile

Inside the .devcontainer directory, you will need a devcontainer.json file and an optional Dockerfile. The Dockerfile is only necessary if you want to write a devcontainer image from scratch or extend an existing image. *It is generally the point of devcontainers to use a common, streamlined template. If you feel that you need to make significant extensions to a devcontainer image, consider adding the changes in one of the base images in this repository instead.

devcontainer.json metadata layout

From the official docs:

The devcontainer.json file contains any needed metadata and settings required to configurate a development container for a given well-defined tool and runtime stack. It can be used by tools and services that support the dev container spec to create a development environment that contains one or more development containers.

The devcontainer.json file contains metadata that VSCode needs in order to access and use the container features after it's startup. The minimum required attributes are:

Additionally, the devcontainer.json usually contains the following attributes:

  • "features : {}"
    A JSON object that points to so called "devcontainer features". Features are self contained scripts, that add additional capabilities, such as software packages to a container. They are an alternative way over adding custom dockerfiles to add additional capabilities, such as installing software packages to a container. The devcontainer project offers some in their repository.

  • "customizations": {}
    A JSON object that holds so called "vendor specific extensions". While devcontainers are mostly used with VSCode today, the developers plan to extend support to other editors and IDE's as well. This object holds data that differs from editor to editor. For VSCode, this is the place where the extensions that should be available in the container are defined (see example below). For more information, see the official docs.

Example configuration

todo: tba

Adding new container images

todo: tba

About

Personal devcontainer images I use for my projects

License:GNU General Public License v3.0


Languages

Language:Dockerfile 74.3%Language:Shell 25.7%