Skip to content

Commit c5cebb0

Browse files
authored
Retry wget tasks in Dockerfile (#63615)
Following #52519, our Docker build pulls down curl sources in an Alpine Linux container using wget. However that version of wget doesn't support any retry flags. Since network issues can cause build failures, wrap the wget calls in the same retry construct used for yum commands elsewhere. Closes #63600.
1 parent 281c702 commit c5cebb0

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

distribution/docker/src/docker/Dockerfile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,19 @@ RUN apk add gnupg gcc make musl-dev openssl-dev openssl-libs-static file
6161
RUN mkdir /work
6262
WORKDIR /work
6363
64-
# Fetch curl sources and files for validation
65-
RUN wget "https://daniel.haxx.se/mykey.asc" -O "curl-gpg.pub" && \\
66-
wget "\${TARBALL_URL}.asc" -O "\${TARBALL_PATH}.asc" && \\
67-
wget "\${TARBALL_URL}" -O "\${TARBALL_PATH}"
64+
# Fetch curl sources and files for validation. Note that alpine's `wget` doesn't have retry options.
65+
RUN function retry_wget() { \\
66+
local URL="\$1" ; \\
67+
local DEST="\$2" ; \\
68+
for iter in {1..10}; do \\
69+
wget "\$URL" -O "\$DEST" && \\
70+
exit_code=0 && break || exit_code=\$? && echo "wget error fetching \$URL: retry \$iter in 10s" && sleep 10; \\
71+
done; \\
72+
return \$exit_code ; \\
73+
} ; \\
74+
retry_wget "https://daniel.haxx.se/mykey.asc" "curl-gpg.pub" && \\
75+
retry_wget "\${TARBALL_URL}.asc" "\${TARBALL_PATH}.asc" && \\
76+
retry_wget "\${TARBALL_URL}" "\${TARBALL_PATH}"
6877
6978
# Validate source
7079
RUN gpg --import --always-trust "curl-gpg.pub" && \\
@@ -216,7 +225,8 @@ RUN for iter in {1..10}; do \\
216225
${package_manager} update --setopt=tsflags=nodocs -y && \\
217226
${package_manager} install --setopt=tsflags=nodocs -y \\
218227
nc shadow-utils zip unzip findutils procps-ng && \\
219-
${package_manager} clean all && exit_code=0 && break || exit_code=\$? && echo "${package_manager} error: retry \$iter in 10s" && \\
228+
${package_manager} clean all && \\
229+
exit_code=0 && break || exit_code=\$? && echo "${package_manager} error: retry \$iter in 10s" && \\
220230
sleep 10; \\
221231
done; \\
222232
(exit \$exit_code)

0 commit comments

Comments
 (0)