Skip to content

Commit 91fcb9a

Browse files
authored
Merge pull request #377 from infosiftr/go-1.17-windows
For Go 1.17+, move the Windows install to C:\Program Files\Go
2 parents 7f1f587 + 272431a commit 91fcb9a

File tree

12 files changed

+83
-24
lines changed

12 files changed

+83
-24
lines changed

1.15/windows/nanoserver-1809/Dockerfile

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.15/windows/windowsservercore-1809/Dockerfile

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.15/windows/windowsservercore-ltsc2016/Dockerfile

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.16/windows/nanoserver-1809/Dockerfile

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.16/windows/windowsservercore-1809/Dockerfile

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.16/windows/windowsservercore-ltsc2016/Dockerfile

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.17-rc/windows/nanoserver-1809/Dockerfile

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.17-rc/windows/windowsservercore-1809/Dockerfile

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.17-rc/windows/windowsservercore-ltsc2016/Dockerfile

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile-windows-nanoserver.template

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,39 @@ SHELL ["cmd", "/S", "/C"]
55
# no Git installed (intentionally)
66
# -- Nano Server is "Windows Slim"
77

8-
# 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
8+
{{
9+
def install_directory:
10+
if [ "1.15", "1.16" ] | index(env.version) then
11+
"C:\\go"
12+
else
13+
"C:\\Program Files\\Go"
14+
end
15+
-}}
16+
{{ if install_directory == "C:\\go" then ( -}}
17+
# ideally, this would be C:\go to match Linux a bit closer, but C:\go was the default install path for Go itself on Windows
918
ENV GOPATH C:\\gopath
19+
# (https://golang.org/cl/283600)
20+
{{ ) else ( -}}
21+
# for 1.17+, we'll follow the (new) Go upstream default for install (https://golang.org/cl/283600), which frees up C:\go to be the default GOPATH and thus match the Linux images more closely (https://github.com/docker-library/golang/issues/288)
22+
ENV GOPATH C:\\go
23+
# HOWEVER, please note that it is the Go upstream intention to remove GOPATH support entirely: https://blog.golang.org/go116-module-changes
24+
{{ ) end -}}
1025

1126
# PATH isn't actually set in the Docker image, so we have to set it from within the container
1227
USER ContainerAdministrator
13-
RUN setx /m PATH "%GOPATH%\bin;C:\go\bin;%PATH%"
28+
RUN setx /m PATH "%GOPATH%\bin;{{ install_directory }}\bin;%PATH%"
1429
USER ContainerUser
1530
# doing this first to share cache across versions more aggressively
1631

1732
ENV GOLANG_VERSION {{ .version }}
1833

19-
COPY --from=golang:{{ .version }}-windowsservercore-{{ env.windowsRelease }} C:\\go C:\\go
34+
# Docker's Windows path parsing is absolutely *cursed*; please just trust me on this one -Tianon
35+
COPY --from=golang:{{ .version }}-windowsservercore-{{ env.windowsRelease }} {{
36+
install_directory
37+
| gsub("\\\\"; "\\\\")
38+
| [ . , . ]
39+
| @json
40+
}}
2041
RUN go version
2142

2243
WORKDIR $GOPATH

Dockerfile-windows-servercore.template

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,26 @@ RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
3737
\
3838
Write-Host 'Complete.';
3939

40-
# 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
40+
{{
41+
def install_directory:
42+
if [ "1.15", "1.16" ] | index(env.version) then
43+
"C:\\go"
44+
else
45+
"C:\\Program Files\\Go"
46+
end
47+
-}}
48+
{{ if install_directory == "C:\\go" then ( -}}
49+
# ideally, this would be C:\go to match Linux a bit closer, but C:\go was the default install path for Go itself on Windows
4150
ENV GOPATH C:\\gopath
51+
# (https://golang.org/cl/283600)
52+
{{ ) else ( -}}
53+
# for 1.17+, we'll follow the (new) Go upstream default for install (https://golang.org/cl/283600), which frees up C:\go to be the default GOPATH and thus match the Linux images more closely (https://github.com/docker-library/golang/issues/288)
54+
ENV GOPATH C:\\go
55+
# HOWEVER, please note that it is the Go upstream intention to remove GOPATH support entirely: https://blog.golang.org/go116-module-changes
56+
{{ ) end -}}
4257

4358
# PATH isn't actually set in the Docker image, so we have to set it from within the container
44-
RUN $newPath = ('{0}\bin;C:\go\bin;{1}' -f $env:GOPATH, $env:PATH); \
59+
RUN $newPath = ('{0}\bin;{{ install_directory }}\bin;{1}' -f $env:GOPATH, $env:PATH); \
4560
Write-Host ('Updating PATH: {0}' -f $newPath); \
4661
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine);
4762
# doing this first to share cache across versions more aggressively
@@ -61,6 +76,11 @@ RUN $url = '{{ .arches["windows-amd64"].url }}'; \
6176
\
6277
Write-Host 'Expanding ...'; \
6378
Expand-Archive go.zip -DestinationPath C:\; \
79+
{{ if install_directory != "C:\\go" then ( -}}
80+
\
81+
Write-Host 'Moving ...'; \
82+
Move-Item -Path C:\go -Destination '{{ install_directory }}'; \
83+
{{ ) else "" end -}}
6484
\
6585
Write-Host 'Removing ...'; \
6686
Remove-Item go.zip -Force; \

apply-templates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jqt='.jq-template.awk'
77
if [ -n "${BASHBREW_SCRIPTS:-}" ]; then
88
jqt="$BASHBREW_SCRIPTS/jq-template.awk"
99
elif [ "$BASH_SOURCE" -nt "$jqt" ]; then
10-
wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/5f0c26381fb7cc78b2d217d58007800bdcfbcfa1/scripts/jq-template.awk'
10+
wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/1da7341a79651d28fbcc3d14b9176593c4231942/scripts/jq-template.awk'
1111
fi
1212

1313
if [ "$#" -eq 0 ]; then

0 commit comments

Comments
 (0)