Skip to content

Commit 272431a

Browse files
committed
For Go 1.17+, move the Windows install to C:\Program Files\Go
This matches Go upstream's change to the same, and allows GOPATH on 1.17+ to move to C:\go (although with the caveat that GOPATH may not actually be useful for much longer). See https://golang.org/cl/283600 for where this was changed in the official Go installer.
1 parent 7f1f587 commit 272431a

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

0 commit comments

Comments
 (0)