|
| 1 | +{ |
| 2 | + // Human-readable name that shows up in both VS Code and GoLand |
| 3 | + "name": "go-template dev container", |
| 4 | + |
| 5 | + // Official Go 1.24 Bullseye image maintained by the Dev Containers team |
| 6 | + "image": "mcr.microsoft.com/devcontainers/go:0-1.24-bullseye", |
| 7 | + |
| 8 | + // Dev Container “features” – extra tooling installed declaratively |
| 9 | + "features": { |
| 10 | + // GitHub CLI for release automation / CODEOWNERS triage |
| 11 | + "ghcr.io/devcontainers/features/github-cli:1": {}, |
| 12 | + |
| 13 | + // golangci-lint (matches your repo's Makefile / CI) |
| 14 | + "ghcr.io/devcontainers/features/golangci-lint:2": { "version": "2.2.0" }, |
| 15 | + |
| 16 | + // Secure Docker-outside-of-Docker so you can build/publish images from inside the container |
| 17 | + "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} |
| 18 | + }, |
| 19 | + |
| 20 | + // Handy mounts (build cache + host Docker socket) |
| 21 | + "mounts": [ |
| 22 | + "type=cache,target=/home/vscode/.cache/go-build", |
| 23 | + "type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock" |
| 24 | + ], |
| 25 | + |
| 26 | + // Drop all Linux caps and block “sudo bash” style privilege escalation |
| 27 | + "runArgs": [ |
| 28 | + "--cap-drop=ALL", |
| 29 | + "--security-opt", "no-new-privileges:true" |
| 30 | + ], |
| 31 | + |
| 32 | + // Recommended post-create sanity check: vet and full test suite |
| 33 | + "postCreateCommand": "go vet ./... && go test ./...", |
| 34 | + |
| 35 | + // IDE-specific tweaks |
| 36 | + "customizations": { |
| 37 | + "vscode": { |
| 38 | + "settings": { |
| 39 | + "go.useLanguageServer": true, |
| 40 | + "go.lintTool": "golangci-lint", |
| 41 | + "go.toolsEnvVars": { "GOFLAGS": "-buildvcs=false" }, |
| 42 | + "editor.formatOnSave": true, |
| 43 | + "editor.codeActionsOnSave": { "source.organizeImports": true } |
| 44 | + }, |
| 45 | + "extensions": [ |
| 46 | + "golang.Go", |
| 47 | + "github.vscode-github-actions", |
| 48 | + "eamodio.gitlens" |
| 49 | + ] |
| 50 | + } |
| 51 | + // GoLand reads the same settings automatically; no extra block needed |
| 52 | + }, |
| 53 | + |
| 54 | + // Keep using the non-root “vscode” user created by the base image |
| 55 | + "remoteUser": "vscode" |
| 56 | +} |
0 commit comments