mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 15:17:30 -04:00
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.
This commit is contained in:
parent
281c702988
commit
c5cebb07e9
1 changed files with 15 additions and 5 deletions
|
@ -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" && \\
|
||||
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue