Maintenance: devcontainer changes

- Bind mount for root only
- Support for Windows Hyperv bind mounts
- Run go mod tidy after go mod download
- Use :z flag for possibly shared bind mounts
- Bind mount zsh_history
- Bind mount docker config directory
This commit is contained in:
Quentin McGaw
2021-04-24 13:53:48 +00:00
parent fb8279f8f0
commit 04313d3c3b
3 changed files with 12 additions and 6 deletions

View File

@@ -19,6 +19,7 @@ It works on Linux, Windows and OSX.
1. Open the command palette in Visual Studio Code (CTRL+SHIFT+P). 1. Open the command palette in Visual Studio Code (CTRL+SHIFT+P).
1. Select `Remote-Containers: Open Folder in Container...` and choose the project directory. 1. Select `Remote-Containers: Open Folder in Container...` and choose the project directory.
1. For Docker running on Windows HyperV, if you want to use SSH keys, bind mount them at `/tmp/.ssh` by changing the `volumes` section in the [docker-compose.yml](docker-compose.yml).
## Customization ## Customization

View File

@@ -8,7 +8,7 @@
"vscode" "vscode"
], ],
"shutdownAction": "stopCompose", "shutdownAction": "stopCompose",
"postCreateCommand": "go mod download", "postCreateCommand": "source ~/.windows.sh && go mod download && go mod tidy",
"workspaceFolder": "/workspace", "workspaceFolder": "/workspace",
"extensions": [ "extensions": [
"golang.go", "golang.go",

View File

@@ -8,12 +8,17 @@ services:
- ../:/workspace - ../:/workspace
# Docker socket to access Docker server # Docker socket to access Docker server
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
# SSH directory # Docker configuration
- ~/.ssh:/home/vscode/.ssh - ~/.docker:/root/.docker:z
- ~/.ssh:/root/.ssh # SSH directory for Linux, OSX and WSL
- ~/.ssh:/root/.ssh:z
# For Windows without WSL, a copy will be made
# from /tmp/.ssh to ~/.ssh to fix permissions
#- ~/.ssh:/tmp/.ssh:ro
# Shell history persistence
- ~/.zsh_history:/root/.zsh_history:z
# Git config # Git config
- ~/.gitconfig:/home/districter/.gitconfig - ~/.gitconfig:/root/.gitconfig:z
- ~/.gitconfig:/root/.gitconfig
environment: environment:
- TZ= - TZ=
cap_add: cap_add: