Skip to content

Instantly share code, notes, and snippets.

@jrussellsmyth
Last active October 10, 2024 15:55
Show Gist options
  • Select an option

  • Save jrussellsmyth/9775cfb444c58c9de71724e42ef244e4 to your computer and use it in GitHub Desktop.

Select an option

Save jrussellsmyth/9775cfb444c58c9de71724e42ef244e4 to your computer and use it in GitHub Desktop.
Basic devcontainer for go using a docker compose file. use with https://gist.github.com/jrussellsmyth/97d8b77adb9307d1c9d2f4785056d21b
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/go
{
"name": "servicename [Go]",
"dockerComposeFile": [
"docker-compose.yml"
],
// the service in the compose file to use for the dev environment
"service": "go-service",
"workspaceFolder": "${localWorkspaceFolder}",
"shutdownAction": "stopCompose",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [2222],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",
"postCreateCommand" :{
"graphviz": "sudo apt-get update && sudo apt-get -y install hey graphviz",
"moq":"go install github.com/matryer/moq@latest"
},
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"remoteEnv": {
},
// Set *default* container specific settings.json values on container create.
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"go.goroot": "/usr/local/go",
"httpyac.environmentSelectedOnStart": [
"devcontainer-local"
]
}
// ,
// "extensions": [
// "golang.Go",
// "redhat.vscode-xml",
// "redhat.vscode-yaml",
// "yokawasa.jwt-debugger",
// "atlassian.atlascode",
// "anweber.vscode-httpyac",
// "eamodio.gitlens",
// "42crunch.vscode-openapi",
// "mongodb.mongodb-vscode",
// "ms-vscode.makefile-tools",
// "ckolkman.vscode-postgres",
// "dunn.redis"
// ]
}
},
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
},
// necessary for the features
"overrideCommand": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment