Skip to content

Commit 66070e3

Browse files
authored
devcontainer
1 parent 2b07645 commit 66070e3

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

.devcontainer/Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# [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
2+
ARG VARIANT=1.17-bullseye
3+
FROM mcr.microsoft.com/vscode/devcontainers/go:${VARIANT}
4+
5+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
6+
ARG NODE_VERSION="none"
7+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
8+
9+
ENV GOPROXY="https://goproxy.cn,direct"
10+
11+
12+
# [Optional] Uncomment this section to install additional OS packages.
13+
RUN set -e \
14+
&& sed -i "s/deb.debian.org/mirrors.aliyun.com/g" /etc/apt/sources.list \
15+
&& sed -i "s/security.debian.org/mirrors.aliyun.com/g" /etc/apt/sources.list \
16+
&& apt-get update && export DEBIAN_FRONTEND=noninteractive
17+
18+
# [Optional] Uncomment the next lines to use go get to install anything else you need
19+
# USER vscode
20+
# RUN go get -x <your-dependency-or-tool>
21+
22+
# [Optional] Uncomment this line to install global node packages.
23+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/devcontainer.json

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "Go",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"args": {
6+
// Update the VARIANT arg to pick a version of Go: 1, 1.16, 1.17
7+
// Append -bullseye or -buster to pin to an OS version.
8+
// Use -bullseye variants on local arm64/Apple Silicon.
9+
"VARIANT": "1.17-bullseye",
10+
// Options
11+
"NODE_VERSION": "none"
12+
}
13+
},
14+
"runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
15+
16+
// Set *default* container specific settings.json values on container create.
17+
"settings": {
18+
"go.toolsManagement.checkForUpdates": "local",
19+
"go.useLanguageServer": true,
20+
"go.gopath": "/go",
21+
"terminal.integrated.defaultProfile.linux": "zsh",
22+
"terminal.integrated.defaultProfile.osx": "zsh",
23+
"terminal.integrated.defaultProfile.windows": "zsh",
24+
},
25+
26+
// Add the IDs of extensions you want installed when the container is created.
27+
"extensions": [
28+
"golang.Go",
29+
"eamodio.gitlens",
30+
"mohsen1.prettify-json",
31+
"zxh404.vscode-proto3",
32+
"bierner.markdown-preview-github-styles",
33+
"cschleiden.vscode-github-actions",
34+
"redhat.vscode-yaml",
35+
"carlos-algms.make-task-provider",
36+
"streetsidesoftware.code-spell-checker",
37+
"k--kato.intellij-idea-keybindings",
38+
"donjayamanne.githistory",
39+
"github.vscode-pull-request-github"
40+
],
41+
42+
"remoteEnv": {
43+
"GOPROXY": "https://goproxy.cn,direct",
44+
},
45+
46+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
47+
"forwardPorts": [16600],
48+
49+
"portsAttributes": {
50+
"16600": {
51+
"label": "HTTP Port",
52+
"onAutoForward": "openBrowserOnce",
53+
}
54+
},
55+
56+
// Use 'postCreateCommand' to run commands after the container is created.
57+
"postCreateCommand": "go mod download",
58+
59+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
60+
// "remoteUser": "vscode",
61+
// "workspaceFolder": "/workspace/project",
62+
// "workspaceMount": "source=/home/admin/workspace/project,target=/workspace/project,type=bind,consistency=cached"
63+
}

0 commit comments

Comments
 (0)