Skip to content

Commit 224f2fc

Browse files
committed
Fix some minor bugs in update.sh and add windowsservercore variants for 1.5 and 1.7
1 parent f79bcf9 commit 224f2fc

File tree

4 files changed

+193
-17
lines changed

4 files changed

+193
-17
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
# see https://disqus.com/home/discussion/chocolatey/chocolatey_gallery_git_install_1710/#comment-2834659433 for why we don't use "/LOADINF=..." to let the installer set PATH
12+
RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
13+
(New-Object System.Net.WebClient).DownloadFile($env:GIT_DOWNLOAD_URL, 'git.exe'); \
14+
\
15+
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GIT_DOWNLOAD_SHA256); \
16+
if ((Get-FileHash git.exe -Algorithm sha256).Hash -ne $env:GIT_DOWNLOAD_SHA256) { \
17+
Write-Host 'FAILED!'; \
18+
exit 1; \
19+
}; \
20+
\
21+
Write-Host 'Installing ...'; \
22+
Start-Process \
23+
-Wait \
24+
-FilePath ./git.exe \
25+
# http://www.jrsoftware.org/ishelp/topic_setupcmdline.htm
26+
-ArgumentList @( \
27+
'/DIR=C:\git', \
28+
'/VERYSILENT', \
29+
'/NORESTART', \
30+
'/NOCANCEL', \
31+
'/SP-', \
32+
# https://github.com/git-for-windows/build-extra/blob/353f965e0e2af3e8c993930796975f9ce512c028/installer/install.iss#L87-L96
33+
'/COMPONENTS=assoc_sh', \
34+
'/SUPPRESSMSGBOXES' \
35+
); \
36+
\
37+
Write-Host 'Updating PATH ...'; \
38+
$env:PATH = 'C:\git\bin;C:\git\mingw\bin;C:\git\usr\bin;' + $env:PATH; \
39+
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
40+
\
41+
Write-Host 'Verifying install ...'; \
42+
Write-Host ' git --version'; git --version; \
43+
Write-Host ' bash --version'; bash --version; \
44+
Write-Host ' curl --version'; curl.exe --version; \
45+
\
46+
Write-Host 'Removing installer ...'; \
47+
Remove-Item git.exe -Force; \
48+
\
49+
Write-Host 'Complete.';
50+
51+
# 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
52+
ENV GOPATH C:\\gopath
53+
54+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
55+
RUN [Environment]::SetEnvironmentVariable('PATH', $env:GOPATH + '\bin;C:\go\bin;' + $env:PATH, [EnvironmentVariableTarget]::Machine);
56+
# doing this first to share cache across versions more aggressively
57+
58+
ENV GOLANG_VERSION 1.5.4
59+
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip
60+
ENV GOLANG_DOWNLOAD_SHA256 1201053d5659a5fc5c82dff58c3eaee66ecd02901621725cfdfff1681278bd1a
61+
62+
RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \
63+
(New-Object System.Net.WebClient).DownloadFile($env:GOLANG_DOWNLOAD_URL, 'go.zip'); \
64+
\
65+
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \
66+
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_SHA256) { \
67+
Write-Host 'FAILED!'; \
68+
exit 1; \
69+
}; \
70+
\
71+
Write-Host 'Expanding ...'; \
72+
Expand-Archive go.zip -DestinationPath C:\; \
73+
\
74+
Write-Host 'Verifying install ("go version") ...'; \
75+
go version; \
76+
\
77+
Write-Host 'Removing ...'; \
78+
Remove-Item go.zip -Force; \
79+
\
80+
Write-Host 'Complete.';
81+
82+
WORKDIR $GOPATH

