From 88b5e2b06f35a9bd7ae91dd3a534be8dcf9be8c7 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Thu, 8 Aug 2019 15:36:20 -0700 Subject: [PATCH] Add newer Nano Server variants --- .travis.yml | 9 ++++++ 1.11/windows/nanoserver-1803/Dockerfile | 22 +++++++++++++++ 1.11/windows/nanoserver-1809/Dockerfile | 22 +++++++++++++++ 1.12/windows/nanoserver-1803/Dockerfile | 22 +++++++++++++++ 1.12/windows/nanoserver-1809/Dockerfile | 22 +++++++++++++++ 1.13-rc/windows/nanoserver-1803/Dockerfile | 22 +++++++++++++++ 1.13-rc/windows/nanoserver-1809/Dockerfile | 22 +++++++++++++++ Dockerfile-windows-nanoserver.template | 33 ++++------------------ update.sh | 1 + 9 files changed, 148 insertions(+), 27 deletions(-) create mode 100644 1.11/windows/nanoserver-1803/Dockerfile create mode 100644 1.11/windows/nanoserver-1809/Dockerfile create mode 100644 1.12/windows/nanoserver-1803/Dockerfile create mode 100644 1.12/windows/nanoserver-1809/Dockerfile create mode 100644 1.13-rc/windows/nanoserver-1803/Dockerfile create mode 100644 1.13-rc/windows/nanoserver-1809/Dockerfile diff --git a/.travis.yml b/.travis.yml index bfaafb29..2573e103 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,6 +51,15 @@ script: # TODO make the tests run successfully on Windows too! docker run --rm "$image" go version docker run --rm "$image" git --version + # if we've got nanoserver, let's build test that too + nanoserverDir="../nanoserver-${VARIANT#windows/windowsservercore-}" + if [ -f "$nanoserverDir/Dockerfile" ]; then + nanoserverImage="${image//windowsservercore/nanoserver}" + nanoserverFromWindows="$(awk -F '[ =]' '$1 == "COPY" && $2 == "--from" { print $3; exit }' "$nanoserverDir/Dockerfile")" # match "COPY --from=..." value + docker tag "$image" "$nanoserverFromWindows" + docker build -t "$nanoserverImage" "$nanoserverDir" + docker run --rm "$nanoserverImage" go version + fi else ~/official-images/test/run.sh "$image" fi diff --git a/1.11/windows/nanoserver-1803/Dockerfile b/1.11/windows/nanoserver-1803/Dockerfile new file mode 100644 index 00000000..6e27667b --- /dev/null +++ b/1.11/windows/nanoserver-1803/Dockerfile @@ -0,0 +1,22 @@ +FROM mcr.microsoft.com/windows/nanoserver:1803 + +SHELL ["cmd", "/S", "/C"] + +# no Git installed (intentionally) +# -- Nano Server is "Windows Slim" + +# 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 +ENV GOPATH C:\\gopath + +# 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;C:\go\bin;%PATH%" +USER ContainerUser +# doing this first to share cache across versions more aggressively + +ENV GOLANG_VERSION 1.11.12 + +COPY --from=golang:1.11.12-windowsservercore-1803 C:\\go C:\\go +RUN go version + +WORKDIR $GOPATH diff --git a/1.11/windows/nanoserver-1809/Dockerfile b/1.11/windows/nanoserver-1809/Dockerfile new file mode 100644 index 00000000..43e2b9ae --- /dev/null +++ b/1.11/windows/nanoserver-1809/Dockerfile @@ -0,0 +1,22 @@ +FROM mcr.microsoft.com/windows/nanoserver:1809 + +SHELL ["cmd", "/S", "/C"] + +# no Git installed (intentionally) +# -- Nano Server is "Windows Slim" + +# 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 +ENV GOPATH C:\\gopath + +# 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;C:\go\bin;%PATH%" +USER ContainerUser +# doing this first to share cache across versions more aggressively + +ENV GOLANG_VERSION 1.11.12 + +COPY --from=golang:1.11.12-windowsservercore-1809 C:\\go C:\\go +RUN go version + +WORKDIR $GOPATH diff --git a/1.12/windows/nanoserver-1803/Dockerfile b/1.12/windows/nanoserver-1803/Dockerfile new file mode 100644 index 00000000..3662a2d7 --- /dev/null +++ b/1.12/windows/nanoserver-1803/Dockerfile @@ -0,0 +1,22 @@ +FROM mcr.microsoft.com/windows/nanoserver:1803 + +SHELL ["cmd", "/S", "/C"] + +# no Git installed (intentionally) +# -- Nano Server is "Windows Slim" + +# 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 +ENV GOPATH C:\\gopath + +# 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;C:\go\bin;%PATH%" +USER ContainerUser +# doing this first to share cache across versions more aggressively + +ENV GOLANG_VERSION 1.12.7 + +COPY --from=golang:1.12.7-windowsservercore-1803 C:\\go C:\\go +RUN go version + +WORKDIR $GOPATH diff --git a/1.12/windows/nanoserver-1809/Dockerfile b/1.12/windows/nanoserver-1809/Dockerfile new file mode 100644 index 00000000..86270d46 --- /dev/null +++ b/1.12/windows/nanoserver-1809/Dockerfile @@ -0,0 +1,22 @@ +FROM mcr.microsoft.com/windows/nanoserver:1809 + +SHELL ["cmd", "/S", "/C"] + +# no Git installed (intentionally) +# -- Nano Server is "Windows Slim" + +# 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 +ENV GOPATH C:\\gopath + +# 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;C:\go\bin;%PATH%" +USER ContainerUser +# doing this first to share cache across versions more aggressively + +ENV GOLANG_VERSION 1.12.7 + +COPY --from=golang:1.12.7-windowsservercore-1809 C:\\go C:\\go +RUN go version + +WORKDIR $GOPATH diff --git a/1.13-rc/windows/nanoserver-1803/Dockerfile b/1.13-rc/windows/nanoserver-1803/Dockerfile new file mode 100644 index 00000000..932ba42f --- /dev/null +++ b/1.13-rc/windows/nanoserver-1803/Dockerfile @@ -0,0 +1,22 @@ +FROM mcr.microsoft.com/windows/nanoserver:1803 + +SHELL ["cmd", "/S", "/C"] + +# no Git installed (intentionally) +# -- Nano Server is "Windows Slim" + +# 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 +ENV GOPATH C:\\gopath + +# 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;C:\go\bin;%PATH%" +USER ContainerUser +# doing this first to share cache across versions more aggressively + +ENV GOLANG_VERSION 1.13beta1 + +COPY --from=golang:1.13beta1-windowsservercore-1803 C:\\go C:\\go +RUN go version + +WORKDIR $GOPATH diff --git a/1.13-rc/windows/nanoserver-1809/Dockerfile b/1.13-rc/windows/nanoserver-1809/Dockerfile new file mode 100644 index 00000000..7027ddaf --- /dev/null +++ b/1.13-rc/windows/nanoserver-1809/Dockerfile @@ -0,0 +1,22 @@ +FROM mcr.microsoft.com/windows/nanoserver:1809 + +SHELL ["cmd", "/S", "/C"] + +# no Git installed (intentionally) +# -- Nano Server is "Windows Slim" + +# 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 +ENV GOPATH C:\\gopath + +# 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;C:\go\bin;%PATH%" +USER ContainerUser +# doing this first to share cache across versions more aggressively + +ENV GOLANG_VERSION 1.13beta1 + +COPY --from=golang:1.13beta1-windowsservercore-1809 C:\\go C:\\go +RUN go version + +WORKDIR $GOPATH diff --git a/Dockerfile-windows-nanoserver.template b/Dockerfile-windows-nanoserver.template index f0312db0..a0759c3c 100644 --- a/Dockerfile-windows-nanoserver.template +++ b/Dockerfile-windows-nanoserver.template @@ -1,7 +1,6 @@ FROM mcr.microsoft.com/windows/nanoserver:%%MICROSOFT-TAG%% -# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] +SHELL ["cmd", "/S", "/C"] # no Git installed (intentionally) # -- Nano Server is "Windows Slim" @@ -10,34 +9,14 @@ SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPref ENV GOPATH C:\\gopath # PATH isn't actually set in the Docker image, so we have to set it from within the container -RUN $newPath = ('{0}\bin;C:\go\bin;{1}' -f $env:GOPATH, $env:PATH); \ - Write-Host ('Updating PATH: {0}' -f $newPath); \ -# Nano Server does not have "[Environment]::SetEnvironmentVariable()" - setx /M PATH $newPath; +USER ContainerAdministrator +RUN setx /m PATH "%GOPATH%\bin;C:\go\bin;%PATH%" +USER ContainerUser # doing this first to share cache across versions more aggressively ENV GOLANG_VERSION %%VERSION%% -RUN $url = ('https://golang.org/dl/go{0}.windows-amd64.zip' -f $env:GOLANG_VERSION); \ - Write-Host ('Downloading {0} ...' -f $url); \ - Invoke-WebRequest -Uri $url -OutFile 'go.zip'; \ - \ - $sha256 = '%%WIN-SHA256%%'; \ - Write-Host ('Verifying sha256 ({0}) ...' -f $sha256); \ - if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $sha256) { \ - Write-Host 'FAILED!'; \ - exit 1; \ - }; \ - \ - Write-Host 'Expanding ...'; \ - Expand-Archive go.zip -DestinationPath C:\; \ - \ - Write-Host 'Verifying install ("go version") ...'; \ - go version; \ - \ - Write-Host 'Removing ...'; \ - Remove-Item go.zip -Force; \ - \ - Write-Host 'Complete.'; +COPY --from=golang:%%VERSION%%-windowsservercore-%%MICROSOFT-TAG%% C:\\go C:\\go +RUN go version WORKDIR $GOPATH diff --git a/update.sh b/update.sh index 9697d20c..a004e510 100755 --- a/update.sh +++ b/update.sh @@ -117,6 +117,7 @@ for version in "${versions[@]}"; do "Dockerfile-windows-${winVariant%%-*}.template" > "$version/windows/$winVariant/Dockerfile" case "$winVariant" in + nanoserver-*) ;; # nanoserver images COPY --from=...:...-windowsservercore-... *-1803) travisEnv='\n - os: windows\n dist: 1803-containers\n env: VERSION='"$version VARIANT=windows/$winVariant$travisEnv" ;; *-1809) ;; # no AppVeyor or Travis support for 1809: https://github.com/appveyor/ci/issues/1885 and https://github.com/appveyor/ci/issues/2676 *) appveyorEnv='\n - version: '"$version"'\n variant: '"$winVariant$appveyorEnv" ;;