summaryrefslogtreecommitdiffstats
path: root/.devcontainer
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-11-13 09:09:31 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-11-13 10:56:22 +1100
commit903e65ae8d3e5f65d6b05ff411fbd99b114c5db4 (patch)
treeb2974168cefbc410d4b1ace437fe62f330c401b5 /.devcontainer
parent3e153153390f24fe1505d82514dd65bfb0f1df31 (diff)
add devcontainer folder
Diffstat (limited to '.devcontainer')
-rw-r--r--.devcontainer/Dockerfile13
-rw-r--r--.devcontainer/devcontainer.json68
2 files changed, 81 insertions, 0 deletions
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 000000000..03c43d411
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,13 @@
+# adapted from https://github.com/devcontainers/images/blob/main/src/go/.devcontainer/Dockerfile
+
+# [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.19, 1.18, 1-bullseye, 1.19-bullseye, 1.18-bullseye, 1-buster, 1.19-buster, 1.18-buster
+ARG VARIANT=1-bullseye
+FROM golang:${VARIANT}
+
+RUN go install mvdan.cc/gofumpt@latest
+RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
+RUN golangci-lint --version
+
+# [Optional] Uncomment this section to install additional OS packages.
+# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
+# && apt-get -y install --no-install-recommends <your-package-list-here>
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 000000000..3c8537052
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,68 @@
+// adapted from https://github.com/devcontainers/images/blob/main/src/go/.devcontainer/devcontainer.json
+{
+ "build": {
+ "dockerfile": "./Dockerfile",
+ "context": "."
+ },
+ "features": {
+ "ghcr.io/devcontainers/features/common-utils:1": {
+ "installZsh": "true",
+ "username": "vscode",
+ "uid": "1000",
+ "gid": "1000",
+ "upgradePackages": "true"
+ },
+ "ghcr.io/devcontainers/features/go:1": {
+ "version": "none"
+ },
+ "ghcr.io/devcontainers/features/git:1": {
+ "version": "latest",
+ "ppa": "false"
+ }
+ },
+ "overrideFeatureInstallOrder": [
+ "ghcr.io/devcontainers/features/common-utils"
+ ],
+ // not sure if we actually need these
+ "runArgs": [
+ "--cap-add=SYS_PTRACE",
+ "--security-opt",
+ "seccomp=unconfined"
+ ],
+ // 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]": {
+ "editor.formatOnSave": true,
+ "editor.codeActionsOnSave": {
+ "source.organizeImports": true
+ }
+ },
+ "go.lintTool": "golangci-lint",
+ "gopls": {
+ "formatting.gofumpt": true,
+ "usePlaceholders": false // add parameter placeholders when completing a function
+ },
+ "files.eol": "\n"
+ },
+ // Add the IDs of extensions you want installed when the container is created.
+ "extensions": [
+ "golang.Go"
+ ]
+ }
+ },
+ // Use 'postCreateCommand' to run commands after the container is created.
+ // "postCreateCommand": "go version",
+
+ // See https://www.kenmuse.com/blog/avoiding-dubious-ownership-in-dev-containers/
+ "postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
+
+ // Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
+ "remoteUser": "vscode"
+}