1.6/windows/windowsservercore/Dockerfile

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,41 @@ ENV GIT_TAG v${GIT_VERSION}.windows.1
88
ENV GIT_DOWNLOAD_URL https://github.com/git-for-windows/git/releases/download/${GIT_TAG}/Git-${GIT_VERSION}-64-bit.exe
99
ENV GIT_DOWNLOAD_SHA256 006d971bcbe73cc8d841a100a4eb20d22e135142bf5b0f2120722fd420e166e5
1010
# steps inspired by "chcolateyInstall.ps1" from "git.install" (https://chocolatey.org/packages/git.install)
11+
# see https://disqus.com/home/discussion/chocolatey/chocolatey_gallery_git_install_1710/#comment-2834659433 for why we don't use "/LOADINF=..." to let the installer set PATH
1112
RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
1213
(New-Object System.Net.WebClient).DownloadFile($env:GIT_DOWNLOAD_URL, 'git.exe'); \
1314
\
1415
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GIT_DOWNLOAD_SHA256); \
1516
if ((Get-FileHash git.exe -Algorithm sha256).Hash -ne $env:GIT_DOWNLOAD_SHA256) { \
17+
Write-Host 'FAILED!'; \
1618
exit 1; \
1719
}; \
1820
\
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-
\
2921
Write-Host 'Installing ...'; \
3022
Start-Process \
3123
-Wait \
3224
-FilePath ./git.exe \
3325
# http://www.jrsoftware.org/ishelp/topic_setupcmdline.htm
3426
-ArgumentList @( \
27+
'/DIR=C:\git', \
3528
'/VERYSILENT', \
3629
'/NORESTART', \
3730
'/NOCANCEL', \
3831
'/SP-', \
32+
# https://github.com/git-for-windows/build-extra/blob/353f965e0e2af3e8c993930796975f9ce512c028/installer/install.iss#L87-L96
33+
'/COMPONENTS=assoc_sh', \
3934
'/SUPPRESSMSGBOXES' \
4035
); \
4136
\
37+
Write-Host 'Updating PATH ...'; \
38+
$env:PATH = 'C:\git\bin;C:\git\mingw\bin;C:\git\usr\bin;' + $env:PATH; \
39+
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
40+
\
41+
Write-Host 'Verifying install ...'; \
42+
Write-Host ' git --version'; git --version; \
43+
Write-Host ' bash --version'; bash --version; \
44+
Write-Host ' curl --version'; curl.exe --version; \
45+
\
4246
Write-Host 'Removing installer ...'; \
4347
Remove-Item git.exe -Force; \
4448
\
@@ -60,12 +64,16 @@ RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \
6064
\
6165
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \
6266
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_SHA256) { \
67+
Write-Host 'FAILED!'; \
6368
exit 1; \
6469
}; \
6570
\
6671
Write-Host 'Expanding ...'; \
6772
Expand-Archive go.zip -DestinationPath C:\; \
6873
\
74+
Write-Host 'Verifying install ("go version") ...'; \
75+
go version; \
76+
\
6977
Write-Host 'Removing ...'; \
7078
Remove-Item go.zip -Force; \
7179
\
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
# see https://disqus.com/home/discussion/chocolatey/chocolatey_gallery_git_install_1710/#comment-2834659433 for why we don't use "/LOADINF=..." to let the installer set PATH
12+
RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
13+
(New-Object System.Net.WebClient).DownloadFile($env:GIT_DOWNLOAD_URL, 'git.exe'); \
14+
\
15+
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GIT_DOWNLOAD_SHA256); \
16+
if ((Get-FileHash git.exe -Algorithm sha256).Hash -ne $env:GIT_DOWNLOAD_SHA256) { \
17+
Write-Host 'FAILED!'; \
18+
exit 1; \
19+
}; \
20+
\
21+
Write-Host 'Installing ...'; \
22+
Start-Process \
23+
-Wait \
24+
-FilePath ./git.exe \
25+
# http://www.jrsoftware.org/ishelp/topic_setupcmdline.htm
26+
-ArgumentList @( \
27+
'/DIR=C:\git', \
28+
'/VERYSILENT', \
29+
'/NORESTART', \
30+
'/NOCANCEL', \
31+
'/SP-', \
32+
# https://github.com/git-for-windows/build-extra/blob/353f965e0e2af3e8c993930796975f9ce512c028/installer/install.iss#L87-L96
33+
'/COMPONENTS=assoc_sh', \
34+
'/SUPPRESSMSGBOXES' \
35+
); \
36+
\
37+
Write-Host 'Updating PATH ...'; \
38+
$env:PATH = 'C:\git\bin;C:\git\mingw\bin;C:\git\usr\bin;' + $env:PATH; \
39+
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
40+
\
41+
Write-Host 'Verifying install ...'; \
42+
Write-Host ' git --version'; git --version; \
43+
Write-Host ' bash --version'; bash --version; \
44+
Write-Host ' curl --version'; curl.exe --version; \
45+
\
46+
Write-Host 'Removing installer ...'; \
47+
Remove-Item git.exe -Force; \
48+
\
49+
Write-Host 'Complete.';
50+
51+
# 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
52+
ENV GOPATH C:\\gopath
53+
54+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
55+
RUN [Environment]::SetEnvironmentVariable('PATH', $env:GOPATH + '\bin;C:\go\bin;' + $env:PATH, [EnvironmentVariableTarget]::Machine);
56+
# doing this first to share cache across versions more aggressively
57+
58+
ENV GOLANG_VERSION 1.7rc6
59+
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip
60+
ENV GOLANG_DOWNLOAD_SHA256 f043f7327049340e078ded4f9eed0b811f8cfa1adb7492403d3dea9cfebee13b
61+
62+
RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \
63+
(New-Object System.Net.WebClient).DownloadFile($env:GOLANG_DOWNLOAD_URL, 'go.zip'); \
64+
\
65+
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \
66+
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_SHA256) { \
67+
Write-Host 'FAILED!'; \
68+
exit 1; \
69+
}; \
70+
\
71+
Write-Host 'Expanding ...'; \
72+
Expand-Archive go.zip -DestinationPath C:\; \
73+
\
74+
Write-Host 'Verifying install ("go version") ...'; \
75+
go version; \
76+
\
77+
Write-Host 'Removing ...'; \
78+
Remove-Item go.zip -Force; \
79+
\
80+
Write-Host 'Complete.';
81+
82+
WORKDIR $GOPATH

