Skip to content

gantsign/devcontainers

Repository files navigation

GantSign Development Containers

Prerequisites

If your don’t want to see the occasional garbled character, you’ll need to install a couple of fonts and set your terminal emulator to use the Nerd Font.

  • A Nerd Font installed and enabled in your terminal

  • An emoji font e.g.

    Debian/Ubuntu
    sudo apt install fonts-noto-color-emoji
    RedHat/Amazon
    sudo dnf install google-noto-emoji-fonts

Base container

The base container is the smallest container for development that doesn’t require Docker or Kubernetes.

Features

In addition to basic GNU/Linux command line tools this container contains the following:

  • bat a cat alternative with syntax highlighting

  • btop a color top alternative with broader information

  • Delta for more readable diffs

  • duf a df alternative with easier to read output

  • Dust a du alternative with easier to read output

  • fd an easier to use find alternative

  • fzf a general-purpose command-line fuzzy finder

  • fzf-tab use fzf for tab-completion

  • Generic Colouriser add color output to many basic GNU/Linux commands

  • GitHub CLI to make GitHub easier to work with from the command line

  • Glances a color top alternative with broader information

  • hexyl hex viewer

  • htop a color top alternative

  • HTTPie easier to use curl alternative with color output

  • HTTP Prompt interactive interface to HTTPie

  • Hurl for testing REST APIs

  • hyperfine benchmarking tool

  • lazygit a terminal UI for git commands

  • LSD (LSDeluxe) a ls/tree alternative with color and icons

  • Node Version Manager for installing/managing versions of Node.js

  • jq for manipulating JSON

  • Oh My Zsh for tab-completion and aliases

  • Pipenv for managing Python dependencies/virtualenvs

  • pipx for installing Python applications

  • procs a ps alternative with color and keyword search

  • ripgrep for searching files/directories for text

  • sd easy to use sed alternative

  • SDKMAN! for installing/managing SDKs such as Java and Maven

  • ssh-tools command line utilities for SSH

  • starship a full featured shell prompt

  • The Silver Searcher for searching files/directories for text

  • Tokei view stats about your code

  • vim-airline status/tabline for vim

  • You Should Use to remind you of available shell aliases

  • zoxide easily navigate to previous directories

  • zimfw for managing Zsh plugins (including Oh My Zsh)

  • zsh-autosuggestions suggests commands as you type based on history and completions

  • zsh-syntax-highlighting syntax highlighting for the command line

Running standalone

If you just want to try it out, you can run it standalone:

docker run --rm -ti ghcr.io/gantsign/devcontainer-base

Running in VS Code

First you need to create a .devcontainer/devcontainer.json file in the root of your project:

.devcontainer/devcontainer.json
// For format details, see https://aka.ms/devcontainer.json
{
	"name": "GantSign",
	"build": {
		"dockerfile": "Dockerfile",
	},

	"settings": {
		"editor.renderWhitespace": "all",
		"editor.rulers": [
			80,
			100,
			120
		],
		"editor.guides.bracketPairs": true
	},

	"extensions": [
		"streetsidesoftware.code-spell-checker",
		"editorconfig.editorconfig"
	],

	"forwardPorts": [],

	"mounts": [
		"source=devcontainer-history,target=/home/dev/.shell_history,type=volume",
		"source=devcontainer-zoxide,target=/home/dev/.local/share/zoxide,type=volume"
	],

	"runArgs": [
		// [Optional] Uncomment for improved security, requires https://github.com/nestybox/sysbox to be installed
		// "--runtime=sysbox-runc"
	],

	"remoteUser": "dev",
}

Then you need to create a Dockerfile:

.devcontainer/Dockerfile
FROM ghcr.io/gantsign/devcontainer-base

# ** [Optional] Uncomment this section to install additional packages. **
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
#     && apt-get -y install --no-install-recommends <your-package-list-here>

# ** [Optional] Uncomment this section to install SDKs. **
# SHELL [ "/usr/bin/bash", "--login", "-c" ]
# RUN sdk_install java 11
# RUN sdk_install maven 3
# RUN nvm install --lts

Then press Ctrl-P and select "Remote-Containers: Open Folder in Container…​" from the menu.

DinD container

For when you need to use Docker for development. The DinD container contains everything in the base container as well as Docker-in-Docker and related tools.

Features

In addition to the tools in the base container the DinD container also contains the following:

  • ctop a top like tool for containers

  • dive a tool for exploring Docker images

  • Docker the most well know container tool

  • Docker Compose a tool for defining and running multi-container Docker applications

  • Lazydocker a simple terminal UI for Docker & Docker Compose

Running in VS Code

First you need to create a .devcontainer/devcontainer.json file in the root of your project:

.devcontainer/devcontainer.json
// For format details, see https://aka.ms/devcontainer.json
{
	"name": "GantSign",
	"build": {
		"dockerfile": "Dockerfile",
	},

	"settings": {
		"editor.renderWhitespace": "all",
		"editor.rulers": [
			80,
			100,
			120
		],
		"editor.guides.bracketPairs": true
	},

	"extensions": [
		"streetsidesoftware.code-spell-checker",
		"editorconfig.editorconfig"
	],

	"forwardPorts": [],

	"mounts": [
		"source=devcontainer-history,target=/home/dev/.shell_history,type=volume",
		"source=devcontainer-zoxide,target=/home/dev/.local/share/zoxide,type=volume",
		// To preserve Docker images between runs
		"source=devcontainer-docker,target=/var/lib/docker,type=volume"
	],

	"runArgs": [
		// Requires https://github.com/nestybox/sysbox to be installed
		"--runtime=sysbox-runc"
	],

	"remoteUser": "dev",

	// So the Docker init script runs
	"overrideCommand": false
}
ℹ️

