-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathstart-node-ci
More file actions
executable file
·49 lines (39 loc) · 1.23 KB
/
start-node-ci
File metadata and controls
executable file
·49 lines (39 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
set -e
PROFILE_ARGS=()
SERVICES=(cli gatekeeper keymaster redis mongodb postgres search-server)
if [ -f .env ]; then
set -a
# shellcheck disable=SC1091
. ./.env
set +a
fi
if [ "${KC_IPFS_ENABLE,,}" != "false" ]; then
PROFILE_ARGS=(--profile ipfs)
SERVICES=(ipfs "${SERVICES[@]}")
fi
docker compose --profile ipfs down
docker compose down
docker compose "${PROFILE_ARGS[@]}" build "${SERVICES[@]}"
docker compose "${PROFILE_ARGS[@]}" up -d "${SERVICES[@]}"
echo "Waiting for all services to be 'Up'..."
MAX_RETRIES=30
RETRY_INTERVAL=5
RETRY_COUNT=0
while true; do
TOTAL_SERVICES="${#SERVICES[@]}"
UP_COUNT=$(docker compose "${PROFILE_ARGS[@]}" ps --services --status running "${SERVICES[@]}" | wc -l)
if [[ "$UP_COUNT" -eq "$TOTAL_SERVICES" ]]; then
echo "✅ All containers are 'Up'"
break
fi
if [[ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]]; then
echo "❌ Timed out waiting for containers to be 'Up'"
docker compose "${PROFILE_ARGS[@]}" ps -a
docker compose "${PROFILE_ARGS[@]}" logs --no-color --tail=200 "${SERVICES[@]}"
exit 1
fi
echo "⏳ Waiting... ($RETRY_COUNT/$MAX_RETRIES) running ${UP_COUNT}/${TOTAL_SERVICES}"
sleep "$RETRY_INTERVAL"
RETRY_COUNT=$((RETRY_COUNT + 1))
done