Skip to content
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

Proposal: Introduce Dockerfiles for windowsservercore #222

Conversation

StefanScherer
Copy link

@StefanScherer StefanScherer commented Aug 25, 2016

After golang now has its first Windows Docker image on Docker Hub it is time for node to provide an official Windows Docker image as well.

This PR is a proposal to build and push Windows Docker images for the windowsservercore variant which works on Windows 10 + Docker 4 Windows Beta 31++ or Windows Server 2016.

The test-build.ps1 can be called to build the images. It downloads the ZIP files for Node.js 4.7.0, 6.9.2 and 7.2.1 and builds these Docker images:

  • node:4.7.0-windowsservercore
  • node:4.7.0-windowsservercore-onbuild
  • node:6.9.2-windowsservercore
  • node:6.9.2-windowsservercore-onbuild
  • node:7.2.1-windowsservercore
  • node:7.2.1-windowsservercore-onbuild

In my previous work building a Windows Docker image I used the MSI packages which can be found here https://github.com/StefanScherer/dockerfiles-windows/tree/master/node, but this results in a slightly bigger Docker image as Windows caches the MSI packages in a second place even after removing it in the Dockerfile. So I switched to the ZIP files.

The labels for the Docker images are based on the work for the golang Docker images.

See also:

For information about how to get Docker running on Windows, please see the relevant Windows Server Quick Start guide provided by Microsoft.

See also #223 for the nanoserver Dockerfile proposal.

@Starefossen
Copy link
Member

This is great! 😄

Now we just need a CI capable of running Docker for Windows so we can make sure things don't break!

ENV NODE_VERSION 4.5.0
ENV NODE_SHA256 16aab15b29e79746d1bae708f6a5dbed8ef3c87426a9408f7261163d0cda0f56

RUN powershell -Command \

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@Starefossen
Copy link
Member

@tianon can Docker Hub build Docker Images for Windows?

@StefanScherer
Copy link
Author

@Starefossen not yet, also AppVeyor waits for Windows Server 2016 GA.

@StefanScherer
Copy link
Author

I'm more concerned if we need more dev dependencies to make it usable for the community.

Maybe we should add Python and probanly https://github.com/felixrieseberg/windows-build-tools to allow compiling native node modules as well.

The golang image without git was also not really usable.

@StefanScherer
Copy link
Author

I just tested the 6.5.0 Dockerfile with another line without any further optimizations

RUN npm install --global --production windows-build-tools

but then the Docker image increases from 7.9 GB to 11.5 GB:

C:\Users\vagrant\dockerfiles-windows\node [master ≡ +0 ~1 -0 !]> docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
stefanscherer/node-windows    6.5.0-full          d564a1d10cab        55 seconds ago      11.47 GB
stefanscherer/node-windows    6.5.0               558a2232ccf5        5 days ago          7.887 GB

I personally don't have the use case of compiling native node modules and build a Docker image with that for distribution. My workflow would look like this: Run npm install --production in AppVeyor in their full installed build images and then COPY deploy own code + node_modules into a Docker image (once they have a Docker build image).

@friism
Copy link

friism commented Sep 23, 2016

@StefanScherer
Copy link
Author

@friism I've tried several times to adapt the Dockerfile to PowerShell without the CMD variable names, but it seems that there is a strange problem using quotes for strings.
As this Dockerfile has the ErrorActionPreference it should be good enough for now.

FROM microsoft/windowsservercore
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
ENV NODE_VERSION 4.6.0

RUN Write-Host "https://nodejs.org/dist/v$($env:NODE_VERSION)/node-v$($env:NODE_VERSION)-win-x64.zip"
RUN $url = "https://nodejs.org/dist/v$($env:NODE_VERSION)/node-v$($env:NODE_VERSION)-win-x64.zip"
RUN (New-Object System.Net.WebClient).DownloadFile("https://nodejs.org/dist/v$($env:NODE_VERSION)/node-v$($env:NODE_VERSION)-win-x64.zip", 'node.zip')

shows the correct string after the Write-Host, but saving that string as a variable or use it in the DownloadFile function does not work:

Step 6/10 : RUN Write-Host "https://nodejs.org/dist/v$($env:NODE_VERSION)/node-v$($env:NODE_VERSION)-win-x64.zip"
 ---> Running in 96040c5827a5
https://nodejs.org/dist/v4.6.0/node-v4.6.0-win-x64.zip
 ---> 092e42203a2f
Removing intermediate container 96040c5827a5
Step 7/10 : RUN $url = "https://nodejs.org/dist/v$($env:NODE_VERSION)/node-v$($env:NODE_VERSION)-win-x64.zip"
 ---> Running in 68bcfb0f2eba
https://nodejs.org/dist/v$($env:NODE_VERSION)/node-v$($env:NODE_VERSION)-win-x6
4.zip : The term 'https://nodejs.org/dist/v$($env:NODE_VERSION)/node-v$($env:NO
DE_VERSION)-win-x64.zip' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:41
+ ... op'; $url = https://nodejs.org/dist/v$($env:NODE_VERSION)/node-v$($en ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (https://nodejs....ON)-win-x64.z
   ip:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : CommandNotFoundException

So I keep it as it is right now.

@tianon
Copy link
Contributor

tianon commented Sep 28, 2016

@StefanScherer in my own testing with PowerShell's string interpolation, it had odd edge cases that made it more trouble than it was worth; I found either ('string' + $var + 'string') or ('Format {0} string {1}' -f $var1, $var2) to be much more reliable

@StefanScherer StefanScherer force-pushed the introduce-windows-dockerfiles branch from 224a0ea to d044e93 Compare September 29, 2016 06:55
@StefanScherer
Copy link
Author

