Skip to content

Commit 5f4c7d7

Browse files
committed
Added update.sh
1 parent d3738da commit 5f4c7d7

File tree

7 files changed

+124
-19
lines changed

7 files changed

+124
-19
lines changed

22/windows-2019/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN $newPath = ('C:\nodejs;{0}\Yarn\bin;{1}' -f $env:LOCALAPPDATA, $env:PATH); \
99
# doing this first to share cache across versions more aggressively
1010

1111
ENV NODE_VERSION 22.7.0
12-
ENV NODE_SHA256 3fc638727974262b4f65a6b1b43c22fb2d80671cdcb50e1237e0b05d1330aaf7
12+
ENV CHECKSUM 3fc638727974262b4f65a6b1b43c22fb2d80671cdcb50e1237e0b05d1330aaf7
1313

1414
RUN $url = ('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VERSION); \
1515
Write-Host ('Downloading {0} ...' -f $url); \
@@ -34,7 +34,7 @@ RUN $url = ('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VE
3434
\
3535
Write-Host 'Complete.'
3636

37-
ENV YARN_VERSION 1.22.17
37+
ENV YARN_VERSION 1.22.22
3838

3939
# "It is recommended to install Yarn through the npm package manager" (https://classic.yarnpkg.com/en/docs/install)
4040
RUN Write-Host 'Installing "yarn" ...'; \
@@ -47,5 +47,5 @@ RUN Write-Host 'Installing "yarn" ...'; \
4747

4848
COPY docker-entrypoint.ps1 C:/docker-entrypoint.ps1
4949
ENTRYPOINT [ "powershell.exe" , "C:/docker-entrypoint.ps1" ]
50-
50+
5151
CMD [ "node.exe" ]

22/windows-2022/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN $newPath = ('C:\nodejs;{0}\Yarn\bin;{1}' -f $env:LOCALAPPDATA, $env:PATH); \
99
# doing this first to share cache across versions more aggressively
1010

1111
ENV NODE_VERSION 22.7.0
12-
ENV NODE_SHA256 3fc638727974262b4f65a6b1b43c22fb2d80671cdcb50e1237e0b05d1330aaf7
12+
ENV CHECKSUM 3fc638727974262b4f65a6b1b43c22fb2d80671cdcb50e1237e0b05d1330aaf7
1313

1414
RUN $url = ('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VERSION); \
1515
Write-Host ('Downloading {0} ...' -f $url); \
@@ -34,7 +34,7 @@ RUN $url = ('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VE
3434
\
3535
Write-Host 'Complete.'
3636

37-
ENV YARN_VERSION 1.22.17
37+
ENV YARN_VERSION 1.22.22
3838

3939
# "It is recommended to install Yarn through the npm package manager" (https://classic.yarnpkg.com/en/docs/install)
4040
RUN Write-Host 'Installing "yarn" ...'; \

Dockerfile-windows.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 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_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:\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" ]

architectures

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
bashbrew-arch variants
2-
amd64 alpine3.19,alpine3.20,bookworm,bookworm-slim,bullseye,bullseye-slim
2+
amd64 alpine3.19,alpine3.20,bookworm,bookworm-slim,bullseye,bullseye-slim,windows-2019,windows-2022
33
arm32v6 alpine3.19,alpine3.20
44
arm32v7 alpine3.19,alpine3.20,bookworm,bookworm-slim,bullseye,bullseye-slim
55
arm64v8 alpine3.19,alpine3.20,bookworm,bookworm-slim,bullseye,bullseye-slim
66
i386 alpine3.19,alpine3.20
77
ppc64le alpine3.19,alpine3.20,bookworm,bookworm-slim,bullseye,bullseye-slim
8-
s390x alpine3.19,alpine3.20,bookworm,bookworm-slim,bullseye,bullseye-slim
8+
s390x alpine3.19,alpine3.20,bookworm,bookworm-slim,bullseye,bullseye-slim

docker-entrypoint.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Ensure script stops on any error
2+
$ErrorActionPreference = 'Stop'
3+
4+
# Check if the first argument:
5+
# 1. Contains a "-"
6+
# 2. Is NOT a recognized command
7+
# 3. Is a file that's NOT executable
8+
if (($args[0] -like '*-') -or
9+
(!(Get-Command $args[0] -ErrorAction SilentlyContinue)) -or
10+
(((Test-Path $args[0] -PathType Leaf)) -and -not ((Get-Item $args[0]).Attributes -band 'ReadOnly'))) {
11+
# Prepend 'node' to the argument list
12+
$args = @('node') + $args
13+
}
14+
15+
# Execute the (potentially modified) command
16+
& $args[0] $args[1..($args.Length-1)]

functions.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ function is_debian_slim() {
193193
return 1
194194
}
195195

196+
function is_windows() {
197+
local variant
198+
variant=$1
199+
shift
200+
201+
if [ "${variant}" = "${variant#windows}" ]; then
202+
return 1
203+
fi
204+
}
205+
196206
function get_fork_name() {
197207
local version
198208
version=$1

update.sh

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,42 @@ set -ue
55
function usage() {
66
cat << EOF
77
8-
Update the node docker images.
8+
Update the node Docker images.
99
1010
Usage:
11-
$0 [-s] [MAJOR_VERSION(S)] [VARIANT(S)]
11+
$0 [-s] [-w] [MAJOR_VERSION(S)] [VARIANT(S)]
1212
1313
Examples:
14-
- update.sh # Update all images
15-
- update.sh -s # Update all images, skip updating Alpine and Yarn
16-
- update.sh 8,10 # Update all variants of version 8 and 10
17-
- update.sh -s 8 # Update version 8 and variants, skip updating Alpine and Yarn
18-
- update.sh 8 alpine # Update only alpine's variants for version 8
19-
- update.sh -s 8 bullseye # Update only bullseye variant for version 8, skip updating Alpine and Yarn
20-
- update.sh . alpine # Update the alpine variant for all versions
14+
- update.sh # Update all images
15+
- update.sh -s # Update all images, skip updating Alpine and Yarn
16+
- update.sh -w # Update only Windows images
17+
- update.sh 8,10 # Update all variants of version 8 and 10
18+
- update.sh -s 8 # Update version 8 and variants, skip updating Alpine and Yarn
19+
- update.sh 8 alpine # Update only Alpine variants for version 8
20+
- update.sh -w 8 windows-2022 # Update only Windows 2022 variant for version 8
21+
- update.sh . alpine # Update the Alpine variant for all versions
2122
2223
OPTIONS:
23-
-s Security update; skip updating the yarn and alpine versions.
24+
-s Security update; skip updating the Yarn and Alpine versions.
25+
-w Windows images update only
2426
-b CI config update only
2527
-h Show this message
2628
2729
EOF
2830
}
2931

3032
SKIP=false
31-
while getopts "sh" opt; do
33+
WINDOWS_ONLY=false
34+
while getopts "swh" opt; do
3235
case "${opt}" in
3336
s)
3437
SKIP=true
3538
shift
3639
;;
40+
w)
41+
WINDOWS_ONLY=true
42+
shift
43+
;;
3744
h)
3845
usage
3946
exit
@@ -167,6 +174,17 @@ function update_node_version() {
167174
sed -Ei -e "s/(buildpack-deps:)name/\\1${variant}/" "${dockerfile}-tmp"
168175
elif is_debian_slim "${variant}"; then
169176
sed -Ei -e "s/(debian:)name-slim/\\1${variant}/" "${dockerfile}-tmp"
177+
elif is_windows "${variant}"; then
178+
windows_version="${variant#*windows-}"
179+
checksum=$(
180+
curl -sSL --compressed "https://nodejs.org/dist/v${nodeVersion}/SHASUMS256.txt" | grep "node-v${nodeVersion}-win-x64.zip" | cut -d' ' -f1
181+
)
182+
if [ -z "$checksum" ]; then
183+
rm -f "${dockerfile}-tmp"
184+
fatal "Failed to fetch checksum for version ${nodeVersion}"
185+
fi
186+
sed -Ei -e "s/mcr\.microsoft\.com\/windows\/servercore:version/mcr\.microsoft\.com\/windows\/servercore:ltsc${windows_version}/" "${dockerfile}-tmp"
187+
sed -Ei -e 's/^(ENV CHECKSUM ).*/\1'"${checksum}"'/' "${dockerfile}-tmp"
170188
fi
171189

172190
if diff -q "${dockerfile}-tmp" "${dockerfile}" > /dev/null; then
@@ -201,6 +219,8 @@ for version in "${versions[@]}"; do
201219
# See details in function.sh
202220
IFS=' ' read -ra variants <<< "$(get_variants "${parentpath}")"
203221

222+
echo "Supported variants for ${parentpath}: ${variants[@]}"
223+
204224
pids=()
205225

206226
if [ -f "${version}/Dockerfile" ]; then
@@ -223,9 +243,17 @@ for version in "${versions[@]}"; do
223243
template_file="${parentpath}/Dockerfile-slim.template"
224244
elif is_alpine "${variant}"; then
225245
template_file="${parentpath}/Dockerfile-alpine.template"
246+
elif is_windows "${variant}"; then
247+
template_file="${parentpath}/Dockerfile-windows.template"
248+
fi
249+
250+
# Copy .sh only if not is_windows
251+
if ! is_windows "${variant}"; then
252+
cp "${parentpath}/docker-entrypoint.sh" "${version}/${variant}/docker-entrypoint.sh"
253+
elif is_windows "${variant}"; then
254+
cp "${parentpath}/docker-entrypoint.ps1" "${version}/${variant}/docker-entrypoint.ps1"
226255
fi
227256

228-
cp "${parentpath}/docker-entrypoint.sh" "${version}/${variant}/docker-entrypoint.sh"
229257
if [ "${update_version}" -eq 0 ] && [ "${update_variant}" -eq 0 ]; then
230258
update_node_version "${baseuri}" "${versionnum}" "${template_file}" "${version}/${variant}/Dockerfile" "${variant}" &
231259
pids+=($!)

0 commit comments

Comments
 (0)