Skip to content

Retry wget tasks in Dockerfile #63615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions distribution/docker/src/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,19 @@ RUN apk add gnupg gcc make musl-dev openssl-dev openssl-libs-static file
RUN mkdir /work
WORKDIR /work

# Fetch curl sources and files for validation
RUN wget "https://daniel.haxx.se/mykey.asc" -O "curl-gpg.pub" && \\
wget "\${TARBALL_URL}.asc" -O "\${TARBALL_PATH}.asc" && \\
wget "\${TARBALL_URL}" -O "\${TARBALL_PATH}"
# Fetch curl sources and files for validation. Note that alpine's `wget` doesn't have retry options.
RUN function retry_wget() { \\
local URL="\$1" ; \\
local DEST="\$2" ; \\
for iter in {1..10}; do \\
wget "\$URL" -O "\$DEST" && \\
exit_code=0 && break || exit_code=\$? && echo "wget error fetching \$URL: retry \$iter in 10s" && sleep 10; \\
done; \\
return \$exit_code ; \\
} ; \\
retry_wget "https://daniel.haxx.se/mykey.asc" "curl-gpg.pub" && \\
retry_wget "\${TARBALL_URL}.asc" "\${TARBALL_PATH}.asc" && \\
retry_wget "\${TARBALL_URL}" "\${TARBALL_PATH}"

# Validate source
RUN gpg --import --always-trust "curl-gpg.pub" && \\
Expand Down Expand Up @@ -216,7 +225,8 @@ RUN for iter in {1..10}; do \\
${package_manager} update --setopt=tsflags=nodocs -y && \\
${package_manager} install --setopt=tsflags=nodocs -y \\
nc shadow-utils zip unzip findutils procps-ng && \\
${package_manager} clean all && exit_code=0 && break || exit_code=\$? && echo "${package_manager} error: retry \$iter in 10s" && \\
${package_manager} clean all && \\
exit_code=0 && break || exit_code=\$? && echo "${package_manager} error: retry \$iter in 10s" && \\
sleep 10; \\
done; \\
(exit \$exit_code)
Expand Down