Skip to content

Commit

Permalink
Dockerfile: use "go install" to install utilities
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Sep 2, 2021
1 parent a7a7c73 commit 14ff070
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
11 changes: 5 additions & 6 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -274,21 +274,20 @@ RUN `
C:\git\cmd\git config --global core.autocrlf true;

RUN `
Function Build-GoTestSum() { `
Write-Host "INFO: Building gotestsum version $Env:GOTESTSUM_VERSION in $Env:GOPATH"; `
Function Install-GoTestSum() { `
$Env:GO111MODULE = 'on'; `
$tmpGobin = "${Env:GOBIN_TMP}"; `
$Env:GOBIN = """${Env:GOPATH}`\bin"""; `
&go get -buildmode=exe "gotest.tools/gotestsum@${Env:GOTESTSUM_VERSION}"; `
Write-Host "INFO: Installing gotestsum version $Env:GOTESTSUM_VERSION in $Env:GOBIN"; `
&go install "gotest.tools/gotestsum@${Env:GOTESTSUM_VERSION}"; `
$Env:GOBIN = "${tmpGobin}"; `
$Env:GO111MODULE = 'off'; `
if ($LASTEXITCODE -ne 0) { `
Throw '"gotestsum build failed..."'; `
Throw '"gotestsum install failed..."'; `
} `
Write-Host "INFO: Build done for gotestsum..."; `
} `
`
Build-GoTestSum
Install-GoTestSum

# Make PowerShell the default entrypoint
ENTRYPOINT ["powershell.exe"]
Expand Down
4 changes: 2 additions & 2 deletions hack/dockerfile/install/golangci_lint.installer
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

install_golangci_lint() {
set -e
export GO111MODULE=on
GOBIN="${PREFIX}" go get "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}"
echo "Install golangci-lint version ${GOLANGCI_LINT_VERSION}"
GOBIN="${PREFIX}" GO111MODULE=on go install "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}"
"${PREFIX}"/golangci-lint --version
}
4 changes: 2 additions & 2 deletions hack/dockerfile/install/gotestsum.installer
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

install_gotestsum() (
set -e
export GO111MODULE=on
GOBIN="${PREFIX}" go get "gotest.tools/gotestsum@${GOTESTSUM_VERSION}"
echo "Install gotestsum version ${GOTESTSUM_VERSION}"
GOBIN="${PREFIX}" GO111MODULE=on go install "gotest.tools/gotestsum@${GOTESTSUM_VERSION}"
)
5 changes: 1 addition & 4 deletions hack/dockerfile/install/shfmt.installer
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@

install_shfmt() {
echo "Install shfmt version $SHFMT_VERSION"
git clone https://github.com/mvdan/sh.git "$GOPATH/src/github.com/mvdan/sh"
cd "$GOPATH/src/github.com/mvdan/sh" || exit 1
git checkout -q "$SHFMT_VERSION"
GO111MODULE=on go build ${GO_BUILDMODE} -v -o "${PREFIX}/shfmt" ./cmd/shfmt
GOBIN="${PREFIX}" GO111MODULE=on go install "mvdan.cc/sh/v3/cmd/shfmt@${SHFMT_VERSION}"
}
3 changes: 1 addition & 2 deletions hack/dockerfile/install/tomll.installer
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

install_tomll() {
echo "Install go-toml version ${GOTOML_VERSION}"
# TODO remove GO111MODULE=on and change to 'go install -mod=mod ...' once we're at go 1.16+
GO111MODULE=on GOBIN="${PREFIX}" go get -v "github.com/pelletier/go-toml/cmd/tomll@${GOTOML_VERSION}"
GOBIN="${PREFIX}" GO111MODULE=on go install "github.com/pelletier/go-toml/cmd/tomll@${GOTOML_VERSION}"
}
5 changes: 1 addition & 4 deletions hack/dockerfile/install/vndr.installer
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@

install_vndr() {
echo "Install vndr version $VNDR_VERSION"
git clone https://github.com/LK4D4/vndr.git "$GOPATH/src/github.com/LK4D4/vndr"
cd "$GOPATH/src/github.com/LK4D4/vndr" || exit 1
git checkout -q "$VNDR_VERSION"
go build ${GO_BUILDMODE} -v -o "${PREFIX}/vndr" .
GOBIN="${PREFIX}" GO111MODULE=on go install "github.com/LK4D4/vndr@${VNDR_VERSION}"
}

0 comments on commit 14ff070

Please sign in to comment.