From e346324301e7d7379b3a5d47a2da1a702d4eb87a Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Wed, 11 Sep 2019 19:39:01 -0400 Subject: [PATCH] Added Alpine dev container for Go development --- .devcontainer/Dockerfile | 10 ++++++++++ .devcontainer/devcontainer.json | 23 +++++++++++++++++++++++ .gitignore | 4 +++- .vscode/extensions.json | 9 +++++++++ .vscode/settings.json | 5 +++++ CONTRIBUTING.md | 12 ++++++++++++ 6 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..84a81d87 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -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 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..a96d99b4 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -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" + ] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 82995009..be4c27c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ lazydocker* TODO.md Lazydocker.code-workspace -.vscode +.vscode/* +!.vscode/extensions.json +!.vscode/settings.json \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..22ac080f --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + "recommendations": [ + "ms-vscode.Go", + "ms-vscode-remote.remote-containers", + "ms-azuretools.vscode-docker", + "davidanson.vscode-markdownlint", + "shardulm94.trailing-spaces" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..4144936c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "go.useLanguageServer": true, + "go.inferGopath": false, + "go.autocompleteUnimportedPackages": true +} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d87495aa..42b79f69 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,6 +53,18 @@ go mod vendor 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 Please note by participating in this project, you agree to abide by the [code of conduct].