Skip to content

Commit 78c2926

Browse files
committed
add devcontainer for vscode
1 parent a3c8380 commit 78c2926

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
4+
#-------------------------------------------------------------------------------------------------------------
5+
6+
FROM golang:1
7+
8+
# Avoid warnings by switching to noninteractive
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
12+
# this user's GID/UID must match your local user UID/GID to avoid permission issues
13+
# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See
14+
# https://aka.ms/vscode-remote/containers/non-root-user for details.
15+
ARG USERNAME=vscode
16+
ARG USER_UID=1000
17+
ARG USER_GID=$USER_UID
18+
19+
# Configure apt, install packages and tools
20+
RUN apt-get update \
21+
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
22+
#
23+
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
24+
&& apt-get -y install git iproute2 procps lsb-release \
25+
#
26+
# Install gocode-gomod
27+
&& go get -x -d github.com/stamblerre/gocode 2>&1 \
28+
&& go build -o gocode-gomod github.com/stamblerre/gocode \
29+
&& mv gocode-gomod $GOPATH/bin/ \
30+
#
31+
# Install Go tools
32+
&& go get -u -v \
33+
github.com/mdempsky/gocode \
34+
github.com/uudashr/gopkgs/cmd/gopkgs \
35+
github.com/ramya-rao-a/go-outline \
36+
github.com/acroca/go-symbols \
37+
github.com/godoctor/godoctor \
38+
golang.org/x/tools/cmd/guru \
39+
golang.org/x/tools/cmd/gorename \
40+
github.com/rogpeppe/godef \
41+
github.com/zmb3/gogetdoc \
42+
github.com/haya14busa/goplay/cmd/goplay \
43+
github.com/sqs/goreturns \
44+
github.com/josharian/impl \
45+
github.com/davidrjenni/reftools/cmd/fillstruct \
46+
github.com/fatih/gomodifytags \
47+
github.com/cweill/gotests/... \
48+
golang.org/x/tools/cmd/goimports \
49+
golang.org/x/lint/golint \
50+
golang.org/x/tools/cmd/gopls \
51+
github.com/alecthomas/gometalinter \
52+
honnef.co/go/tools/... \
53+
github.com/golangci/golangci-lint/cmd/golangci-lint \
54+
github.com/mgechev/revive \
55+
github.com/derekparker/delve/cmd/dlv 2>&1 \
56+
#
57+
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
58+
&& groupadd --gid $USER_GID $USERNAME \
59+
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
60+
# [Optional] Add sudo support
61+
&& apt-get install -y sudo \
62+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
63+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
64+
#
65+
# Clean up
66+
&& apt-get autoremove -y \
67+
&& apt-get clean -y \
68+
&& rm -rf /var/lib/apt/lists/*
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
2+
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/go
3+
{
4+
"name": "Go",
5+
"dockerFile": "Dockerfile",
6+
"runArgs": [
7+
// Uncomment the next line to use a non-root user. On Linux, this will prevent
8+
// new files getting created as root, but you may need to update the USER_UID
9+
// and USER_GID in .devcontainer/Dockerfile to match your user if not 1000.
10+
// "-u", "vscode",
11+
12+
"--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"
13+
],
14+
15+
// Use 'settings' to set *default* container specific settings.json values on container create.
16+
// You can edit these settings after create using File > Preferences > Settings > Remote.
17+
"settings": {
18+
"terminal.integrated.shell.linux": "/bin/bash",
19+
"go.gopath": "/go"
20+
},
21+
22+
// Uncomment the next line if you want to publish any ports.
23+
// "appPort": [],
24+
25+
// Uncomment the next line to run commands after the container is created.
26+
// "postCreateCommand": "go version",
27+
28+
// Add the IDs of extensions you want installed when the container is created in the array below.
29+
"extensions": [
30+
"ms-vscode.go"
31+
]
32+
}

0 commit comments

Comments
 (0)