Skip to content

Commit 04ba8bf

Browse files
authored
Merge pull request #108 from infosiftr/moar-windows
Fix some minor bugs in update.sh and add windowsservercore variants for 1.5 and 1.7
2 parents f79bcf9 + 8376071 commit 04ba8bf

File tree

4 files changed

+203
-18
lines changed

4 files changed

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

1.6/windows/windowsservercore/Dockerfile

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,10 @@ RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
1313
\
1414
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GIT_DOWNLOAD_SHA256); \
1515
if ((Get-FileHash git.exe -Algorithm sha256).Hash -ne $env:GIT_DOWNLOAD_SHA256) { \
16+
Write-Host 'FAILED!'; \
1617
exit 1; \
1718
}; \
1819
\
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-
\
2920
Write-Host 'Installing ...'; \
3021
Start-Process \
3122
-Wait \
@@ -36,9 +27,25 @@ RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
3627
'/NORESTART', \
3728
'/NOCANCEL', \
3829
'/SP-', \
39-
'/SUPPRESSMSGBOXES' \
30+
'/SUPPRESSMSGBOXES', \
31+
\
32+
# https://github.com/git-for-windows/build-extra/blob/353f965e0e2af3e8c993930796975f9ce512c028/installer/install.iss#L87-L96
33+
'/COMPONENTS=assoc_sh', \
34+
\
35+
# set "/DIR" so we can set "PATH" afterwards
36+
# 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
37+
'/DIR=C:\git' \
4038
); \
4139
\
40+
Write-Host 'Updating PATH ...'; \
41+
$env:PATH = 'C:\git\bin;C:\git\mingw64\bin;C:\git\usr\bin;' + $env:PATH; \
42+
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
43+
\
44+
Write-Host 'Verifying install ...'; \
45+
Write-Host ' git --version'; git --version; \
46+
Write-Host ' bash --version'; bash --version; \
47+
Write-Host ' curl --version'; curl.exe --version; \
48+
\
4249
Write-Host 'Removing installer ...'; \
4350
Remove-Item git.exe -Force; \
4451
\
@@ -60,12 +67,16 @@ RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \
6067
\
6168
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \
6269
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_SHA256) { \
70+
Write-Host 'FAILED!'; \
6371
exit 1; \
6472
}; \
6573
\
6674
Write-Host 'Expanding ...'; \
6775
Expand-Archive go.zip -DestinationPath C:\; \
6876
\
77+
Write-Host 'Verifying install ("go version") ...'; \
78+
go version; \
79+
\
6980
Write-Host 'Removing ...'; \
7081
Remove-Item go.zip -Force; \
7182
\
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+
Write-Host 'FAILED!'; \
17+
exit 1; \
18+
}; \
19+
\
20+
Write-Host 'Installing ...'; \
21+
Start-Process \
22+
-Wait \
23+
-FilePath ./git.exe \
24+
# http://www.jrsoftware.org/ishelp/topic_setupcmdline.htm
25+
-ArgumentList @( \
26+
'/VERYSILENT', \
27+
'/NORESTART', \
28+
'/NOCANCEL', \
29+
'/SP-', \
30+
'/SUPPRESSMSGBOXES', \
31+
\
32+
# https://github.com/git-for-windows/build-extra/blob/353f965e0e2af3e8c993930796975f9ce512c028/installer/install.iss#L87-L96
33+
'/COMPONENTS=assoc_sh', \
34+
\
35+
# set "/DIR" so we can set "PATH" afterwards
36+
# 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
37+
'/DIR=C:\git' \
38+
); \
39+
\
40+
Write-Host 'Updating PATH ...'; \
41+
$env:PATH = 'C:\git\bin;C:\git\mingw64\bin;C:\git\usr\bin;' + $env:PATH; \
42+
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
43+
\
44+
Write-Host 'Verifying install ...'; \
45+
Write-Host ' git --version'; git --version; \
46+
Write-Host ' bash --version'; bash --version; \
47+
Write-Host ' curl --version'; curl.exe --version; \
48+
\
49+
Write-Host 'Removing installer ...'; \
50+
Remove-Item git.exe -Force; \
51+
\
52+
Write-Host 'Complete.';
53+
54+
# 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
55+
ENV GOPATH C:\\gopath
56+
57+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
58+
RUN [Environment]::SetEnvironmentVariable('PATH', $env:GOPATH + '\bin;C:\go\bin;' + $env:PATH, [EnvironmentVariableTarget]::Machine);
59+
# doing this first to share cache across versions more aggressively
60+
61+
ENV GOLANG_VERSION 1.7rc6
62+
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip
63+
ENV GOLANG_DOWNLOAD_SHA256 f043f7327049340e078ded4f9eed0b811f8cfa1adb7492403d3dea9cfebee13b
64+
65+
RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \
66+
(New-Object System.Net.WebClient).DownloadFile($env:GOLANG_DOWNLOAD_URL, 'go.zip'); \
67+
\
68+
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \
69+
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_SHA256) { \
70+
Write-Host 'FAILED!'; \
71+
exit 1; \
72+
}; \
73+
\
74+
Write-Host 'Expanding ...'; \
75+
Expand-Archive go.zip -DestinationPath C:\; \
76+
\
77+
Write-Host 'Verifying install ("go version") ...'; \
78+
go version; \
79+
\
80+
Write-Host 'Removing ...'; \
81+
Remove-Item go.zip -Force; \
82+
\
83+
Write-Host 'Complete.';
84+
85+
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)