|
| 1 | +FROM microsoft/windowsservercore |
| 2 | + |
| 3 | +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] |
| 4 | + |
| 5 | +# install Git (especially for "go get") |
| 6 | +ENV GIT_VERSION 2.9.2 |
| 7 | +ENV GIT_TAG v${GIT_VERSION}.windows.1 |
| 8 | +ENV GIT_DOWNLOAD_URL https://github.com/git-for-windows/git/releases/download/${GIT_TAG}/Git-${GIT_VERSION}-64-bit.exe |
| 9 | +ENV GIT_DOWNLOAD_SHA256 006d971bcbe73cc8d841a100a4eb20d22e135142bf5b0f2120722fd420e166e5 |
| 10 | +# steps inspired by "chcolateyInstall.ps1" from "git.install" (https://chocolatey.org/packages/git.install) |
| 11 | +RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \ |
| 12 | + (New-Object System.Net.WebClient).DownloadFile($env:GIT_DOWNLOAD_URL, 'git.exe'); \ |
| 13 | + \ |
| 14 | + Write-Host ('Verifying sha256 ({0}) ...' -f $env:GIT_DOWNLOAD_SHA256); \ |
| 15 | + if ((Get-FileHash git.exe -Algorithm sha256).Hash -ne $env:GIT_DOWNLOAD_SHA256) { \ |
| 16 | + exit 1; \ |
| 17 | + }; \ |
| 18 | + \ |
| 19 | + Write-Host 'Pre-configuring installer so it sets PATH ...'; \ |
| 20 | + New-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Git_is1' \ |
| 21 | + | Out-Null; \ |
| 22 | + New-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Git_is1' \ |
| 23 | + -Name 'Inno Setup CodeFile: Path Option' \ |
| 24 | + -Value 'CmdTools' \ |
| 25 | + -PropertyType 'String' \ |
| 26 | + -Force \ |
| 27 | + | Out-Null; \ |
| 28 | + \ |
| 29 | + Write-Host 'Installing ...'; \ |
| 30 | + Start-Process \ |
| 31 | + -Wait \ |
| 32 | + -FilePath ./git.exe \ |
| 33 | +# http://www.jrsoftware.org/ishelp/topic_setupcmdline.htm |
| 34 | + -ArgumentList @( \ |
| 35 | + '/VERYSILENT', \ |
| 36 | + '/NORESTART', \ |
| 37 | + '/NOCANCEL', \ |
| 38 | + '/SP-', \ |
| 39 | + '/SUPPRESSMSGBOXES' \ |
| 40 | + ); \ |
| 41 | + \ |
| 42 | + Write-Host 'Removing installer ...'; \ |
| 43 | + Remove-Item git.exe -Force; \ |
| 44 | + \ |
| 45 | + Write-Host 'Complete.'; |
| 46 | + |
| 47 | +# 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 |
| 48 | +ENV GOPATH C:\\gopath |
| 49 | + |
| 50 | +# PATH isn't actually set in the Docker image, so we have to set it from within the container |
| 51 | +RUN [Environment]::SetEnvironmentVariable('PATH', $env:GOPATH + '\bin;C:\go\bin;' + $env:PATH, [EnvironmentVariableTarget]::Machine); |
| 52 | +# doing this first to share cache across versions more aggressively |
| 53 | + |
| 54 | +ENV GOLANG_VERSION 1.6.3 |
| 55 | +ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip |
| 56 | +ENV GOLANG_DOWNLOAD_SHA256 6a18e5ed8b39785338986aecc6a3f36f5c4be286ff52db0ae3bcd2275ab70df0 |
| 57 | + |
| 58 | +RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \ |
| 59 | + (New-Object System.Net.WebClient).DownloadFile($env:GOLANG_DOWNLOAD_URL, 'go.zip'); \ |
| 60 | + \ |
| 61 | + Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \ |
| 62 | + if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_SHA256) { \ |
| 63 | + exit 1; \ |
| 64 | + }; \ |
| 65 | + \ |
| 66 | + Write-Host 'Expanding ...'; \ |
| 67 | + Expand-Archive go.zip -DestinationPath C:\; \ |
| 68 | + \ |
| 69 | + Write-Host 'Removing ...'; \ |
| 70 | + Remove-Item go.zip -Force; \ |
| 71 | + \ |
| 72 | + Write-Host 'Complete.'; |
| 73 | + |
| 74 | +WORKDIR $GOPATH |
0 commit comments