@tianon Thanks. I've added similar workarounds to introduce the SHELL instruction. PR rebased and squashed to use latest Node.js versions 4.6 and 6.7.

@StefanScherer StefanScherer force-pushed the introduce-windows-dockerfiles branch from d044e93 to 05a82ed Compare September 29, 2016 07:23
@chorrell chorrell mentioned this pull request Sep 29, 2016
chorrell

This comment was marked as off-topic.

@friism
Copy link

friism commented Sep 29, 2016

@chorrell note that there may also (likely) be a nanoserver variant alongside windowsservercore.

@StefanScherer
Copy link
Author

@chorrell Thanks for #239. Tried something similar today morning, but you know your test scripts better than I.
Your comment about removing the windows directory, is it still valid if #223 gets merged in the future to support nanoserver + windowsservercore?
If yes, I'll rebase both PR's, no problem.

@chorrell
Copy link
Contributor

At the time I thought it might make things simpler to omit the windows directory, but I wasn't considering tags and looking at docker-library/golang#106 it makes more sense. So yeah, leave it as is withwindows/nanoserver and windows/windowsservercore.

We'll want to probably modify the update.sh script and add new *.template files for the nanoserver and windowsservercore images at some point. I might also need to do more updates to test-build.sh too, but I'll merge #239 first.

@StefanScherer StefanScherer force-pushed the introduce-windows-dockerfiles branch from 05a82ed to ea2dabf Compare September 29, 2016 22:02
@StefanScherer
Copy link
Author

Anything I can do to push this forward a little bit?

@chorrell chorrell dismissed their stale review November 3, 2016 18:56

misunderstanding, I wasn't thinking about tags

@chorrell
Copy link
Contributor

chorrell commented Nov 3, 2016

Was there still an open question about doing CI? I don't have any experience running Docker in Windows and I don't really have a handle on how to test this or what we'd use for automated CI.

@StefanScherer
Copy link
Author

Something like .travis.yml + test_build.sh for Windows?
This should be possible on AppVeyor soon: appveyor.yml + test_build.ps1

But I think there is more CI to push to Docker Hub as well, right? Jenkins? So you would need eg. a Windows 2016 Jenkins slave for further steps.

@chorrell
Copy link
Contributor

chorrell commented Nov 3, 2016

The push to docker hub is all manual via a PR e.g., docker-library/official-images#2281

AppVeyor sounds like it might be an option for validating the images then?

@StefanScherer
Copy link
Author

Yes, they plan to setup Win2016 + nanoserver build agents with preloaded base images microsoft/windowsservercore + microsoft/nanoserver.

@chorrell
Copy link
Contributor

chorrell commented Nov 3, 2016

Also, I think a few remaining tasks are:

  • Update the Dockerfiles with the latest Node.js versions (v4.6.1, v7.0.0, etc)
  • Create .template files for the windowsservercore Dockerfiles
  • Update the update.sh script for updating the Dockerfiles or create a new script just for updating the Windows images.

@chorrell
Copy link
Contributor

chorrell commented Nov 3, 2016

OK, so we probably want to wait until AppVeyor has Windows server 2016. Afaik, the build group doesn't have any 2016 machines in the jenkins/ci setup: https://ci.nodejs.org/computer/

@StefanScherer
Copy link
Author

For example Azure has prebuilt Win2016+Containers including Docker engine preinstalled, there is also an up-to-date "Deploy to Azure" template here.
So this should be easy to extend new Jenkins slaves.

I can have a look at the update.sh

@chorrell
Copy link
Contributor

chorrell commented Nov 3, 2016

OK, that would be up to the @nodejs/build group to setup I guess.

@StefanScherer
Copy link
Author

The update.sh could be enhanced like the one for docker-library/mongo/update.sh fetching the sha256 sums for the Windows Dockerfiles.

@StefanScherer StefanScherer force-pushed the introduce-windows-dockerfiles branch 4 times, most recently from 244e21e to 5e7fd92 Compare December 7, 2016 10:26
@StefanScherer
Copy link
Author

Updated to Node 4.7.0, 6.9.2 and 7.2.1 :-)

@computeronix
Copy link

FYI streamlined the windows side with the msi (of course wouldn't work with nano though)

#297

@computeronix
Copy link

Python has a splitter between Windows and Linux so could be possible to easily implement with the proper tags and automated building mechanism as discussed above
https://store.docker.com/images/1ae86987-df14-4741-9433-d9602a4da995?tab=description

The ones provided by @StefanScherer and myself both are natively supported within Windows Server 2016 Server (and even Azure Server 2016 /w containers ;) )

@StefanScherer
Copy link
Author

FYI, if setting up a Win2016+Docker build agent is too hard, try AppVeyor's new build agent appveyor/ci#1150 using a simple appveyor.yml like mine.

@StefanScherer
Copy link
Author

Any progress having an Win 2016 server to provide official Node.js Windows Docker images?

@StefanScherer StefanScherer force-pushed the introduce-windows-dockerfiles branch from 5e7fd92 to e4f9a12 Compare March 22, 2017 06:36
@friism
Copy link

friism commented Mar 22, 2017

@StefanScherer what about adding appveyor machinery to the PR?

@StefanScherer
Copy link
Author

@friism Thanks, already working on a new PR that introduces both nano + core + appveyor.yml :-)

@StefanScherer
Copy link
Author

Closing, see #362 for a more up to date PR with appveyor.yml

@StefanScherer StefanScherer deleted the introduce-windows-dockerfiles branch July 23, 2017 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants