Skip to content

Commit 88b5e2b

Browse files
committed
Add newer Nano Server variants
1 parent fd3fd77 commit 88b5e2b

File tree

9 files changed

+148
-27
lines changed

9 files changed

+148
-27
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ script:
5151
# TODO make the tests run successfully on Windows too!
5252
docker run --rm "$image" go version
5353
docker run --rm "$image" git --version
54+
# if we've got nanoserver, let's build test that too
55+
nanoserverDir="../nanoserver-${VARIANT#windows/windowsservercore-}"
56+
if [ -f "$nanoserverDir/Dockerfile" ]; then
57+
nanoserverImage="${image//windowsservercore/nanoserver}"
58+
nanoserverFromWindows="$(awk -F '[ =]' '$1 == "COPY" && $2 == "--from" { print $3; exit }' "$nanoserverDir/Dockerfile")" # match "COPY --from=..." value
59+
docker tag "$image" "$nanoserverFromWindows"
60+
docker build -t "$nanoserverImage" "$nanoserverDir"
61+
docker run --rm "$nanoserverImage" go version
62+
fi
5463
else
5564
~/official-images/test/run.sh "$image"
5665
fi
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM mcr.microsoft.com/windows/nanoserver:1803
2+
3+
SHELL ["cmd", "/S", "/C"]
4+
5+
# no Git installed (intentionally)
6+
# -- Nano Server is "Windows Slim"
7+
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
9+
ENV GOPATH C:\\gopath
10+
11+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
12+
USER ContainerAdministrator
13+
RUN setx /m PATH "%GOPATH%\bin;C:\go\bin;%PATH%"
14+
USER ContainerUser
15+
# doing this first to share cache across versions more aggressively
16+
17+
ENV GOLANG_VERSION 1.11.12
18+
19+
COPY --from=golang:1.11.12-windowsservercore-1803 C:\\go C:\\go
20+
RUN go version
21+
22+
WORKDIR $GOPATH
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM mcr.microsoft.com/windows/nanoserver:1809
2+
3+
SHELL ["cmd", "/S", "/C"]
4+
5+
# no Git installed (intentionally)
6+
# -- Nano Server is "Windows Slim"
7+
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
9+
ENV GOPATH C:\\gopath
10+
11+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
12+
USER ContainerAdministrator
13+
RUN setx /m PATH "%GOPATH%\bin;C:\go\bin;%PATH%"
14+
USER ContainerUser
15+
# doing this first to share cache across versions more aggressively
16+
17+
ENV GOLANG_VERSION 1.11.12
18+
19+
COPY --from=golang:1.11.12-windowsservercore-1809 C:\\go C:\\go
20+
RUN go version
21+
22+
WORKDIR $GOPATH
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM mcr.microsoft.com/windows/nanoserver:1803
2+
3+
SHELL ["cmd", "/S", "/C"]
4+
5+
# no Git installed (intentionally)
6+
# -- Nano Server is "Windows Slim"
7+
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
9+
ENV GOPATH C:\\gopath
10+
11+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
12+
USER ContainerAdministrator
13+
RUN setx /m PATH "%GOPATH%\bin;C:\go\bin;%PATH%"
14+
USER ContainerUser
15+
# doing this first to share cache across versions more aggressively
16+
17+
ENV GOLANG_VERSION 1.12.7
18+
19+
COPY --from=golang:1.12.7-windowsservercore-1803 C:\\go C:\\go
20+
RUN go version
21+
22+
WORKDIR $GOPATH
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM mcr.microsoft.com/windows/nanoserver:1809
2+
3+
SHELL ["cmd", "/S", "/C"]
4+
5+
# no Git installed (intentionally)
6+
# -- Nano Server is "Windows Slim"
7+
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
9+
ENV GOPATH C:\\gopath
10+
11+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
12+
USER ContainerAdministrator
13+
RUN setx /m PATH "%GOPATH%\bin;C:\go\bin;%PATH%"
14+
USER ContainerUser
15+
# doing this first to share cache across versions more aggressively
16+
17+
ENV GOLANG_VERSION 1.12.7
18+
19+
COPY --from=golang:1.12.7-windowsservercore-1809 C:\\go C:\\go
20+
RUN go version
21+
22+
WORKDIR $GOPATH
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM mcr.microsoft.com/windows/nanoserver:1803
2+
3+
SHELL ["cmd", "/S", "/C"]
4+
5+
# no Git installed (intentionally)
6+
# -- Nano Server is "Windows Slim"
7+
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
9+
ENV GOPATH C:\\gopath
10+
11+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
12+
USER ContainerAdministrator
13+
RUN setx /m PATH "%GOPATH%\bin;C:\go\bin;%PATH%"
14+
USER ContainerUser
15+
# doing this first to share cache across versions more aggressively
16+
17+
ENV GOLANG_VERSION 1.13beta1
18+
19+
COPY --from=golang:1.13beta1-windowsservercore-1803 C:\\go C:\\go
20+
RUN go version
21+
22+
WORKDIR $GOPATH
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM mcr.microsoft.com/windows/nanoserver:1809
2+
3+
SHELL ["cmd", "/S", "/C"]
4+
5+
# no Git installed (intentionally)
6+
# -- Nano Server is "Windows Slim"
7+
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
9+
ENV GOPATH C:\\gopath
10+
11+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
12+
USER ContainerAdministrator
13+
RUN setx /m PATH "%GOPATH%\bin;C:\go\bin;%PATH%"
14+
USER ContainerUser
15+
# doing this first to share cache across versions more aggressively
16+
17+
ENV GOLANG_VERSION 1.13beta1
18+
19+
COPY --from=golang:1.13beta1-windowsservercore-1809 C:\\go C:\\go
20+
RUN go version
21+
22+
WORKDIR $GOPATH
Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
FROM mcr.microsoft.com/windows/nanoserver:%%MICROSOFT-TAG%%
22

