From 0bd33c6d21269ce5ce36e0a3c6bade2f13130344 Mon Sep 17 00:00:00 2001 From: lnu Date: Mon, 18 Oct 2021 11:38:10 +0000 Subject: [PATCH] feat: devcontainer config for vscode allows to develop inside a container from vscode persion pinned to bullseye/1.17 pwsh, fish, bash and zsh installed pwsh set as default shell default build task added --- .devcontainer/Dockerfile | 26 +++++++++++++ .devcontainer/devcontainer.json | 67 +++++++++++++++++++++++++++++++++ .vscode/settings.json | 7 +++- .vscode/tasks.json | 22 +++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/tasks.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..b62641ee --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,26 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/go/.devcontainer/base.Dockerfile + +# [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.16, 1.17, 1-bullseye, 1.16-bullseye, 1.17-bullseye, 1-buster, 1.16-buster, 1.17-buster +ARG VARIANT=1-bullseye +FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} + +# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 +ARG NODE_VERSION="none" +RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# Download the Microsoft repository GPG keys +RUN wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb +# Register the Microsoft repository GPG keys +RUN dpkg -i packages-microsoft-prod.deb + +# [Optional] Uncomment this section to install additional OS packages. +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get install -y --no-install-recommends fish\ + && apt-get install -y --no-install-recommends powershell + + +# [Optional] Uncomment the next line to use go get to install anything else you need +# RUN go get -x github.com/JanDeDobbeleer/battery + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..7d82a8d0 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,67 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/go +{ + "name": "Go", + "build": { + "dockerfile": "Dockerfile", + "args": { + // Update the VARIANT arg to pick a version of Go: 1, 1.16, 1.17 + // Append -bullseye or -buster to pin to an OS version. + // Use -bullseye variants on local arm64/Apple Silicon. + "VARIANT": "1.17-bullseye", + // Options + "NODE_VERSION": "lts/*" + } + }, + "runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], + + // Set *default* container specific settings.json values on container create. + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true, + "go.gopath": "/go", + "go.goroot": "/usr/local/go", + "terminal.integrated.profiles.linux": { + "bash": { + "path": "bash" + }, + "zsh": { + "path": "zsh" + }, + "fish": { + "path": "fish" + }, + "tmux": { + "path": "tmux", + "icon": "terminal-tmux" + }, + "pwsh": { + "path": "pwsh", + "icon": "terminal-powershell" + } + }, + "terminal.integrated.defaultProfile.linux": "pwsh", + "terminal.integrated.defaultProfile.windows": "pwsh", + "terminal.integrated.defaultProfile.osx": "pwsh", + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "github.vscode-pull-request-github", + "esbenp.prettier-vscode", + "davidanson.vscode-markdownlint", + "yzhang.markdown-all-in-one", + "bungcip.better-toml", + "redhat.vscode-yaml", + "golang.go-nightly" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "go version", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 73e15260..b849af19 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,8 @@ { - "go.lintTool": "golangci-lint" + "go.lintTool": "golangci-lint", + "go.lintOnSave": "file", + "go.testOnSave": true, + "[go]": { + "editor.formatOnSave": false + } } diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..d6cbac13 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,22 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "cwd": "${workspaceRoot}", + "echoCommand": true, + "type": "shell", + "tasks": [ + { + "type": "shell", + "command": "go", + "label": "build omp", + "options": { "cwd": "${workspaceRoot}/src" }, + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": "$go", + "args": ["build", "-v", "-o", "bin/oh-my-posh"] + } + ] +}