Skip to content

Commit b4f1c4f

Browse files
committed
add proper healthcheck to docker compose and wait
1 parent 29cec2e commit b4f1c4f

2 files changed

Lines changed: 32 additions & 16 deletions

File tree

examples/ethereum-basic-event-handlers/docker-compose.yml

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,62 @@ services:
22
hardhat:
33
build: ./hardhat
44
ports:
5-
- '8545:8545'
5+
- "8545:8545"
66
graph-node:
77
image: graphprotocol/graph-node:latest
8+
platform: linux/amd64
89
ports:
9-
- '8000:8000'
10-
- '8001:8001'
11-
- '8020:8020'
12-
- '8030:8030'
13-
- '8040:8040'
10+
- "8000:8000"
11+
- "8001:8001"
12+
- "8020:8020"
13+
- "8030:8030"
14+
- "8040:8040"
1415
depends_on:
15-
- hardhat
16-
- ipfs
17-
- postgres
16+
hardhat:
17+
condition: service_started
18+
ipfs:
19+
condition: service_started
20+
postgres:
21+
condition: service_healthy
1822
environment:
1923
postgres_host: postgres
2024
postgres_user: graph-node
2125
postgres_pass: let-me-in
2226
postgres_db: graph-node
23-
ipfs: 'ipfs:5001'
24-
ethereum: 'test:http://hardhat:8545'
27+
ipfs: "ipfs:5001"
28+
ethereum: "test:http://hardhat:8545"
2529
GRAPH_LOG: info
2630
GRAPH_ALLOW_NON_DETERMINISTIC_IPFS: 1
31+
healthcheck:
32+
test: ["CMD-SHELL", "nc -z localhost 8030 || exit 1"]
33+
interval: 5s
34+
timeout: 5s
35+
retries: 30
36+
start_period: 10s
2737
ipfs:
2838
image: ipfs/kubo:v0.19.1
2939
ports:
30-
- '5001:5001'
40+
- "5001:5001"
3141
volumes:
3242
- ipfs-data:/data/ipfs
3343
postgres:
3444
image: postgres
3545
ports:
36-
- '5432:5432'
37-
command: ['postgres', '-cshared_preload_libraries=pg_stat_statements']
46+
- "5432:5432"
47+
command: ["postgres", "-cshared_preload_libraries=pg_stat_statements"]
3848
environment:
3949
POSTGRES_USER: graph-node
4050
POSTGRES_PASSWORD: let-me-in
4151
POSTGRES_DB: graph-node
42-
POSTGRES_INITDB_ARGS: '-E UTF8 --locale=C'
52+
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
4353
volumes:
4454
- postgres-data:/var/lib/postgresql/data
55+
healthcheck:
56+
test: ["CMD-SHELL", "pg_isready -U graph-node"]
57+
interval: 5s
58+
timeout: 5s
59+
retries: 30
60+
start_period: 5s
4561

4662
volumes:
4763
ipfs-data:

examples/ethereum-basic-event-handlers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"codegen": "graph codegen",
1414
"create-test": "graph create test/basic-event-handlers --node http://localhost:8020/",
1515
"deploy-test": "graph deploy test/basic-event-handlers --version-label v0.0.1 --ipfs http://localhost:5001 --node http://localhost:8020/",
16-
"test": "docker compose up -d && sleep 30 && hardhat test --network localhost && docker compose down",
16+
"test": "docker compose up -d --wait --wait-timeout 50 && hardhat test --network localhost && docker compose down",
1717
"test:hardhat": "hardhat test --network localhost"
1818
},
1919
"dependencies": {

0 commit comments

Comments
 (0)