Dev container documentation and cleanup
This commit is contained in:
5
.devcontainer/.dockerignore
Normal file
5
.devcontainer/.dockerignore
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.dockerignore
|
||||||
|
devcontainer.json
|
||||||
|
docker-compose.yml
|
||||||
|
Dockerfile
|
||||||
|
README.md
|
||||||
1
.devcontainer/Dockerfile
Normal file
1
.devcontainer/Dockerfile
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FROM qmcgaw/godevcontainer
|
||||||
68
.devcontainer/README.md
Normal file
68
.devcontainer/README.md
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
# Development container
|
||||||
|
|
||||||
|
Development container that can be used with VSCode.
|
||||||
|
|
||||||
|
It works on Linux, Windows and OSX.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- [VS code](https://code.visualstudio.com/download) installed
|
||||||
|
- [VS code remote containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed
|
||||||
|
- [Docker](https://www.docker.com/products/docker-desktop) installed and running
|
||||||
|
- If you don't use Linux or WSL 2, share your home directory `~/` and the directory of your project with Docker Desktop
|
||||||
|
- [Docker Compose](https://docs.docker.com/compose/install/) installed
|
||||||
|
- Ensure your host has the following and that they are accessible by Docker:
|
||||||
|
- `~/.ssh` directory
|
||||||
|
- `~/.gitconfig` file (can be empty)
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## Customization
|
||||||
|
|
||||||
|
### Customize the image
|
||||||
|
|
||||||
|
You can make changes to the [Dockerfile](Dockerfile) and then rebuild the image. For example, your Dockerfile could be:
|
||||||
|
|
||||||
|
```Dockerfile
|
||||||
|
FROM qmcgaw/godevcontainer
|
||||||
|
USER root
|
||||||
|
RUN apk add curl
|
||||||
|
USER vscode
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that you may need to use `USER root` to build as root, and then change back to `USER vscode`.
|
||||||
|
|
||||||
|
To rebuild the image, either:
|
||||||
|
|
||||||
|
- With VSCode through the command palette, select `Remote-Containers: Rebuild and reopen in container`
|
||||||
|
- With a terminal, go to this directory and `docker-compose build`
|
||||||
|
|
||||||
|
### Customize VS code settings
|
||||||
|
|
||||||
|
You can customize **settings** and **extensions** in the [devcontainer.json](devcontainer.json) definition file.
|
||||||
|
|
||||||
|
### Entrypoint script
|
||||||
|
|
||||||
|
You can bind mount a shell script to `/home/vscode/.welcome.sh` to replace the [current welcome script](shell/.welcome.sh).
|
||||||
|
|
||||||
|
### Publish a port
|
||||||
|
|
||||||
|
To access a port from your host to your development container, publish a port in [docker-compose.yml](docker-compose.yml).
|
||||||
|
|
||||||
|
### Run other services
|
||||||
|
|
||||||
|
1. Modify [docker-compose.yml](docker-compose.yml) to launch other services at the same time as this development container, such as a test database:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
database:
|
||||||
|
image: postgres
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: password
|
||||||
|
```
|
||||||
|
|
||||||
|
1. In [devcontainer.json](devcontainer.json), change the line `"runServices": ["vscode"],` to `"runServices": ["vscode", "database"],`.
|
||||||
|
1. In the VS code command palette, rebuild the container.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "pia-dev",
|
"name": "gluetun-dev",
|
||||||
"dockerComposeFile": [
|
"dockerComposeFile": [
|
||||||
"docker-compose.yml"
|
"docker-compose.yml"
|
||||||
],
|
],
|
||||||
@@ -12,27 +12,25 @@
|
|||||||
"workspaceFolder": "/workspace",
|
"workspaceFolder": "/workspace",
|
||||||
"extensions": [
|
"extensions": [
|
||||||
"golang.go",
|
"golang.go",
|
||||||
"IBM.output-colorizer",
|
"eamodio.gitlens", // IDE Git information
|
||||||
"eamodio.gitlens",
|
|
||||||
"mhutchie.git-graph",
|
|
||||||
"davidanson.vscode-markdownlint",
|
"davidanson.vscode-markdownlint",
|
||||||
"shardulm94.trailing-spaces",
|
"ms-azuretools.vscode-docker", // Docker integration and linting
|
||||||
"alefragnani.Bookmarks",
|
"shardulm94.trailing-spaces", // Show trailing spaces
|
||||||
"Gruntfuggly.todo-tree",
|
"Gruntfuggly.todo-tree", // Highlights TODO comments
|
||||||
"mohsen1.prettify-json",
|
"bierner.emojisense", // Emoji sense for markdown
|
||||||
"quicktype.quicktype",
|
"stkb.rewrap", // rewrap comments after n characters on one line
|
||||||
"spikespaz.vscode-smoothtype",
|
"vscode-icons-team.vscode-icons", // Better file extension icons
|
||||||
"stkb.rewrap",
|
"github.vscode-pull-request-github", // Github interaction
|
||||||
"vscode-icons-team.vscode-icons"
|
"redhat.vscode-yaml", // Kubernetes, Drone syntax highlighting
|
||||||
|
"bajdzis.vscode-database", // Supports connections to mysql or postgres, over SSL, socked
|
||||||
|
"IBM.output-colorizer", // Colorize your output/test logs
|
||||||
|
"mohsen1.prettify-json", // Prettify JSON data
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
// General settings
|
|
||||||
"files.eol": "\n",
|
"files.eol": "\n",
|
||||||
// Docker
|
|
||||||
"remote.extensionKind": {
|
"remote.extensionKind": {
|
||||||
"ms-azuretools.vscode-docker": "workspace"
|
"ms-azuretools.vscode-docker": "workspace"
|
||||||
},
|
},
|
||||||
// Golang general settings
|
|
||||||
"go.useLanguageServer": true,
|
"go.useLanguageServer": true,
|
||||||
"go.autocompleteUnimportedPackages": true,
|
"go.autocompleteUnimportedPackages": true,
|
||||||
"go.gotoSymbol.includeImports": true,
|
"go.gotoSymbol.includeImports": true,
|
||||||
@@ -43,7 +41,6 @@
|
|||||||
"usePlaceholders": false
|
"usePlaceholders": false
|
||||||
},
|
},
|
||||||
"go.lintTool": "golangci-lint",
|
"go.lintTool": "golangci-lint",
|
||||||
// Golang on save
|
|
||||||
"go.buildOnSave": "workspace",
|
"go.buildOnSave": "workspace",
|
||||||
"go.lintOnSave": "workspace",
|
"go.lintOnSave": "workspace",
|
||||||
"go.vetOnSave": "workspace",
|
"go.vetOnSave": "workspace",
|
||||||
@@ -53,20 +50,21 @@
|
|||||||
"source.organizeImports": true
|
"source.organizeImports": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Golang testing
|
|
||||||
"go.toolsEnvVars": {
|
"go.toolsEnvVars": {
|
||||||
"GOFLAGS": "-tags=integration"
|
"GOFLAGS": "-tags=",
|
||||||
|
// "CGO_ENABLED": 1 // for the race detector
|
||||||
},
|
},
|
||||||
"gopls.env": {
|
"gopls.env": {
|
||||||
"GOFLAGS": "-tags=integration"
|
"GOFLAGS": "-tags="
|
||||||
},
|
},
|
||||||
"go.testEnvVars": {},
|
"go.testEnvVars": {},
|
||||||
"go.testFlags": [
|
"go.testFlags": [
|
||||||
"-v",
|
"-v",
|
||||||
// "-race"
|
// "-race"
|
||||||
],
|
],
|
||||||
"go.testTimeout": "600s",
|
"go.testTimeout": "10s",
|
||||||
|
"go.coverOnSingleTest": true,
|
||||||
"go.coverOnSingleTestFile": true,
|
"go.coverOnSingleTestFile": true,
|
||||||
"go.coverOnSingleTest": true
|
"go.coverOnTestPackage": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,14 +2,24 @@ version: "3.7"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
vscode:
|
vscode:
|
||||||
image: qmcgaw/godevcontainer
|
build: .
|
||||||
|
image: godevcontainer
|
||||||
volumes:
|
volumes:
|
||||||
- ../:/workspace
|
- ../:/workspace
|
||||||
|
# Docker socket to access Docker server
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
# SSH directory
|
||||||
- ~/.ssh:/home/vscode/.ssh
|
- ~/.ssh:/home/vscode/.ssh
|
||||||
- ~/.ssh:/root/.ssh
|
- ~/.ssh:/root/.ssh
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
# Git config
|
||||||
|
- ~/.gitconfig:/home/districter/.gitconfig
|
||||||
|
- ~/.gitconfig:/root/.gitconfig
|
||||||
|
environment:
|
||||||
|
- TZ=
|
||||||
cap_add:
|
cap_add:
|
||||||
|
# For debugging with dlv
|
||||||
- SYS_PTRACE
|
- SYS_PTRACE
|
||||||
security_opt:
|
security_opt:
|
||||||
|
# For debugging with dlv
|
||||||
- seccomp:unconfined
|
- seccomp:unconfined
|
||||||
entrypoint: zsh -c "while sleep 1000; do :; done"
|
entrypoint: zsh -c "while sleep 1000; do :; done"
|
||||||
|
|||||||
Reference in New Issue
Block a user