Provision the wagov devcontainer toolchain with pyinfra
Project description
Cloud Native Devcontainer
Production-ready development container with modern tooling for cloud-native and infrastructure development.
What's Inside
Languages: Go, Node.js, Python, Rust (via cargo-binstall), uv, pnpm
Cloud: AWS CLI, Terraform, Kubernetes (kubectl, k9s, k3d, helm, kustomize)
Development: Docker-from-Docker, git, just, mise, direnv, starship, zellij, neovim, lazygit
Security: Trivy, Semgrep, cosign, SLSA verifier, lychee (link checker)
Utilities: ripgrep, fzf, jq, yq, httpie, hurl, btop, restic, rclone
Complete list: See
src/wagov_devcontainer/spec.pyandsrc/wagov_devcontainer/deploy.py
Quick Start
VS Code Devcontainer (Recommended)
Create .devcontainer/devcontainer.json:
{
"name": "My Project",
"image": "ghcr.io/wagov-dtt/devcontainer-base",
"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
],
"onCreateCommand": "docker-init.sh",
"remoteEnv": {
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}",
"DOCKER_API_VERSION": "1.43"
},
"remoteUser": "vscode"
}
Open in VS Code: Cmd/Ctrl+Shift+P → "Dev Containers: Reopen in Container"
Why these settings?
- Docker socket bind mount - Enables Docker via host socket (no privileged mode needed, Docker CLI pre-installed via extrepo)
onCreateCommand- Runs baked-indocker-init.shwhich fixes socket permissionsDOCKER_API_VERSION- Caps Docker client API version for compatibility with older daemons (set to 1.43 for broad compatibility)LOCAL_WORKSPACE_FOLDER- Enables bind mounts from inside the container using host pathsremoteUser: vscode- Correct user permissions
Docker CLI
# Basic usage (mount host Docker socket)
docker run -it --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
--group-add $(stat -c '%g' /var/run/docker.sock) \
ghcr.io/wagov-dtt/devcontainer-base
# With your projects mounted
docker run -it --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
--group-add $(stat -c '%g' /var/run/docker.sock) \
-v ~/projects:/workspaces \
ghcr.io/wagov-dtt/devcontainer-base
Install on Existing System
# Preferred: run the published package directly
uvx wagov-devcontainer
# Or with pipx
pipx run --spec wagov-devcontainer wagov-devcontainer
# Repo helper script for Debian/Ubuntu
curl -sSL https://raw.githubusercontent.com/wagov-dtt/devcontainer-base/main/install.sh | sh
Use as Template
- GitHub: Click "Use this template" to create your own repository
- Codespaces: Works immediately - click "Code" → "Create codespace"
- Local: Clone and customize as needed
CI/CD Integration
Run tests in the devcontainer for guaranteed consistency:
- name: Run tests in devcontainer
uses: devcontainers/ci@v0.3
with:
imageName: local/devcontainer
push: never
runCmd: |
just test
mise run lint
See .github/workflows/test-devcontainer.yml for complete example.
How It Works
Architecture
- Base: Debian stable-backports (currently Trixie/13)
- Package Management: APT for system tools, mise for development tools
- Build: Python package (
wagov-devcontainer) runs a pyinfra deploy during Docker build or local install - Docker-from-Docker: Host socket bind mount (Docker CLI pre-installed via extrepo, no privileged mode needed)
Tool Sources
Tools are installed from two sources, preferring APT when available:
- APT via extrepo (preferred) - Signed packages from official repos
- Docker, GitHub CLI, Terraform, kubectl, mise
- mise - Cross-platform tools not in APT, or needing version flexibility
- Languages (Go, Node, Python), k9s, trivy, starship
Key Features
- Security: SBOM, signed images, Trivy scanning
- Performance: Multi-platform builds (amd64/arm64), layer caching
- Flexibility: mise auto-switches tool versions per project
- Supply Chain: Verified packages via extrepo
Adding Tools
Edit src/wagov_devcontainer/spec.py and add to the appropriate list:
MISE_TOOLS = (
# Simple: just the tool name (defaults to latest)
+ ["pipx:your-tool"] # or npm:, cargo:, github:user/repo
# Complex: tuple with TOML config string
+ [("pipx:tool", '{ version = "latest", extras = "extra", uvx_args = "--with dep" }')]
)
For provisioning behaviour, edit src/wagov_devcontainer/deploy.py. Then rebuild: just build
See CONTRIBUTING.md for contributor guidance.
Optional Cloud CLIs
GCP CLI and Azure CLI are not installed by default (saves ~1 GB). Install them when needed:
# GCP CLI (repo already enabled via extrepo)
sudo apt-get update && sudo apt-get install -y google-cloud-cli
# Azure CLI (repo not available for Trixie, use pipx)
pipx install azure-cli
Development Commands
just # List all commands
just build # Build test image
just test # Test Docker-from-Docker
just dev # Interactive shell
just scan # Security scan with Trivy
just lint # Format and lint Python sources
just clean # Clean up images
For maintainers:
just publish # Multi-platform build + push
just shell # Run published image interactively
Troubleshooting
| Issue | Solution |
|---|---|
| Docker not working | Ensure Docker socket is available on the host |
| Tool missing | Check src/wagov_devcontainer/spec.py |
| Build fails | Run just clean then just build |
| Permission errors | User should be in docker group (automatic) |
| mise issues | Run mise doctor inside container |
Contributing
- Fork and clone the repo
- Make changes to
src/wagov_devcontainer/,Dockerfile, or docs - Test:
just build && just test && just dev - Submit PR with test results
What to contribute:
- New tools or tool updates
- Documentation improvements
- Bug fixes
- Performance optimisations
See CONTRIBUTING.md for contributor guidance and project philosophy.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wagov_devcontainer-0.1.0.tar.gz.
File metadata
- Download URL: wagov_devcontainer-0.1.0.tar.gz
- Upload date:
- Size: 66.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd2c91fe192b1ff58cb30828c266862936fb1fe32f0093ab74a6b2a628527baa
|
|
| MD5 |
26d0c83eeb66052c50b93b2c1cb22e74
|
|
| BLAKE2b-256 |
6b8a4b968e5f105cee81510a969f35692c988cb59bbaae23451f2f4edbeccce8
|
Provenance
The following attestation bundles were made for wagov_devcontainer-0.1.0.tar.gz:
Publisher:
release.yml on wagov-dtt/devcontainer-base
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wagov_devcontainer-0.1.0.tar.gz -
Subject digest:
bd2c91fe192b1ff58cb30828c266862936fb1fe32f0093ab74a6b2a628527baa - Sigstore transparency entry: 1178093169
- Sigstore integration time:
-
Permalink:
wagov-dtt/devcontainer-base@1a2a90da1799da859cbe5bc03b89792fc5513912 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/wagov-dtt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1a2a90da1799da859cbe5bc03b89792fc5513912 -
Trigger Event:
push
-
Statement type:
File details
Details for the file wagov_devcontainer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: wagov_devcontainer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16222fa574c55931707ce00e62a9f2cf0304b81a9ce21de4cf6a2ad06df6e75b
|
|
| MD5 |
c41ae3ca980ad644f3f0f169a3f5fa24
|
|
| BLAKE2b-256 |
5904f3f673646bd37ab6e3669a6d87d2b1b89bbad33a9759e551101b13f24ff7
|
Provenance
The following attestation bundles were made for wagov_devcontainer-0.1.0-py3-none-any.whl:
Publisher:
release.yml on wagov-dtt/devcontainer-base
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wagov_devcontainer-0.1.0-py3-none-any.whl -
Subject digest:
16222fa574c55931707ce00e62a9f2cf0304b81a9ce21de4cf6a2ad06df6e75b - Sigstore transparency entry: 1178093228
- Sigstore integration time:
-
Permalink:
wagov-dtt/devcontainer-base@1a2a90da1799da859cbe5bc03b89792fc5513912 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/wagov-dtt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1a2a90da1799da859cbe5bc03b89792fc5513912 -
Trigger Event:
push
-
Statement type: