How to Build Projects With Container Craft Dev Container and Runme
Runme interactive notebook provides an interactive notebook for developers and operations teams to run projects while documenting each step of the process.
In this guide, we will walk through setting up the ContainerCraft DevContainer as your development environment with Runme. The ContainerCraft DevContainer houses the most commonly used tools and configurations required for DevOps and provides a consistent development environment for DevOps practitioners. You will also learn how to create instructions for testing your projects directly inside the container.
Prerequisites
To get started, ensure you have the following installed on your local machine:
- Runme: Runme provides various client interfaces for accessing the Runme Notebook. For this guide, we will be using Runme on VS Code. With Runme installed on your code editor, you can proceed to set Runme as your default Markdown viewer
- Docker: Ensure you have Docker installed and running on your machine.
- VS Code Remote—Containers Extension: Install the VS Code Remote—Containers Extension to work with containers directly in VS Code.
Setting Up Your Dev Container
In this section, we will walk you through creating your dev container with all necessary files, accessing it in VS Code, testing your project in the container, and using Runme’s features to build your projects.
Create the .devcontainer
Folder.
To create your .devcontainer
folder, ensure you have a README.md
file in your project directory. In your README.md
file, run the command below:
mkdir -p ./.devcontainer
Create and Configure the devcontainer.json
The devcontainer.json
file specifies how VSCode should handle the container. In your README.md
file, run the script below. This will create the devcontainer.json
file and give it the ContainerCraft DevContainer configuration.
cat <<EOF | sudo tee ./.devcontainer/devcontainer.json > /dev/null
{
"name": "konductor",
"remoteUser": "vscode",
"dockerFile": "Dockerfile",
"init": true,
"privileged": true,
"overrideCommand": false,
"updateRemoteUserUID": true,
"shutdownAction": "stopContainer",
"securityOpt": [
"seccomp=unconfined"
],
"runArgs": [
"--privileged",
"--network=host",
"--device=/dev/kvm"
],
"mounts": [
"source=dind-var-lib-docker,target=/var/lib/docker,type=volume"
],
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
},
"postCreateCommand": "devcontainer-links",
"forwardPorts": [
1313,
2222,
6000,
7681,
8080
],
"customizations": {
"vscode": {
"extensions": [
"golang.go",
"vscodevim.vim",
"github.copilot",
"stateful.runme",
"max-ss.cyberpunk",
"ms-python.python",
"redhat.vscode-yaml",
"esbenp.prettier-vscode",
"oderwat.indent-rainbow",
"okteto.kubernetes-context",
"ms-vsliveshare.vsliveshare",
"ms-azuretools.vscode-docker",
"github.vscode-github-actions",
"ms-kubernetes-tools.kind-vscode",
"ms-vscode.vscode-typescript-next",
"github.vscode-pull-request-github",
"ms-vscode-remote.remote-containers",
"randomfractalsinc.vscode-data-table",
"visualstudioexptteam.vscodeintellicode",
"ms-kubernetes-tools.vscode-kubernetes-tools"
]
}
}
}
EOF
Create and Configure the Dockerfile
The Dockerfile
defines the base image for the dev container, which is the foundation for setting up the development environment. In your README.md
file, run the script below.
cat <<EOF | sudo tee ./.devcontainer/Dockerfile > /dev/null
FROM ghcr.io/containercraft/devcontainer:latest
EOF
This will create a Dockerfile with containercraft image in it.