1+ FROM mcr.microsoft.com/windows/servercore:ltsc2019
2+
3+ SHELL ["powershell" , "-Command" , "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';" ]
4+
5+ # PATH isn't actually set in the Docker image, so we have to set it from within the container
6+ RUN $newPath = ('C:\n odejs;{0}\Y arn\b in;{1}' -f $env:LOCALAPPDATA, $env:PATH); \
7+ Write-Host ('Updating PATH: {0}' -f $newPath); \
8+ [Environment]::SetEnvironmentVariable('PATH' , $newPath, [EnvironmentVariableTarget]::Machine)
9+ # doing this first to share cache across versions more aggressively
10+
11+ ENV NODE_VERSION 22.7.0
12+ ENV NODE_SHA256 3fc638727974262b4f65a6b1b43c22fb2d80671cdcb50e1237e0b05d1330aaf7
13+
14+ RUN $url = ('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VERSION); \
15+ Write-Host ('Downloading {0} ...' -f $url); \
16+ Invoke-WebRequest -Uri $url -OutFile 'node.zip' ; \
17+ \
18+ Write-Host ('Verifying sha256 ({0}) ...' -f $env:NODE_SHA256); \
19+ if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $env:NODE_SHA256) { throw 'SHA256 mismatch' }; \
20+ \
21+ Write-Host 'Expanding ...' ; \
22+ Expand-Archive node.zip -DestinationPath C:\; \
23+ \
24+ Write-Host 'Renaming ...' ; \
25+ Rename-Item -Path ('C:\n ode-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\n odejs' ; \
26+ \
27+ Write-Host 'Removing ...' ; \
28+ Remove-Item node.zip -Force; \
29+ \
30+ Write-Host 'Verifying ("node --version") ...' ; \
31+ node --version; \
32+ Write-Host 'Verifying ("npm --version") ...' ; \
33+ npm --version; \
34+ \
35+ Write-Host 'Complete.'
36+
37+ ENV YARN_VERSION 1.22.17
38+
39+ # "It is recommended to install Yarn through the npm package manager" (https://classic.yarnpkg.com/en/docs/install)
40+ RUN Write-Host 'Installing "yarn" ...' ; \
41+ npm install --global ('yarn@{0}' -f $env:YARN_VERSION); \
42+ \
43+ Write-Host 'Verifying ("yarn --version") ...' ; \
44+ yarn --version; \
45+ \
46+ Write-Host 'Complete.'
47+
48+ CMD [ "node" ]
0 commit comments