Skip to content

Commit aa5a959

Browse files
authored
Merge pull request #116 from infosiftr/nanoserver
Add nanoserver variants
2 parents 53424ca + cba64e4 commit aa5a959

File tree

4 files changed

+94
-6
lines changed

4 files changed

+94
-6
lines changed

1.6/windows/nanoserver/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM microsoft/nanoserver
2+
3+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
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+
RUN $newPath = ('{0}\bin;C:\go\bin;{1}' -f $env:GOPATH, $env:PATH); \
13+
Write-Host ('Updating PATH: {0}' -f $newPath); \
14+
# Nano Server does not have "[Environment]::SetEnvironmentVariable()"
15+
setx /M PATH $newPath;
16+
# doing this first to share cache across versions more aggressively
17+
18+
ENV GOLANG_VERSION 1.6.3
19+
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip
20+
ENV GOLANG_DOWNLOAD_SHA256 6a18e5ed8b39785338986aecc6a3f36f5c4be286ff52db0ae3bcd2275ab70df0
21+
22+
RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \
23+
Invoke-WebRequest -Uri $env:GOLANG_DOWNLOAD_URL -OutFile 'go.zip'; \
24+
\
25+
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \
26+
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_SHA256) { \
27+
Write-Host 'FAILED!'; \
28+
exit 1; \
29+
}; \
30+
\
31+
Write-Host 'Expanding ...'; \
32+
Expand-Archive go.zip -DestinationPath C:\; \
33+
\
34+
Write-Host 'Verifying install ("go version") ...'; \
35+
go version; \
36+
\
37+
Write-Host 'Removing ...'; \
38+
Remove-Item go.zip -Force; \
39+
\
40+
Write-Host 'Complete.';
41+
42+
WORKDIR $GOPATH

1.6/windows/windowsservercore/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ENV GIT_DOWNLOAD_URL https://github.com/git-for-windows/git/releases/download/${
99
ENV GIT_DOWNLOAD_SHA256 006d971bcbe73cc8d841a100a4eb20d22e135142bf5b0f2120722fd420e166e5
1010
# steps inspired by "chcolateyInstall.ps1" from "git.install" (https://chocolatey.org/packages/git.install)
1111
RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
12-
(New-Object System.Net.WebClient).DownloadFile($env:GIT_DOWNLOAD_URL, 'git.exe'); \
12+
Invoke-WebRequest -Uri $env:GIT_DOWNLOAD_URL -OutFile 'git.exe'; \
1313
\
1414
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GIT_DOWNLOAD_SHA256); \
1515
if ((Get-FileHash git.exe -Algorithm sha256).Hash -ne $env:GIT_DOWNLOAD_SHA256) { \
@@ -55,15 +55,17 @@ RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
5555
ENV GOPATH C:\\gopath
5656

5757
# PATH isn't actually set in the Docker image, so we have to set it from within the container
58-
RUN [Environment]::SetEnvironmentVariable('PATH', $env:GOPATH + '\bin;C:\go\bin;' + $env:PATH, [EnvironmentVariableTarget]::Machine);
58+
RUN $newPath = ('{0}\bin;C:\go\bin;{1}' -f $env:GOPATH, $env:PATH); \
59+
Write-Host ('Updating PATH: {0}' -f $newPath); \
60+
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine);
5961
# doing this first to share cache across versions more aggressively
6062

6163
ENV GOLANG_VERSION 1.6.3
6264
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip
6365
ENV GOLANG_DOWNLOAD_SHA256 6a18e5ed8b39785338986aecc6a3f36f5c4be286ff52db0ae3bcd2275ab70df0
6466

6567
RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \
66-
(New-Object System.Net.WebClient).DownloadFile($env:GOLANG_DOWNLOAD_URL, 'go.zip'); \
68+
Invoke-WebRequest -Uri $env:GOLANG_DOWNLOAD_URL -OutFile 'go.zip'; \
6769
\
6870
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \
6971
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_SHA256) { \

1.7/windows/nanoserver/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM microsoft/nanoserver
2+
3+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
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+
RUN $newPath = ('{0}\bin;C:\go\bin;{1}' -f $env:GOPATH, $env:PATH); \
13+
Write-Host ('Updating PATH: {0}' -f $newPath); \
14+
# Nano Server does not have "[Environment]::SetEnvironmentVariable()"
15+
setx /M PATH $newPath;
16+
# doing this first to share cache across versions more aggressively
17+
18+
ENV GOLANG_VERSION 1.7.1
19+
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip
20+
ENV GOLANG_DOWNLOAD_SHA256 af2b836bb894672cf4c28df32a2ee3ff560e2b463e1ab44bb99833064ba09e5f
21+
22+
RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \
23+
Invoke-WebRequest -Uri $env:GOLANG_DOWNLOAD_URL -OutFile 'go.zip'; \
24+
\
25+
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \
26+
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_SHA256) { \
27+
Write-Host 'FAILED!'; \
28+
exit 1; \
29+
}; \
30+
\
31+
Write-Host 'Expanding ...'; \
32+
Expand-Archive go.zip -DestinationPath C:\; \
33+
\
34+
Write-Host 'Verifying install ("go version") ...'; \
35+
go version; \
36+
\
37+
Write-Host 'Removing ...'; \
38+
Remove-Item go.zip -Force; \
39+
\
40+
Write-Host 'Complete.';
41+
42+
WORKDIR $GOPATH

1.7/windows/windowsservercore/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ENV GIT_DOWNLOAD_URL https://github.com/git-for-windows/git/releases/download/${
99
ENV GIT_DOWNLOAD_SHA256 006d971bcbe73cc8d841a100a4eb20d22e135142bf5b0f2120722fd420e166e5
1010
# steps inspired by "chcolateyInstall.ps1" from "git.install" (https://chocolatey.org/packages/git.install)
1111
RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
12-
(New-Object System.Net.WebClient).DownloadFile($env:GIT_DOWNLOAD_URL, 'git.exe'); \
12+
Invoke-WebRequest -Uri $env:GIT_DOWNLOAD_URL -OutFile 'git.exe'; \
1313
\
1414
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GIT_DOWNLOAD_SHA256); \
1515
if ((Get-FileHash git.exe -Algorithm sha256).Hash -ne $env:GIT_DOWNLOAD_SHA256) { \
@@ -55,15 +55,17 @@ RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
5555
ENV GOPATH C:\\gopath
5656

5757
# PATH isn't actually set in the Docker image, so we have to set it from within the container
58-
RUN [Environment]::SetEnvironmentVariable('PATH', $env:GOPATH + '\bin;C:\go\bin;' + $env:PATH, [EnvironmentVariableTarget]::Machine);
58+
RUN $newPath = ('{0}\bin;C:\go\bin;{1}' -f $env:GOPATH, $env:PATH); \
59+
Write-Host ('Updating PATH: {0}' -f $newPath); \
60+
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine);
5961
# doing this first to share cache across versions more aggressively
6062

6163
ENV GOLANG_VERSION 1.7.1
6264
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip
6365
ENV GOLANG_DOWNLOAD_SHA256 af2b836bb894672cf4c28df32a2ee3ff560e2b463e1ab44bb99833064ba09e5f
6466

6567
RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \
66-
(New-Object System.Net.WebClient).DownloadFile($env:GOLANG_DOWNLOAD_URL, 'go.zip'); \
68+
Invoke-WebRequest -Uri $env:GOLANG_DOWNLOAD_URL -OutFile 'go.zip'; \
6769
\
6870
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \
6971
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_SHA256) { \

0 commit comments

Comments
 (0)