bypass build error: toomanyrequests: You have reached your pull rate limit.

This commit is contained in:
Gustavo Trott 2024-08-27 21:25:06 -03:00
parent e4f0238bc1
commit 5a3fb2c2c9

View File

@ -51,6 +51,29 @@ kill_docker() {
trap 'kill_docker' SIGINT SIGTERM
# Try to pull Docker Image 5 times (to bypass "toomanyrequests: You have reached your pull rate limit." error)
retry_count=0
max_retries=5
retry_wait=300 # wait time in seconds (5 minutes)
while [[ $retry_count -lt $max_retries ]]; do
if sudo docker pull "$DOCKER_IMAGE"; then
echo "Docker image pulled successfully."
break
else
echo "Failed to pull Docker image, attempt $((retry_count+1))/$max_retries."
((retry_count++))
if [[ $retry_count -lt $max_retries ]]; then
echo "Waiting for $retry_wait seconds before retrying..."
sleep $retry_wait
else
echo "Exceeded maximum retry attempts. Exiting."
exit 1
fi
fi
done
# -v "$CACHE_DIR/dev":/root/dev
sudo docker run --rm --detach --cidfile $DOCKER_CONTAINER_ID_FILE \
--env GIT_REV=$GIT_REV --env COMMIT_DATE=$COMMIT_DATE --env LOCAL_BUILD=$LOCAL_BUILD \