Skip to content

Commit 48c09b0

Browse files
authored
Merge pull request #13 from ClubeBitcoinUnB/feat/ci-pipeline
Add action to build docker container
2 parents 9479172 + f5dfe1f commit 48c09b0

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build Monitoring Container
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
test-docker-compose:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
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/bitcoin-node-healthcheck.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ case "$BITCOIN_NETWORK" in
66
mainnet) NETWORK="" ;;
77
signet) NETWORK="-signet" ;;
88
testnet) NETWORK="-testnet" ;;
9-
regtest|"") NETWORK="-regtest" ;; regtest is the default
9+
regtest|"") NETWORK="-regtest" ;; # regtest is the default
1010
*)
1111
echo "Unknown BITCOIN_NETWORK: $BITCOIN_NETWORK"
1212
exit 1

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)