Skip to content

Commit bfd3789

Browse files
authored
Merge pull request #25 from verbotenj/feat-docker-compose-postgres
feat: Add a docker-compose with cardano-node and postgres for persistent data
2 parents aae50d0 + 75ec277 commit bfd3789

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

config/secrets/postgres_db

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cexplorer

config/secrets/postgres_password

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
changeme

config/secrets/postgres_user

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
postgres

docker-compose.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
version: "3.9"
2+
3+
services:
4+
postgres:
5+
image: postgres:15.3-alpine3.18
6+
environment:
7+
- POSTGRES_LOGGING=true
8+
- POSTGRES_DB_FILE=/run/secrets/postgres_db
9+
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
10+
- POSTGRES_USER_FILE=/run/secrets/postgres_user
11+
secrets:
12+
- postgres_password
13+
- postgres_user
14+
- postgres_db
15+
ports:
16+
- ${POSTGRES_PORT:-5432}:5432
17+
volumes:
18+
- postgres:/var/lib/postgresql/data
19+
restart: on-failure
20+
healthcheck:
21+
# Use pg_isready to check postgres is running. Substitute different
22+
# user `postgres` if you've setup differently to config/pgpass-mainnet
23+
test: ["CMD-SHELL", "pg_isready -U postgres"]
24+
interval: 10s
25+
timeout: 5s
26+
retries: 5
27+
command: ${POSTGRES_ARGS:--c maintenance_work_mem=1GB -c max_parallel_maintenance_workers=4}
28+
logging:
29+
driver: "json-file"
30+
options:
31+
max-size: "200k"
32+
max-file: "10"
33+
34+
cardano-node:
35+
image: ghcr.io/blinklabs-io/cardano-node:latest
36+
environment:
37+
- NETWORK=${NETWORK:-preview}
38+
volumes:
39+
- node-data:/opt/cardano/data
40+
- node-ipc:/ipc
41+
restart: on-failure
42+
healthcheck:
43+
test: ["CMD-SHELL", "curl -f 127.0.0.1:12798/metrics || exit 1"]
44+
interval: 60s
45+
timeout: 10s
46+
retries: 5
47+
logging:
48+
driver: "json-file"
49+
options:
50+
max-size: "200k"
51+
max-file: "10"
52+
53+
cardano-db-sync:
54+
image: blinklabs/cardano-db-sync:13.1.0.2
55+
environment:
56+
- DISABLE_LEDGER=${DISABLE_LEDGER}
57+
- NETWORK=${NETWORK:-preview}
58+
- POSTGRES_HOST=postgres
59+
- POSTGRES_PORT=5432
60+
- RESTORE_SNAPSHOT=${RESTORE_SNAPSHOT:-}
61+
- RESTORE_RECREATE_DB=N
62+
- EXTRA_DB_SYNC_ARGS=${EXTRA_DB_SYNC_ARGS:-}
63+
depends_on:
64+
# Depend on both services to be healthy before starting.
65+
cardano-node:
66+
condition: service_healthy
67+
postgres:
68+
condition: service_healthy
69+
secrets:
70+
- postgres_password
71+
- postgres_user
72+
- postgres_db
73+
volumes:
74+
- db-sync-data:/var/lib/cexplorer
75+
- node-ipc:/node-ipc
76+
restart: on-failure
77+
logging:
78+
driver: "json-file"
79+
options:
80+
max-size: "200k"
81+
max-file: "10"
82+
83+
secrets:
84+
postgres_db:
85+
file: ./config/secrets/postgres_db
86+
postgres_password:
87+
file: ./config/secrets/postgres_password
88+
postgres_user:
89+
file: ./config/secrets/postgres_user
90+
91+
volumes:
92+
db-sync-data:
93+
postgres:
94+
node-data:
95+
node-ipc:

0 commit comments

Comments
 (0)