docker-node icon indicating copy to clipboard operation
docker-node copied to clipboard

Add Official Support for Windows Docker Images

Open zZHorizonZz opened this issue 1 year ago • 13 comments

Description

This PR introduces official support for building windows based docker images for node. At the moment, these images don't include Yarn, I noticed that other PR(s) are pushing to remove it from the Linux images as well, so I followed suit. Although maybe we could enable corepack by default? As currently, based on the discussion in the PR to enable corepack by default in Node itself, it seems like they will be rewriting it because npm has some security concers, so that may take a couple of years.

Motivation and Context

I've seen a few attempts to add windows support over the years, but those PRs seem to have stalled. So, I thought I'd take a look at it. I've combined some useful bits from those previous efforts and added my own improvements to get things working smoothly on newer versions and new build system.

Testing Details

I've successfully built and tested these images locally. Plus, with the new Windows pipeline I added, they've been tested against both Windows Server 2019 and 2022 trough github actions.

Example Output (if appropriate)

None provided

Types of changes

  • [x] Documentation
  • [ ] Version change (Update, remove or add more Node.js versions)
  • [x] Variant change (Update, remove or add more variants, or versions of variants)
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Other (none of the above)

Checklist

  • [x] My code follows the code style of this project.
  • [x] My change requires a change to the documentation.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING.md document.
  • [x] All new and existing tests passed.

zZHorizonZz avatar Sep 03 '24 10:09 zZHorizonZz

I see something weird going on in the GitHub action when running the gpg --keyserver command. If I run the build locally, it works, but if it runs in the GitHub action, it's throwing errors:

gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: Signature made 08/22/24 14:16:19 Coordinated Universal Time
gpg:                using RSA key 890C08DBEAB4DFCF[55](https://github.com/zZHorizonZz/docker-node-windows/actions/runs/10681419694/job/29605009626#step:4:56)5EF4
gpg: Can't check signature: No public key

It almost seems like it's not able to call the servers outside.

zZHorizonZz avatar Sep 04 '24 11:09 zZHorizonZz

I see something weird going on in the GitHub action when running the gpg --keyserver command. If I run the build locally, it works, but if it runs in the GitHub action, it's throwing errors:

gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: keyserver receive failed: Server indicated a failure
gpg: Signature made 08/22/24 14:16:19 Coordinated Universal Time
gpg:                using RSA key 890C08DBEAB4DFCF[55](https://github.com/zZHorizonZz/docker-node-windows/actions/runs/10681419694/job/29605009626#step:4:56)5EF4
gpg: Can't check signature: No public key

It almost seems like it's not able to call the servers outside.

The only thing I can think of is that it's being rate limited on the keyserver side, as the requests are coming from GitHub where I imagine a lot of people are sending requests. But in that case, I don't understand why the Linux build would work.

zZHorizonZz avatar Sep 05 '24 08:09 zZHorizonZz

Can you create a docs update PR for this?

LaurentGoderre avatar Sep 09 '24 13:09 LaurentGoderre

Can you create a docs update PR for this?

I have updated the README to include a section about the windowsservercore variant.

zZHorizonZz avatar Sep 09 '24 15:09 zZHorizonZz

@LaurentGoderre

Can you create a docs update PR for this?

Maybe I understand it wrong, but did you mean to update the README or is there some separate documentation I should update? I didn't find any other doc files in this project.

zZHorizonZz avatar Sep 10 '24 04:09 zZHorizonZz

There's a separate repo for the documentation on Hub but I realise the Node one is out of sync so I will fix that seperatly.

LaurentGoderre avatar Sep 10 '24 13:09 LaurentGoderre

I will let the other members review it but LGTM

LaurentGoderre avatar Sep 10 '24 13:09 LaurentGoderre

So since this has been merged, it means that users won't be able to use corepack without installing it (In the future). So do we want to install yarn or not? I personally think the decision on what to use for a package manager should be up to the user. So I would personally not install yarn at all and keep it the way it is, just plain Node.js, or install corepack so that users can then enable the package manager of their choice themselves.

zZHorizonZz avatar Sep 22 '24 15:09 zZHorizonZz

@zZHorizonZz I personally think it would be good to not include yarn in this variant by default since it's new and wouldn't break anything but I could see people wanting the variants to be consistent. I will let others weigh in on this.

LaurentGoderre avatar Sep 23 '24 14:09 LaurentGoderre

Yeah, the reason why I'm even discussing this is because of this issue you created, where I see an inclination to not just include yarn even in linux images, or create an image variant with yarn pre-installed.

zZHorizonZz avatar Sep 23 '24 14:09 zZHorizonZz

Looks like this will address #2063.

iancward avatar Oct 25 '24 22:10 iancward

Should I fix the nitpicks that Copilot made? I haven't really used this on GitHub, but there are commit suggestion actions available for both of these.

zZHorizonZz avatar Dec 10 '24 06:12 zZHorizonZz

I would suggest using nanoserver instead of servercore as it's much lighter.. I'm building my own image using the following code in my dockerfile:

FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 AS base

RUN curl.exe -o node.zip https://nodejs.org/dist/v20.17.0/node-v20.17.0-win-x64.zip && \
  mkdir "C:\\nodejs" && \
  tar.exe -xf node.zip -C "C:\\nodejs" --strip-components=1

ARG NODE_PATH="C:\nodejs"
ENV PATH "${NODE_PATH};C:\Windows\System32"
RUN npm config set registry https://registry.npmjs.org/

vaclavholusa avatar Jan 05 '25 22:01 vaclavholusa