forked from docker-library/golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-windows-nanoserver.template
43 lines (36 loc) · 1.53 KB
/
Dockerfile-windows-nanoserver.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FROM mcr.microsoft.com/windows/{{ env.windowsVariant }}:{{ env.windowsRelease }}
SHELL ["cmd", "/S", "/C"]
# no Git installed (intentionally)
# -- Nano Server is "Windows Slim"
{{
def install_directory:
if [ "1.15", "1.16" ] | index(env.version) then
"C:\\go"
else
"C:\\Program Files\\Go"
end
-}}
{{ if install_directory == "C:\\go" then ( -}}
# 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
ENV GOPATH C:\\gopath
# (https://golang.org/cl/283600)
{{ ) else ( -}}
# 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)
ENV GOPATH C:\\go
# HOWEVER, please note that it is the Go upstream intention to remove GOPATH support entirely: https://blog.golang.org/go116-module-changes
{{ ) end -}}
# PATH isn't actually set in the Docker image, so we have to set it from within the container
USER ContainerAdministrator
RUN setx /m PATH "%GOPATH%\bin;{{ install_directory }}\bin;%PATH%"
USER ContainerUser
# doing this first to share cache across versions more aggressively
ENV GOLANG_VERSION {{ .version }}
# Docker's Windows path parsing is absolutely *cursed*; please just trust me on this one -Tianon
COPY --from=golang:{{ .version }}-windowsservercore-{{ env.windowsRelease }} {{
install_directory
| gsub("\\\\"; "\\\\")
| [ . , . ]
| @json
}}
RUN go version
WORKDIR $GOPATH