diff --git a/bootstrap/setup.sh b/bootstrap/setup.sh index 0ceb1a3..32666f4 100755 --- a/bootstrap/setup.sh +++ b/bootstrap/setup.sh @@ -1,5 +1,7 @@ #!/bin/bash +max_curl_attempts=10 + wait_for_docker() { TIMEOUT=30 while [ $TIMEOUT -gt 0 ]; do @@ -24,7 +26,7 @@ IMAGE_NAME="ghcr.io/digimangos-gateixeira-testing/shopping-list-api:main" echo "Running ${IMAGE_NAME} instance!" # Get the container ID of the running container for the specified image -CONTAINER_ID=$(docker ps --filter "ancestor=$IMAGE_NAME" --format "{{.ID}}") +CONTAINER_ID=$(docker ps -a --filter "ancestor=$IMAGE_NAME" --format "{{.ID}}") echo "Container ID: ${CONTAINER_ID}" @@ -42,5 +44,16 @@ while ! curl -s "http://localhost:3001/items/" > /dev/null; do sleep 1 done +attempt=0 +while ! curl -s "http://localhost:3001/items/" > /dev/null && [ $attempt -lt $max_curl_attempts ]; do + printf "." + sleep 2 + attempt=$((attempt + 1)) +done + +if [ $attempt -eq $max_curl_attempts ]; then + echo "Error: Unable to reach http://localhost:3001/items/ after $max_curl_attempts attempts." +fi + echo -e 'API is up and running!' -exit 0 \ No newline at end of file +exit 0