Move the creation of the user to before we perform the 'go get'. This way files under the gopath (specifically go modules cache) are writable by the vscode user (which is necessary for go modules to work).
This commit is contained in:
@@ -20,8 +20,23 @@ RUN apt-get update \
|
|||||||
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
|
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
|
||||||
&& apt-get -y install git procps lsb-release \
|
&& apt-get -y install git procps lsb-release \
|
||||||
#
|
#
|
||||||
|
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
|
||||||
|
&& groupadd --gid $USER_GID $USERNAME \
|
||||||
|
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
|
||||||
|
# [Optional] Add sudo support
|
||||||
|
&& apt-get install -y sudo \
|
||||||
|
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
|
||||||
|
&& chmod 0440 /etc/sudoers.d/$USERNAME \
|
||||||
|
#
|
||||||
|
# Clean up
|
||||||
|
&& apt-get autoremove -y \
|
||||||
|
&& apt-get clean -y \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
USER $USERNAME
|
||||||
|
|
||||||
# Install gocode-gomod
|
# Install gocode-gomod
|
||||||
&& go get -x -d github.com/stamblerre/gocode 2>&1 \
|
RUN go get -x -d github.com/stamblerre/gocode 2>&1 \
|
||||||
&& go build -o gocode-gomod github.com/stamblerre/gocode \
|
&& go build -o gocode-gomod github.com/stamblerre/gocode \
|
||||||
&& mv gocode-gomod $GOPATH/bin/ \
|
&& mv gocode-gomod $GOPATH/bin/ \
|
||||||
#
|
#
|
||||||
@@ -49,17 +64,4 @@ RUN apt-get update \
|
|||||||
honnef.co/go/tools/... \
|
honnef.co/go/tools/... \
|
||||||
github.com/golangci/golangci-lint/cmd/golangci-lint \
|
github.com/golangci/golangci-lint/cmd/golangci-lint \
|
||||||
github.com/mgechev/revive \
|
github.com/mgechev/revive \
|
||||||
github.com/derekparker/delve/cmd/dlv 2>&1 \
|
github.com/derekparker/delve/cmd/dlv 2>&1
|
||||||
#
|
|
||||||
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
|
|
||||||
&& groupadd --gid $USER_GID $USERNAME \
|
|
||||||
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
|
|
||||||
# [Optional] Add sudo support
|
|
||||||
&& apt-get install -y sudo \
|
|
||||||
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
|
|
||||||
&& chmod 0440 /etc/sudoers.d/$USERNAME \
|
|
||||||
#
|
|
||||||
# Clean up
|
|
||||||
&& apt-get autoremove -y \
|
|
||||||
&& apt-get clean -y \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|||||||
Reference in New Issue
Block a user