Skip to content

Commit f5dfe1f

Browse files
m4yconedilmedeiros
authored andcommitted
Add healthcheck into build action
1 parent eac2b84 commit f5dfe1f

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

.github/workflows/build-monitoring-container.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,16 @@ jobs:
1919
- name: Set up Docker Buildx
2020
uses: docker/setup-buildx-action@v3
2121

22-
- name: Build Docker Compose
23-
run: docker compose --profile monitoring build
22+
- name: Build and Start Docker Compose
23+
run: |
24+
docker compose --profile monitoring build
25+
docker compose --profile monitoring up -d
26+
27+
- name: Wait for bitcoin-node to be healthy
28+
run: |
29+
chmod +x docker/wait-for-bitcoin-healthy.sh
30+
docker/wait-for-bitcoin-healthy.sh
31+
32+
- name: Stop Docker Compose
33+
run: |
34+
docker compose down -v

docker/wait-for-bitcoin-healthy.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
echo "Waiting for bitcoin-node to be healthy..."
4+
TIMEOUT=60
5+
INTERVAL=6
6+
ELAPSED=0
7+
8+
while [ $ELAPSED -lt $TIMEOUT ]; do
9+
HEALTH=$(docker container inspect -f '{{.State.Health.Status}}' peer-observer-docker-bitcoin-node-1)
10+
if [ "$HEALTH" = "healthy" ]; then
11+
echo "bitcoin-node is healthy!"
12+
exit 0
13+
fi
14+
15+
echo "Current health status: $HEALTH"
16+
sleep $INTERVAL
17+
ELAPSED=$((ELAPSED + INTERVAL))
18+
done
19+
20+
echo "bitcoin-node failed to become healthy within $TIMEOUT seconds."
21+
docker compose logs bitcoin-node
22+
exit 1

0 commit comments

Comments
 (0)