Skip to content

Commit

Permalink
fix(ci): properly wait for containers to be up and running (#1160)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske authored Jan 5, 2024
1 parent b96b8c5 commit 316671c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .ci/setup_kong.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ GATEWAY_CONTAINER_NAME=kong

waitContainer() {
for try in {1..100}; do
echo "waiting for $1.."
nc localhost $2 && break;
sleep $3
echo "waiting for $1"
docker exec --user root $2 $3 && break;
sleep 0.2
done
}

Expand All @@ -33,7 +33,7 @@ docker run --rm -d --name $PG_CONTAINER_NAME \
-e "POSTGRES_PASSWORD=$KONG_DB_PASSWORD" \
postgres:9.6

waitContainer "PostgreSQL" 8001 0.2
waitContainer "PostGres" $PG_CONTAINER_NAME pg_isready

# Prepare the Kong database
docker run --rm --network=$NETWORK_NAME \
Expand Down Expand Up @@ -62,4 +62,4 @@ docker run -d --name $GATEWAY_CONTAINER_NAME \
-p 127.0.0.1:8444:8444 \
$KONG_IMAGE

waitContainer "Kong" 8001 0.2
waitContainer "Kong" $GATEWAY_CONTAINER_NAME "kong health"
16 changes: 8 additions & 8 deletions .ci/setup_kong_ee.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ KONG_PG_HOST=pg

GATEWAY_CONTAINER_NAME=kong

# create docker network
docker network create $NETWORK_NAME

waitContainer() {
for try in {1..100}; do
echo "waiting for $1.."
nc localhost $2 && break;
sleep $3
echo "waiting for $1"
docker exec --user root $2 $3 && break;
sleep 0.2
done
}

# create docker network
docker network create $NETWORK_NAME

# Start a PostgreSQL container
docker run --rm -d --name $PG_CONTAINER_NAME \
--network=$NETWORK_NAME \
Expand All @@ -88,7 +88,7 @@ docker run --rm -d --name $PG_CONTAINER_NAME \
-e "POSTGRES_PASSWORD=$KONG_DB_PASSWORD" \
postgres:9.6

waitContainer "PostgreSQL" 5432 0.2
waitContainer "PostGres" $PG_CONTAINER_NAME pg_isready

# Prepare the Kong database
docker run --rm --network=$NETWORK_NAME \
Expand Down Expand Up @@ -126,4 +126,4 @@ docker run -d --name $GATEWAY_CONTAINER_NAME \
-p 8004:8004 \
$KONG_IMAGE

waitContainer "Kong" 8001 0.2
waitContainer "Kong" $GATEWAY_CONTAINER_NAME "kong health"

0 comments on commit 316671c

Please sign in to comment.