update.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ for version in "${versions[@]}"; do
4040
[[ "$versionTag" == *.*[^0-9]* ]] || versionTag+='.0'
4141
(
4242
set -x
43-
sed -ri '
44-
s/^(ENV GOLANG_VERSION) .*/\1 '"$fullVersion"'/;
45-
s/^(ENV GOLANG_DOWNLOAD_SHA256) .*/\1 '"$linuxSha256"'/;
46-
s/^(ENV GOLANG_SRC_SHA256) .*/\1 '"$srcSha256"'/;
47-
s/^(FROM golang):.*/\1:'"$version"'/;
48-
' "$version/Dockerfile" "$version/"*"/Dockerfile"
43+
sed -ri \
44+
-e 's/^(ENV GOLANG_VERSION) .*/\1 '"$fullVersion"'/' \
45+
-e 's/^(ENV GOLANG_DOWNLOAD_SHA256) .*/\1 '"$linuxSha256"'/' \
46+
-e 's/^(ENV GOLANG_SRC_SHA256) .*/\1 '"$srcSha256"'/' \
47+
-e 's/^(FROM golang):.*/\1:'"$version"'/' \
48+
"$version/Dockerfile" \
49+
"$version/"*"/Dockerfile"
4950
cp go-wrapper "$version/"
5051
)
5152
for variant in alpine wheezy; do
@@ -64,7 +65,10 @@ for version in "${versions[@]}"; do
6465
if [ -d "$version/$variant" ]; then
6566
(
6667
set -x
67-
sed -ri 's/^(ENV GOLANG_DOWNLOAD_SHA256) .*/\1 '"$windowsSha256"'/' "$version/$variant/Dockerfile"
68+
sed -ri \
69+
-e 's/^(ENV GOLANG_VERSION) .*/\1 '"$fullVersion"'/' \
70+
-e 's/^(ENV GOLANG_DOWNLOAD_SHA256) .*/\1 '"$windowsSha256"'/' \
71+
"$version/$variant/Dockerfile"
6872
)
6973
fi
7074
done

0 commit comments

Comments
 (0)