2020-07-25 01:38:41 +00:00
|
|
|
# Update the VARIANT arg in devcontainer.json to pick an Go version
|
2020-07-29 19:57:06 +09:00
|
|
|
ARG VARIANT=1
|
2020-07-25 01:38:41 +00:00
|
|
|
FROM golang:${VARIANT}
|
2019-04-16 19:54:02 -07:00
|
|
|
|
2020-07-25 01:38:41 +00:00
|
|
|
# This Dockerfile adds a non-root user with sudo access. Update the “remoteUser” property in
|
|
|
|
|
# devcontainer.json to use it. More info: https://aka.ms/vscode-remote/containers/non-root-user.
|
2019-08-05 23:30:46 +00:00
|
|
|
ARG USERNAME=vscode
|
|
|
|
|
ARG USER_UID=1000
|
|
|
|
|
ARG USER_GID=$USER_UID
|
|
|
|
|
|
2020-07-25 01:38:41 +00:00
|
|
|
# Options for common setup script - SHA generated on release
|
|
|
|
|
ARG INSTALL_ZSH="true"
|
|
|
|
|
ARG UPGRADE_PACKAGES="false"
|
|
|
|
|
ARG COMMON_SCRIPT_SOURCE="https://raw.githubusercontent.com/microsoft/vscode-dev-containers/master/script-library/common-debian.sh"
|
|
|
|
|
ARG COMMON_SCRIPT_SHA="dev-mode"
|
|
|
|
|
|
|
|
|
|
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
|
2019-06-28 20:46:20 +00:00
|
|
|
RUN apt-get update \
|
2020-07-25 01:38:41 +00:00
|
|
|
&& export DEBIAN_FRONTEND=noninteractive \
|
|
|
|
|
&& apt-get -y install --no-install-recommends curl ca-certificates 2>&1 \
|
|
|
|
|
&& curl -sSL ${COMMON_SCRIPT_SOURCE} -o /tmp/common-setup.sh \
|
|
|
|
|
&& ([ "${COMMON_SCRIPT_SHA}" = "dev-mode" ] || (echo "${COMMON_SCRIPT_SHA} /tmp/common-setup.sh" | sha256sum -c -)) \
|
|
|
|
|
&& /bin/bash /tmp/common-setup.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \
|
2019-10-22 13:58:24 -07:00
|
|
|
# Clean up
|
2019-12-11 05:03:16 +00:00
|
|
|
&& apt-get autoremove -y \
|
|
|
|
|
&& apt-get clean -y \
|
2020-07-25 01:38:41 +00:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
# Install Go tools
|
|
|
|
|
ARG GO_TOOLS_WITH_MODULES="\
|
|
|
|
|
golang.org/x/tools/gopls \
|
|
|
|
|
honnef.co/go/tools/... \
|
|
|
|
|
golang.org/x/tools/cmd/gorename \
|
|
|
|
|
golang.org/x/tools/cmd/goimports \
|
|
|
|
|
golang.org/x/tools/cmd/guru \
|
2020-07-29 19:57:06 +09:00
|
|
|
golang.org/x/lint/golint \
|
|
|
|
|
github.com/mdempsky/gocode \
|
2020-07-25 01:38:41 +00:00
|
|
|
github.com/cweill/gotests/... \
|
|
|
|
|
github.com/haya14busa/goplay/cmd/goplay \
|
2020-07-29 19:57:06 +09:00
|
|
|
github.com/sqs/goreturns \
|
2020-07-25 01:38:41 +00:00
|
|
|
github.com/josharian/impl \
|
|
|
|
|
github.com/davidrjenni/reftools/cmd/fillstruct \
|
|
|
|
|
github.com/uudashr/gopkgs/v2/cmd/gopkgs \
|
|
|
|
|
github.com/ramya-rao-a/go-outline \
|
|
|
|
|
github.com/acroca/go-symbols \
|
|
|
|
|
github.com/godoctor/godoctor \
|
|
|
|
|
github.com/rogpeppe/godef \
|
|
|
|
|
github.com/zmb3/gogetdoc \
|
|
|
|
|
github.com/fatih/gomodifytags \
|
|
|
|
|
github.com/mgechev/revive \
|
|
|
|
|
github.com/go-delve/delve/cmd/dlv"
|
2020-07-29 19:57:06 +09:00
|
|
|
RUN mkdir -p /tmp/gotools \
|
|
|
|
|
&& cd /tmp/gotools \
|
|
|
|
|
&& export GOPATH=/tmp/gotools \
|
|
|
|
|
# Go tools w/module support
|
|
|
|
|
&& export GO111MODULE=on \
|
|
|
|
|
&& (echo "${GO_TOOLS_WITH_MODULES}" | xargs -n 1 go get -x )2>&1 \
|
|
|
|
|
# gocode-gomod
|
|
|
|
|
&& export GO111MODULE=auto \
|
|
|
|
|
&& go get -x -d github.com/stamblerre/gocode 2>&1 \
|
|
|
|
|
&& go build -o gocode-gomod github.com/stamblerre/gocode \
|
2020-07-25 01:38:41 +00:00
|
|
|
# golangci-lint
|
2020-07-29 19:57:06 +09:00
|
|
|
&& curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin 2>&1 \
|
|
|
|
|
# Move Go tools into path and clean up
|
|
|
|
|
&& mv /tmp/gotools/bin/* /usr/local/bin/ \
|
|
|
|
|
&& mv gocode-gomod /usr/local/bin/ \
|
|
|
|
|
&& rm -rf /tmp/gotools
|
|
|
|
|
|
|
|
|
|
ENV GO111MODULE=auto
|
|
|
|
|
|
2020-07-25 01:38:41 +00:00
|
|
|
# [Optional] Uncomment the next line to use go get to install anything else you need
|
|
|
|
|
# RUN go get -x <your-dependency-or-tool>
|
2020-07-29 19:57:06 +09:00
|
|
|
|
2020-07-25 01:38:41 +00:00
|
|
|
# [Optional] Uncomment this section to install additional OS packages.
|
|
|
|
|
# RUN apt-get update \
|
|
|
|
|
# && export DEBIAN_FRONTEND=noninteractive \
|
2020-07-29 19:57:06 +09:00
|
|
|
# && apt-get -y install --no-install-recommends <your-package-list-here>
|