Added Alpine dev container for Go development

This commit is contained in:
Quentin McGaw 2019-09-11 19:39:01 -04:00
parent 817fb5349b
commit e346324301
6 changed files with 62 additions and 1 deletions

10
.devcontainer/Dockerfile Normal file
View file

@ -0,0 +1,10 @@
FROM golang:1.13-alpine3.10
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=1000
RUN adduser $USERNAME -s /bin/sh -D -u $USER_UID $USER_GID && \
mkdir -p /etc/sudoers.d && \
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME
RUN apk add -q --update --progress --no-cache git sudo
RUN go get -u -v golang.org/x/tools/cmd/gopls 2>&1

View file

@ -0,0 +1,23 @@
{
"name": "lazydocker dev",
"dockerFile": "Dockerfile",
"extensions": [
"ms-vscode.go",
"davidanson.vscode-markdownlint",
"shardulm94.trailing-spaces"
],
"settings": {
"go.gopath": "/go",
"go.inferGopath": false,
"go.useLanguageServer": true
},
"postCreateCommand": "go mod download",
"runArgs": [
// Comment out the next line to run as root instead.
"-u",
"vscode",
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
]
}

4
.gitignore vendored
View file

@ -1,4 +1,6 @@
lazydocker* lazydocker*
TODO.md TODO.md
Lazydocker.code-workspace Lazydocker.code-workspace
.vscode .vscode/*
!.vscode/extensions.json
!.vscode/settings.json

9
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,9 @@
{
"recommendations": [
"ms-vscode.Go",
"ms-vscode-remote.remote-containers",
"ms-azuretools.vscode-docker",
"davidanson.vscode-markdownlint",
"shardulm94.trailing-spaces"
]
}

5
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"go.useLanguageServer": true,
"go.inferGopath": false,
"go.autocompleteUnimportedPackages": true
}

View file

@ -53,6 +53,18 @@ go mod vendor
Hopefully this will be much more streamlined in the future :) Hopefully this will be much more streamlined in the future :)
## Dev environment
### Visual Studio Code
If you use Visual Studio Code:
1. Install the recommended extensions from the popup when you open this repository with it. It will essentially install
- the Go extension
- the Remote Containers extension
1. You can then open the command palette (CTRL+Shift+P) and enter `Remote-Containers: Open Folder in container...`
1. Select this directory
1. Your dev environment will then be in a container so no need to setup any dependency on your host OS.
## Code of conduct ## Code of conduct
Please note by participating in this project, you agree to abide by the [code of conduct]. Please note by participating in this project, you agree to abide by the [code of conduct].