Skip to content

Commit f4cb17a

Browse files
author
Nate McMaster
committed
Add retries to dockerbuild.sh
1 parent 3e2cf46 commit f4cb17a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

dockerbuild.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ fi
104104
dockerfile="$DIR/build/docker/$image.Dockerfile"
105105
tagname="aspnetcore-build-$image"
106106

107+
# Use docker pull with retries to pre-pull the image need by the dockerfile
108+
# docker build regularly fails with TLS handshake issues for unclear reasons.
109+
base_imagename="$(grep -E -o 'FROM (.*)' $dockerfile | cut -c 6-)"
110+
pull_retries=3
111+
while [ $pull_retries -gt 0 ]; do
112+
failed=false
113+
docker pull $base_imagename || failed=true
114+
if [ "$failed" = true ]; then
115+
let pull_retries=pull_retries-1
116+
echo -e "${YELLOW}Failed to pull $base_imagename Retries left: $pull_retries.${RESET}"
117+
sleep 1
118+
else
119+
pull_retries=0
120+
fi
121+
done
122+
107123
docker build "$(dirname "$dockerfile")" \
108124
--build-arg "USER=$(whoami)" \
109125
--build-arg "USER_ID=$(id -u)" \

0 commit comments

Comments
 (0)