Skip to content

Commit be25599

Browse files
committed
Sync more closely with the non-Windows Dockerfile, update "update.sh" and "generate-stackbrew-library.sh"
1 parent 7cb6105 commit be25599

File tree

4 files changed

+95
-19
lines changed

4 files changed

+95
-19
lines changed

1.6/Dockerfile.windows

-15
This file was deleted.
+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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

generate-stackbrew-library.sh

+11-4
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,16 @@ for version in "${versions[@]}"; do
6868
Directory: $version
6969
EOE
7070

71-
for variant in onbuild cross wheezy alpine; do
72-
[ -f "$version/$variant/Dockerfile" ] || continue
71+
for v in \
72+
onbuild cross wheezy alpine \
73+
windows/windowsservercore windows/nanoserver \
74+
; do
75+
dir="$version/$v"
76+
variant="$(basename "$v")"
7377

74-
commit="$(dirCommit "$version/$variant")"
78+
[ -f "$dir/Dockerfile" ] || continue
79+
80+
commit="$(dirCommit "$dir")"
7581

7682
variantAliases=( "${versionAliases[@]/%/-$variant}" )
7783
variantAliases=( "${variantAliases[@]//latest-/}" )
@@ -80,7 +86,8 @@ for version in "${versions[@]}"; do
8086
cat <<-EOE
8187
Tags: $(join ', ' "${variantAliases[@]}")
8288
GitCommit: $commit
83-
Directory: $version/$variant
89+
Directory: $dir
8490
EOE
91+
[ "$variant" = "$v" ] || echo "Constraints: $variant"
8592
done
8693
done

update.sh

+10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ for version in "${versions[@]}"; do
3333
continue
3434
fi
3535

36+
windowsSha256="$(echo $googleSource | grep -Po '">go'"$fullVersion"'\.windows-amd64\.zip</a>.*?>[a-f0-9]{40,64}<' | sed -r 's!.*>([a-f0-9]{64})<.*!\1!; s!.*[<>]+.*!!' | tail -1)"
37+
3638
srcSha256="$(echo $googleSource | grep -Po '">go'"$fullVersion"'\.src\.tar\.gz</a>.*?>[a-f0-9]{40,64}<' | sed -r 's!.*>([a-f0-9]{64})<.*!\1!; s!.*[<>]+.*!!' | tail -1)"
3739

3840
[[ "$versionTag" == *.*[^0-9]* ]] || versionTag+='.0'
@@ -58,6 +60,14 @@ for version in "${versions[@]}"; do
5860
travisEnv='\n - VERSION='"$version VARIANT=$variant$travisEnv"
5961
fi
6062
done
63+
for variant in windows/windowsservercore windows/nanoserver; do
64+
if [ -d "$version/$variant" ]; then
65+
(
66+
set -x
67+
sed -ri 's/^(ENV GOLANG_DOWNLOAD_SHA256) .*/\1 '"$windowsSha256"'/' "$version/$variant/Dockerfile"
68+
)
69+
fi
70+
done
6171
travisEnv='\n - VERSION='"$version VARIANT=$travisEnv"
6272
done
6373

0 commit comments

Comments
 (0)