Skip to content

Commit a45e54a

Browse files
committed
feat(windows): added better install script and removed yarn
1 parent 3197c8d commit a45e54a

File tree

6 files changed

+144
-101
lines changed

6 files changed

+144
-101
lines changed

.github/workflows/build-test-windows.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ jobs:
6363
- name: Test for npm
6464
run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} npm --version
6565

66-
- name: Test for yarn
67-
run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} yarn --version
66+
#- name: Test for yarn
67+
# run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} yarn --version
6868

6969
build-windows-2022:
7070
name: build-windows-2022
@@ -115,5 +115,5 @@ jobs:
115115
- name: Test for npm
116116
run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} npm --version
117117

118-
- name: Test for yarn
119-
run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} yarn --version
118+
#- name: Test for yarn
119+
# run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} yarn --version

22/windows-2019/Dockerfile

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,45 @@ FROM mcr.microsoft.com/windows/servercore:ltsc2019
33
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
44

55
# PATH isn't actually set in the Docker image, so we have to set it from within the container
6-
RUN $newPath = ('C:\nodejs;{0}\Yarn\bin;{1}' -f $env:LOCALAPPDATA, $env:PATH); \
6+
RUN $newPath = ('C:\nodejs;{0}\Yarn\bin;{1};C:\Program Files (x86)\GnuPG\bin' -f $env:LOCALAPPDATA, $env:PATH); \
77
Write-Host ('Updating PATH: {0}' -f $newPath); \
88
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine)
99
# doing this first to share cache across versions more aggressively
1010

