|
| 1 | +FROM microsoft/nanoserver |
| 2 | + |
| 3 | +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] |
| 4 | + |
| 5 | +# ideally, this would be C:\go to match Linux a bit closer, but C:\go is the recommended install path for Go itself on Windows |
| 6 | +ENV GOPATH C:\\gopath |
| 7 | + |
| 8 | +# PATH isn't actually set in the Docker image, so we have to set it from within the container |
| 9 | +RUN Write-Host 'Updating PATH ...'; \ |
| 10 | + $regPath = 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment'; \ |
| 11 | + \ |
| 12 | + $oldPath = ( \ |
| 13 | + Get-ItemProperty \ |
| 14 | + -Path $regPath \ |
| 15 | + -Name PATH \ |
| 16 | + ).path; \ |
| 17 | + Write-Host (' Before: {0}' -f $oldPath); \ |
| 18 | + \ |
| 19 | + $newPath = $env:GOPATH + '\bin;C:\go\bin;' + $oldPath; \ |
| 20 | + Write-Host (' After: {0}' -f $newPath); \ |
| 21 | + \ |
| 22 | + Set-ItemProperty \ |
| 23 | + -Path $regPath \ |
| 24 | + -Name PATH \ |
| 25 | + -Value $newPath; \ |
| 26 | + Write-Host 'Complete.'; |
| 27 | +# doing this first to share cache across versions more aggressively |
| 28 | + |
| 29 | +ENV GOLANG_VERSION 1.6.3 |
| 30 | +ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip |
| 31 | +ENV GOLANG_DOWNLOAD_SHA256 6a18e5ed8b39785338986aecc6a3f36f5c4be286ff52db0ae3bcd2275ab70df0 |
| 32 | + |
| 33 | +RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \ |
| 34 | + Invoke-WebRequest -Uri $env:GOLANG_DOWNLOAD_URL -OutFile 'go.zip'; \ |
| 35 | + \ |
| 36 | + Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \ |
| 37 | + if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_SHA256) { \ |
| 38 | + Write-Host 'FAILED!'; \ |
| 39 | + exit 1; \ |
| 40 | + }; \ |
| 41 | + \ |
| 42 | + Write-Host 'Expanding ...'; \ |
| 43 | + Expand-Archive go.zip -DestinationPath C:\; \ |
| 44 | + \ |
| 45 | + Write-Host 'Verifying install ("go version") ...'; \ |
| 46 | + go version; \ |
| 47 | + \ |
| 48 | + Write-Host 'Removing ...'; \ |
| 49 | + Remove-Item go.zip -Force; \ |
| 50 | + \ |
| 51 | + Write-Host 'Complete.'; |
| 52 | + |
| 53 | +WORKDIR $GOPATH |
0 commit comments