-
Notifications
You must be signed in to change notification settings - Fork 516
Add nanoserver variants #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
FROM microsoft/nanoserver | ||
|
||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] | ||
|
||
# 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 | ||
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; | ||
# doing this first to share cache across versions more aggressively | ||
|
||
ENV GOLANG_VERSION 1.6.3 | ||
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip | ||
ENV GOLANG_DOWNLOAD_SHA256 6a18e5ed8b39785338986aecc6a3f36f5c4be286ff52db0ae3bcd2275ab70df0 | ||
|
||
RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \ | ||
Invoke-WebRequest -Uri $env:GOLANG_DOWNLOAD_URL -OutFile 'go.zip'; \ | ||
\ | ||
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \ | ||
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_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.'; | ||
|
||
WORKDIR $GOPATH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
FROM microsoft/nanoserver | ||
|
||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] | ||
|
||
# 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 | ||
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; | ||
# doing this first to share cache across versions more aggressively | ||
|
||
ENV GOLANG_VERSION 1.7.1 | ||
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip | ||
ENV GOLANG_DOWNLOAD_SHA256 af2b836bb894672cf4c28df32a2ee3ff560e2b463e1ab44bb99833064ba09e5f | ||
|
||
RUN Write-Host ('Downloading {0} ...' -f $env:GOLANG_DOWNLOAD_URL); \ | ||
Invoke-WebRequest -Uri $env:GOLANG_DOWNLOAD_URL -OutFile 'go.zip'; \ | ||
\ | ||
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GOLANG_DOWNLOAD_SHA256); \ | ||
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_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.'; | ||
|
||
WORKDIR $GOPATH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invoke-WebRequest
supposedly buffers in memory, but it's the only option available in Nano Server. 😞There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look at the Docker PowerShell provider. They have added a
BitsOnNano.exe
https://www.powershellgallery.com/packages/DockerMsftProvider/1.0.0.1 (and open the FileList)
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The source for that is here: https://github.com/OneGet/MicrosoftDockerProvider/tree/developer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting!
I was really hoping to use the same .NET methods we use in Server Core (
New-Object System.Net.WebClient
) since they offer IMO the best balance of performance and usability (based on my research, not on real-world testing), but of the three main "download files" methods in PowerShell core,Invoke-WebRequest
was the only one available in stock Nano, so I was just having a bit of a sad moment.I haven't actually verified the claim that I've read on the internet somewhere that
Invoke-WebRequest
buffers in memory (but it's online!! it has to be true 😅), and IMO it's probably not worth the overhead of installing an unrelated module (even if we remove it afterwards) to avoid that. I think our build server can handle it even if this does buffer in-memory. 😄 ❤️There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tianon Invoke-WebRequest used to be slow, but I think it's ok now when used with
-UseBasicParsing
. I don't know about the buffering behavior though.MicrosoftDocs/Virtualization-Documentation#360 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I just realised that PowerShell is on GitHub, and found a similar issue PowerShell/PowerShell#2138
But does this impact running in a container without visible progress bar?
Yes, narrowed it down. Using something like
works fast!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I guess we should add
$ProgressPreference = 'SilentlyContinue';
to ourSHELL
line along with$StopActionPreference
given that the issue you linked to mentions other commands use$ProgressPreference
too likeExpand-Archive
, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ie PowerShell/PowerShell#2138 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I also thought adding it to
SHELL
. And yes this should help forExpand-Archive
as well. :-)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, after finding this out I started adding
SilentlyContinue
to pretty much every system I use :-)