Skip to content

Commit

Permalink
Configure gopath to use non-root user
Browse files Browse the repository at this point in the history
Avoid issues with inconsistent user in devcontainer ci

see: devcontainers/ci#176
  • Loading branch information
lawrencegripper committed Feb 22, 2023
1 parent e0c244a commit 8eb7d97
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
8 changes: 5 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ RUN \
&& curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b $(go env GOPATH)/bin v${GOLANGCI_LINT_VERSION} \
# --> Go releaser
&& go install github.com/goreleaser/goreleaser@v${GO_RELEASER_VERSION} \
&& sudo rm -rf /go/src/ && sudo rm -rf /go/pkg/mod

RUN sudo mkdir /go/pkg/mod && sudo chown -R $USERNAME /go/pkg/mod
# --> Tidy up so container image isn't too large
&& sudo rm -rf /go/src/ && sudo rm -rf /go/pkg/mod/

# Avoid permissions issues when user UID is mapped see: https://github.com/devcontainers/ci/issues/176
ENV GOPATH="/home/$USERNAME/go"
10 changes: 1 addition & 9 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
"seccomp=unconfined",
"--privileged",
"--name", "azbdev",
// Keep command history
"-v", "azbrowse-bashhistory:/root/commandhistory",
// Mount docker socket for docker builds
"-v", "/var/run/docker.sock:/var/run/docker.sock",
// Use host network
Expand All @@ -36,8 +34,7 @@
"rebornix.ruby"
],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"go.gopath": "/go",
"go.gopath": "${env:GOPATH}/go",
"go.useLanguageServer": true,
"[go]": {
"editor.snippetSuggestions": "none",
Expand All @@ -56,11 +53,6 @@
},
}
},
// Uncomment the next line if you want to publish any ports.
// "appPort": [],
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "go version",
// Add the IDs of extensions you want installed when the container is created in the array below.
"postStartCommand": "bundler install",
"features": {
"ghcr.io/stuartleeks/dev-container-features/shell-history:0": {}
Expand Down
3 changes: 3 additions & 0 deletions scripts/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
ENV['GOVERSION'] = go_version

print_header('Configuration')
puts 'Whoami:'
execute_command('whoami')
puts "GOPATH: #{ENV['GOPATH']}"
puts "Is running in CI? #{@is_ci}"
puts "Branch: #{@branch}"
puts "Go version: #{go_version}"
Expand Down

0 comments on commit 8eb7d97

Please sign in to comment.