3-
# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324
4-
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
3+
SHELL ["cmd", "/S", "/C"]
54

65
# no Git installed (intentionally)
76
# -- Nano Server is "Windows Slim"
@@ -10,34 +9,14 @@ SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPref
109
ENV GOPATH C:\\gopath
1110

1211
# PATH isn't actually set in the Docker image, so we have to set it from within the container
13-
RUN $newPath = ('{0}\bin;C:\go\bin;{1}' -f $env:GOPATH, $env:PATH); \
14-
Write-Host ('Updating PATH: {0}' -f $newPath); \
15-
# Nano Server does not have "[Environment]::SetEnvironmentVariable()"
16-
setx /M PATH $newPath;
12+
USER ContainerAdministrator
13+
RUN setx /m PATH "%GOPATH%\bin;C:\go\bin;%PATH%"
14+
USER ContainerUser
1715
# doing this first to share cache across versions more aggressively
1816

1917
ENV GOLANG_VERSION %%VERSION%%
2018

21-
RUN $url = ('https://golang.org/dl/go{0}.windows-amd64.zip' -f $env:GOLANG_VERSION); \
22-
Write-Host ('Downloading {0} ...' -f $url); \
23-
Invoke-WebRequest -Uri $url -OutFile 'go.zip'; \
24-
\
25-
$sha256 = '%%WIN-SHA256%%'; \
26-
Write-Host ('Verifying sha256 ({0}) ...' -f $sha256); \
27-
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $sha256) { \
28-
Write-Host 'FAILED!'; \
29-
exit 1; \
30-
}; \
31-
\
32-
Write-Host 'Expanding ...'; \
33-
Expand-Archive go.zip -DestinationPath C:\; \
34-
\
35-
Write-Host 'Verifying install ("go version") ...'; \
36-
go version; \
37-
\
38-
Write-Host 'Removing ...'; \
39-
Remove-Item go.zip -Force; \
40-
\
41-
Write-Host 'Complete.';
19+
COPY --from=golang:%%VERSION%%-windowsservercore-%%MICROSOFT-TAG%% C:\\go C:\\go
20+
RUN go version
4221

4322
WORKDIR $GOPATH

update.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ for version in "${versions[@]}"; do
117117
"Dockerfile-windows-${winVariant%%-*}.template" > "$version/windows/$winVariant/Dockerfile"
118118

119119
case "$winVariant" in
120+
nanoserver-*) ;; # nanoserver images COPY --from=...:...-windowsservercore-...
120121
*-1803) travisEnv='\n - os: windows\n dist: 1803-containers\n env: VERSION='"$version VARIANT=windows/$winVariant$travisEnv" ;;
121122
*-1809) ;; # no AppVeyor or Travis support for 1809: https://github.com/appveyor/ci/issues/1885 and https://github.com/appveyor/ci/issues/2676
122123
*) appveyorEnv='\n - version: '"$version"'\n variant: '"$winVariant$appveyorEnv" ;;

0 commit comments

Comments
 (0)