-
Notifications
You must be signed in to change notification settings - Fork 517
Add Windows Dockerfile #92
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM windowsservercore | ||
|
||
ENV GOLANG_VERSION 1.6.1 | ||
ENV GOLANG_DOWNLOAD_URL "https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't need this - just build the URL in the DownloadFile command. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's structured the same was as the Linux Dockerfiles: https://github.com/docker-library/golang/blob/master/1.6/Dockerfile#L11 |
||
ENV GOLANG_DOWNLOAD_SHA256 "1505afbcc5f71598c6ffd2a56ad550e4e8728c05649e9085f725e38d6b5a0fb8" | ||
|
||
RUN powershell -Command \ | ||
$ErrorActionPreference = 'Stop'; \ | ||
(New-Object System.Net.WebClient).DownloadFile('%GOLANG_DOWNLOAD_URL%', 'go.zip') ; \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have ErrorActionPreference to stop, to ensure it returns failure at any point in the sequence. Again see dockerfile.windows in docker/docker for an example. |
||
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $env:GOLANG_DOWNLOAD_SHA256) {exit 1} ; \ | ||
Expand-Archive go.zip -DestinationPath c:\\ ; \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The downloaded zip file should be checked as on Linux. I've added something in a node Docker image https://github.com/StefanScherer/dockerfiles-windows/blob/89f47847d082584c72741850119757414dda3625/node/5.10/Dockerfile#L10
|
||
Remove-Item go.zip -Force | ||
|
||
RUN setx /M PATH "C:\go\bin;%PATH%" && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can combine these into a single command to avoid an extra layer. See dockerfile.windows in docker/docker for an example. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The download-unzip and setx instructions? Again, this is structured like the linux image: https://github.com/docker-library/golang/blob/master/1.6/Dockerfile#L20 I don't think there's any harm in having this be separate layers since this sequencing doesn't cause bloat. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, but less layers are quicker.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How? It's the same number of bits over the wire (roughly), and it makes better use of caching because (for example) the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's miniscule but every msec counts. But realistically if you're worried about caching, surely the setx should go first? It's more likely the download will change, not the path... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jhowardmsft but that would be semantically incorrect. Someone building the image and wanting to debug the layer after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You honestly believe that's a realistic scenario though? I really don't. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here are some other reasons:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My $.02 - I truly don't buy that in something so simple. But your call as to what goes into any official images. Just giving my opinion 😄 |
||
setx /M GOPATH "C:\go" |
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.
As on Linux I would see some sort of "buildpack-deps:jessie-scm" base image to have git (and svn, bzr, ...) installed to make
go get
work.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 - Ignore the Linux binary bit. That's a client-only thing, not in containers or in 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.
@jhowardmsft that makes me kind of sad, and I hope there are plans to change that because being able to
docker run -it --rm ubuntu
on Windows sounds really magical and I want it to be a thing 😇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.
+1, but out of my hands.
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.
Maybe with a Hyper-V "Linux container":
docker run -it --rm --isolation=hyperv ubuntu
😄