For Docker-in-Docker to work, it either needs to be run with sysbox --runtime=sysbox-runc (which you need to install on your host machine) or with the --privileged flag. See https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/ for why you should avoid the --privileged flag.

Then you need to create a Dockerfile:

.devcontainer/Dockerfile
FROM ghcr.io/gantsign/devcontainer-dind

# ** [Optional] Uncomment this section to install additional packages. **
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
#     && apt-get -y install --no-install-recommends <your-package-list-here>

# ** [Optional] Uncomment this section to install SDKs. **
# SHELL [ "/usr/bin/bash", "--login", "-c" ]
# RUN sdk_install java 11
# RUN sdk_install maven 3
# RUN nvm install --lts

Then press Ctrl-P and select "Remote-Containers: Open Folder in Container…​" from the menu.

K8s container

For when you need to use Kubernetes for development. The K8s container contains everything in the DinD container as well as K3s and related tools.

Features

In addition to the tools in the DinD container the K3s container also contains the following:

  • Helm Kubernetes package manager

  • K3s lightweight Kubernetes distribution

  • k9s terminal UI for Kubernetes

  • kubectx for switching between Kubernetes contexts

  • kubens for switching between Kubernetes namespaces

  • Kustomize for customizing application configuration

  • stern allows you to tail multiple pods

  • Telepresence bridge between local dev and your Kubernetes cluster

Running in VS Code

First you need to create a .devcontainer/devcontainer.json file in the root of your project:

.devcontainer/devcontainer.json
// For format details, see https://aka.ms/devcontainer.json
{
	"name": "GantSign",
	"build": {
		"dockerfile": "Dockerfile",
	},

	"settings": {
		"editor.renderWhitespace": "all",
		"editor.rulers": [
			80,
			100,
			120
		],
		"editor.guides.bracketPairs": true
	},

	"extensions": [
		"streetsidesoftware.code-spell-checker",
		"editorconfig.editorconfig"
	],

	"forwardPorts": [],

	"mounts": [
		"source=devcontainer-history,target=/home/dev/.shell_history,type=volume",
		"source=devcontainer-zoxide,target=/home/dev/.local/share/zoxide,type=volume",
		// To preserve Docker images between runs
		"source=devcontainer-docker,target=/var/lib/docker,type=volume"
	],

	"runArgs": [
		// Requires https://github.com/nestybox/sysbox to be installed
		"--runtime=sysbox-runc"
		// To use Telepresence you need to use --privileged instead of Sysbox
		// "--privileged"
	],

	"remoteUser": "dev",

	// So the Docker & K3s init script runs
	"overrideCommand": false
}
ℹ️

For Docker-in-Docker or K3s to work, they either needs to be run with sysbox --runtime=sysbox-runc (which you need to install on your host machine) or with the --privileged flag. See https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/ for why you should avoid the --privileged flag.

For Telepresence to work you need to run the container with the --privileged flag instead of Sysbox.

Then you need to create a Dockerfile:

.devcontainer/Dockerfile
FROM ghcr.io/gantsign/devcontainer-k8s

# ** [Optional] Uncomment this section to install additional packages. **
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
#     && apt-get -y install --no-install-recommends <your-package-list-here>

# ** [Optional] Uncomment this section to install SDKs. **
# SHELL [ "/usr/bin/bash", "--login", "-c" ]
# RUN sdk_install java 11
# RUN sdk_install maven 3
# RUN nvm install --lts

# ** [Optional] Uncomment this section if you don't want to run K3s on start. **
# ENTRYPOINT ["/usr/local/share/docker-init.sh"]
# CMD ["sleep", "infinity"]

Then press Ctrl-P and select "Remote-Containers: Open Folder in Container…​" from the menu.

Python 3.9 container

Unlike the other containers this isn’t based on the base container.

Features

In addition to basic GNU/Linux command line tools this container contains the following:

Running standalone

If you just want to try it out, you can run it standalone:

docker run --rm -ti --user vscode --entrypoint zsh ghcr.io/gantsign/devcontainer-python3.9

Running in VS Code

Create a .devcontainer/devcontainer.json file in the root of your project:

.devcontainer/devcontainer.json
// For format details, see https://aka.ms/devcontainer.json
{
	"name": "GantSign",
	"image": "ghcr.io/gantsign/devcontainer-python3.9",

	"settings": {
		"editor.renderWhitespace": "all",
		"editor.rulers": [
			80,
			100,
			120
		],
		"editor.guides.bracketPairs": true
	},

	"extensions": [
		"streetsidesoftware.code-spell-checker",
		"editorconfig.editorconfig"
	],

	"runArgs": [
		// [Optional] Uncomment for improved security, requires https://github.com/nestybox/sysbox to be installed
		// "--runtime=sysbox-runc"
	]
}
ℹ️

For Docker-in-Docker to work, it either needs to be run with sysbox --runtime=sysbox-runc (which you need to install on your host machine) or with the --privileged flag. See https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/ for why you should avoid the --privileged flag.

License

This project uses the Unlicense but the resulting container images contain software under various different open-source licenses.

Author information

John Freeman

GantSign Ltd. Company No. 06109112 (registered in England)