1111
ENV NODE_VERSION 22.7.0
1212
ENV NODE_CHECKSUM 3fc638727974262b4f65a6b1b43c22fb2d80671cdcb50e1237e0b05d1330aaf7
1313

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_CHECKSUM); \
19-
if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $env:NODE_CHECKSUM) { 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:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs'; \
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.'
14+
ENV GPG_VERSION 2.4.5_20240307
3615

37-
ENV YARN_VERSION 1.22.22
16+
RUN Invoke-WebRequest $('https://www.gnupg.org/ftp/gcrypt/binary/gnupg-w32-{0}.exe' -f $env:GPG_VERSION) -OutFile 'gpg-installer.exe'; \
17+
Start-Process -FilePath 'gpg-installer.exe' -ArgumentList '/S' -Wait; \
18+
Remove-Item gpg-installer.exe -Force; \
19+
gpg --version;
3820

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.'
21+
RUN @( \
22+
'4ED778F539E3634C779C87C6D7062848A1AB005C', \
23+
'141F07595B7B3FFE74309A937405533BE57C7D57', \
24+
'74F12602B6F1C4E913FAA37AD3A89613643B6201', \
25+
'DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7', \
26+
'61FC681DFB92A079F1685E77973F295594EC4689', \
27+
'8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600', \
28+
'C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8', \
29+
'890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4', \
30+
'C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C', \
31+
'108F52B48DB57BB0CC439B2997B01419BD92F80A', \
32+
'A363A499291CBBC940DD62E41F10027AF002F8B0', \
33+
'CC68F5A3106FF448322E48ED27F5E38D5B0A215F' \
34+
) | foreach { \
35+
gpg --keyserver hkps://keys.openpgp.org --recv-keys $_ ; \
36+
} ; \
37+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \
38+
Invoke-WebRequest $('https://nodejs.org/dist/v{0}/SHASUMS256.txt.asc' -f $env:NODE_VERSION) -OutFile 'SHASUMS256.txt.asc' -UseBasicParsing ; \
39+
gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc ; \
40+
Invoke-WebRequest $('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VERSION) -OutFile 'node.zip' -UseBasicParsing ; \
41+
$sum = $(cat SHASUMS256.txt.asc | sls $(' node-v{0}-win-x64.zip' -f $env:NODE_VERSION)) -Split ' ' ; \
42+
if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $sum[0]) { Write-Error 'SHA256 mismatch' } ; \
43+
Expand-Archive node.zip -DestinationPath C:\ ; \
44+
Rename-Item -Path $('C:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs'
4745

4846
COPY docker-entrypoint.ps1 C:/docker-entrypoint.ps1
4947
ENTRYPOINT [ "powershell.exe" , "C:/docker-entrypoint.ps1" ]

22/windows-2022/Dockerfile

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,45 @@ FROM mcr.microsoft.com/windows/servercore:ltsc2022
33
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
44

55
# PATH isn't actually set in the Docker image, so we have to set it from within the container
6-
RUN $newPath = ('C:\nodejs;{0}\Yarn\bin;{1}' -f $env:LOCALAPPDATA, $env:PATH); \
6+
RUN $newPath = ('C:\nodejs;{0}\Yarn\bin;{1};C:\Program Files (x86)\GnuPG\bin' -f $env:LOCALAPPDATA, $env:PATH); \
77
Write-Host ('Updating PATH: {0}' -f $newPath); \
88
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine)
99
# doing this first to share cache across versions more aggressively
1010

1111
ENV NODE_VERSION 22.7.0
1212
ENV NODE_CHECKSUM 3fc638727974262b4f65a6b1b43c22fb2d80671cdcb50e1237e0b05d1330aaf7
1313

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_CHECKSUM); \
19-
if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $env:NODE_CHECKSUM) { 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:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs'; \
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.'
14+
ENV GPG_VERSION 2.4.5_20240307
3615

37-
ENV YARN_VERSION 1.22.22
16+
RUN Invoke-WebRequest $('https://www.gnupg.org/ftp/gcrypt/binary/gnupg-w32-{0}.exe' -f $env:GPG_VERSION) -OutFile 'gpg-installer.exe'; \
17+
Start-Process -FilePath 'gpg-installer.exe' -ArgumentList '/S' -Wait; \
18+
Remove-Item gpg-installer.exe -Force; \
19+
gpg --version;
3820

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.'
21+
RUN @( \
22+
'4ED778F539E3634C779C87C6D7062848A1AB005C', \
23+
'141F07595B7B3FFE74309A937405533BE57C7D57', \
24+
'74F12602B6F1C4E913FAA37AD3A89613643B6201', \
25+
'DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7', \
26+
'61FC681DFB92A079F1685E77973F295594EC4689', \
27+
'8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600', \
28+
'C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8', \
29+
'890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4', \
30+
'C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C', \
31+
'108F52B48DB57BB0CC439B2997B01419BD92F80A', \
32+
'A363A499291CBBC940DD62E41F10027AF002F8B0', \
33+
'CC68F5A3106FF448322E48ED27F5E38D5B0A215F' \
34+
) | foreach { \
35+
gpg --keyserver hkps://keys.openpgp.org --recv-keys $_ ; \
36+
} ; \
37+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \
38+
Invoke-WebRequest $('https://nodejs.org/dist/v{0}/SHASUMS256.txt.asc' -f $env:NODE_VERSION) -OutFile 'SHASUMS256.txt.asc' -UseBasicParsing ; \
39+
gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc ; \
40+
Invoke-WebRequest $('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VERSION) -OutFile 'node.zip' -UseBasicParsing ; \
41+
$sum = $(cat SHASUMS256.txt.asc | sls $(' node-v{0}-win-x64.zip' -f $env:NODE_VERSION)) -Split ' ' ; \
42+
if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $sum[0]) { Write-Error 'SHA256 mismatch' } ; \
43+
Expand-Archive node.zip -DestinationPath C:\ ; \
44+
Rename-Item -Path $('C:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs'
4745

4846
COPY docker-entrypoint.ps1 C:/docker-entrypoint.ps1
4947
ENTRYPOINT [ "powershell.exe" , "C:/docker-entrypoint.ps1" ]

Dockerfile-win.template

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM mcr.microsoft.com/windows/servercore:version
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:\nodejs;{0}\Yarn\bin;{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 0.0.0
12+
ENV NODE_CHECKSUM CHECKSUM_x64
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_CHECKSUM); \
19+
if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $env:NODE_CHECKSUM) { 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:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs'; \
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 0.0.0
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+
COPY docker-entrypoint.ps1 C:/docker-entrypoint.ps1
49+
ENTRYPOINT [ "powershell.exe" , "C:/docker-entrypoint.ps1" ]
50+
51+
CMD [ "node.exe" ]

Dockerfile-windows.template

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,34 @@ FROM mcr.microsoft.com/windows/servercore:version
33
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
44

55
# PATH isn't actually set in the Docker image, so we have to set it from within the container
6-
RUN $newPath = ('C:\nodejs;{0}\Yarn\bin;{1}' -f $env:LOCALAPPDATA, $env:PATH); \
6+
RUN $newPath = ('C:\nodejs;{0}\Yarn\bin;{1};C:\Program Files (x86)\GnuPG\bin' -f $env:LOCALAPPDATA, $env:PATH); \
77
Write-Host ('Updating PATH: {0}' -f $newPath); \
88
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine)
99
# doing this first to share cache across versions more aggressively
1010

1111
ENV NODE_VERSION 0.0.0
1212
ENV NODE_CHECKSUM CHECKSUM_x64
1313

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_CHECKSUM); \
19-
if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $env:NODE_CHECKSUM) { 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:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs'; \
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.'
14+
ENV GPG_VERSION 2.4.5_20240307
3615

37-
ENV YARN_VERSION 0.0.0
16+
RUN Invoke-WebRequest $('https://www.gnupg.org/ftp/gcrypt/binary/gnupg-w32-{0}.exe' -f $env:GPG_VERSION) -OutFile 'gpg-installer.exe'; \
17+
Start-Process -FilePath 'gpg-installer.exe' -ArgumentList '/S' -Wait; \
18+
Remove-Item gpg-installer.exe -Force; \
19+
gpg --version;
3820

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.'
21+
RUN @( \
22+
"${NODE_KEYS[@]}"
23+
) | foreach { \
24+
gpg --keyserver hkps://keys.openpgp.org --recv-keys $_ ; \
25+
} ; \
26+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \
27+
Invoke-WebRequest $('https://nodejs.org/dist/v{0}/SHASUMS256.txt.asc' -f $env:NODE_VERSION) -OutFile 'SHASUMS256.txt.asc' -UseBasicParsing ; \
28+
gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc ; \
29+
Invoke-WebRequest $('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VERSION) -OutFile 'node.zip' -UseBasicParsing ; \
30+
$sum = $(cat SHASUMS256.txt.asc | sls $(' node-v{0}-win-x64.zip' -f $env:NODE_VERSION)) -Split ' ' ; \
31+
if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $sum[0]) { Write-Error 'SHA256 mismatch' } ; \
32+
Expand-Archive node.zip -DestinationPath C:\ ; \
33+
Rename-Item -Path $('C:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs'
4734

4835
COPY docker-entrypoint.ps1 C:/docker-entrypoint.ps1
4936
ENTRYPOINT [ "powershell.exe" , "C:/docker-entrypoint.ps1" ]

update.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,18 @@ function update_node_version() {
151151

152152
# Add GPG keys
153153
for key_type in "node" "yarn"; do
154+
last_line=$(tail -n 1 "keys/${key_type}.keys")
154155
while read -r line; do
155156
pattern='"\$\{'$(echo "${key_type}" | tr '[:lower:]' '[:upper:]')'_KEYS\[@\]\}"'
156-
sed -Ei -e "s/([ \\t]*)(${pattern})/\\1${line}${new_line}\\1\\2/" "${dockerfile}-tmp"
157+
if is_windows "${variant}"; then
158+
if [ "$line" = "$last_line" ]; then # Check if it's the last key
159+
sed -Ei -e "s/([ \\t]*)(${pattern})/\\1'${line}'${new_line}\\1\\2/" "${dockerfile}-tmp"
160+
else
161+
sed -Ei -e "s/([ \\t]*)(${pattern})/\\1'${line}',${new_line}\\1\\2/" "${dockerfile}-tmp"
162+
fi
163+
else
164+
sed -Ei -e "s/([ \\t]*)(${pattern})/\\1${line}${new_line}\\1\\2/" "${dockerfile}-tmp"
165+
fi
157166
done < "keys/${key_type}.keys"
158167
sed -Ei -e "/${pattern}/d" "${dockerfile}-tmp"
159168
done

0 commit comments

Comments
 (0)