@@ -5,35 +5,42 @@ set -ue
55function 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
2729EOF
2830}
2931
3032SKIP=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