DockerHub VsCode devcontainer Golang configurable image, with Intellisense & hot-reloading.
713
Registry: DockerHub
Source code: GitHub (private)
Demo project: GitHub
air - for hot-reloading your appgopls - Intellisense & syntax highlighting for your Go projectClone the demo-project branch in an empty directory:
git clone --branch=demo-project https://github.com/google85/vscode-devcontainer-go.git go-project
cd go-project/
Open project in VsCode
code .
Use VsCode Reopen in DevContainer option.
Open a terminal in VsCode and type:
cd src/
make
Pull the image
docker pull google85/vscode-devcontainer-go:1.21.0
Create a .devcontainer folder in the root of your project
mkdir -p .devcontainer
Create the devcontainer.json configuration file
cat <<EOF | tee .devcontainer/devcontainer.json
{
"name": "go-project",
"dockerComposeFile": "docker-compose.devcontainer.yml",
"service": "go-devcontainer",
"workspaceFolder": "/usr/src/app",
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/root/.ssh,type=bind,consistency=cached",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.gitconfig,target=/root/.gitconfig,type=bind,consistency=cached"
],
"customizations": {
"vscode": {
"settings": {
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"golang.Go"
]
}
},
"postCreateCommand": "after-setup.sh",
"forwardPorts": [
// 8000
]
}
EOF
Create the docker-compose.devcontainer.yml to be used
cat <<EOF | tee .devcontainer/docker-compose.devcontainer.yml
version: '3'
services:
go-devcontainer:
image: google85/vscode-devcontainer-go:1.21.0
hostname: go-devcontainer
working_dir: /usr/src/app
#env_file:
#- ../.env
environment:
- TZ=Europe/Bucharest
- GOPATH=/go
volumes:
- ..:/usr/src/app
extra_hosts:
- "host.docker.internal:host-gateway"
tty: true # very important
EOF
Open project in VsCode
Use VsCode Reopen in DevContainer option.
Content type
Image
Digest
sha256:3403d9741…
Size
537.8 MB
Last updated
almost 3 years ago
docker pull google85/vscode-devcontainer-go