|
| 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 | +# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser" |
| 9 | +# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs |
| 10 | +# will be updated to match your local UID/GID (when using the dockerFile property). |
| 11 | +# See https://aka.ms/vscode-remote/containers/non-root-user for details. |
| 12 | +ARG USERNAME=vscode |
| 13 | +ARG USER_UID=1000 |
| 14 | +ARG USER_GID=$USER_UID |
| 15 | + |
| 16 | +# Configure apt, install packages and tools |
| 17 | +# hadolint ignore=DL3003,DL3008 |
| 18 | +RUN apt-get update \ |
| 19 | + && export DEBIAN_FRONTEND=noninteractive \ |
| 20 | + && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ |
| 21 | + # |
| 22 | + # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed |
| 23 | + && apt-get -y install --no-install-recommends git openssh-client less iproute2 procps lsb-release \ |
| 24 | + # |
| 25 | + # Build Go tools w/module support |
| 26 | + && mkdir -p /tmp/gotools \ |
| 27 | + && cd /tmp/gotools \ |
| 28 | + && GOPATH=/tmp/gotools GO111MODULE=on go get -v golang.org/x/tools/gopls@latest 2>&1 \ |
| 29 | + && GOPATH=/tmp/gotools GO111MODULE=on go get -v \ |
| 30 | + github.com/mdempsky/gocode@latest \ |
| 31 | + github.com/sqs/goreturns@latest \ |
| 32 | + # gopkgs is still needed even with gopls: https://github.com/microsoft/vscode-go/issues/3050#issuecomment-592263369 |
| 33 | + github.com/uudashr/gopkgs/v2/cmd/gopkgs@latest \ |
| 34 | + github.com/ramya-rao-a/go-outline@latest \ |
| 35 | + github.com/acroca/go-symbols@latest \ |
| 36 | + github.com/rogpeppe/godef@latest \ |
| 37 | + github.com/fatih/gomodifytags@latest \ |
| 38 | + github.com/go-delve/delve/cmd/dlv@latest 2>&1 \ |
| 39 | + github.com/golangci/golangci-lint/cmd/ [email protected] \ |
| 40 | + # |
| 41 | + # Build gocode-gomod |
| 42 | + && GOPATH=/tmp/gotools go get -x -d github.com/stamblerre/gocode 2>&1 \ |
| 43 | + && GOPATH=/tmp/gotools go build -o gocode-gomod github.com/stamblerre/gocode \ |
| 44 | + # |
| 45 | + # Install Go tools |
| 46 | + && mv /tmp/gotools/bin/* /usr/local/bin/ \ |
| 47 | + && mv gocode-gomod /usr/local/bin/ \ |
| 48 | + # |
| 49 | + # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. |
| 50 | + && groupadd --gid $USER_GID $USERNAME \ |
| 51 | + && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ |
| 52 | + # [Optional] Add sudo support |
| 53 | + && apt-get install -y --no-install-recommends sudo \ |
| 54 | + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ |
| 55 | + && chmod 0440 /etc/sudoers.d/$USERNAME \ |
| 56 | + # |
| 57 | + # Clean up |
| 58 | + && apt-get autoremove -y \ |
| 59 | + && apt-get clean -y \ |
| 60 | + && rm -rf /var/lib/apt/lists/* /tmp/gotools |
| 61 | + |
| 62 | +# Update this to "on" or "off" as appropriate |
| 63 | +# Updated from "auto" to "on" as we are using Go modules for this project |
| 64 | +# See https://dev.to/maelvls/why-is-go111module-everywhere-and-everything-about-go-modules-24k |
| 65 | +ENV GO111MODULE=on |
0 commit comments