Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
136 lines (130 loc) · 4.75 KB
/
Copy pathdocker-compose.yml
File metadata and controls
136 lines (130 loc) · 4.75 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
x-backend-env: &backend-env
FRONTEND_URL: ${FRONTEND_URL:-http://localhost:3000}
DATABASE_URL: postgresql://refract:${POSTGRES_PASSWORD:-refract_dev}@postgres:5432/refract
REDIS_URL: redis://redis:6379
STELLAR_NETWORK: ${STELLAR_NETWORK:-testnet}
SOROBAN_RPC_URL: ${SOROBAN_RPC_URL:-https://soroban-testnet.stellar.org}
STELLAR_NETWORK_PASSPHRASE: ${STELLAR_NETWORK_PASSPHRASE:-Test SDF Network ; September 2015}
REFRACT_POOL_CONTRACT_ID: ${REFRACT_POOL_CONTRACT_ID:-}
REFRACT_POLICY_CONTRACT_ID: ${REFRACT_POLICY_CONTRACT_ID:-}
REFRACT_ORACLE_CONTRACT_ID: ${REFRACT_ORACLE_CONTRACT_ID:-}
ORACLE_RELAYER_SECRET: ${ORACLE_RELAYER_SECRET:-}
COINGECKO_BASE_URL: ${COINGECKO_BASE_URL:-https://api.coingecko.com/api/v3}
STELLAR_HORIZON_URL: ${STELLAR_HORIZON_URL:-https://horizon-testnet.stellar.org}
DEFILLAMA_BASE_URL: ${DEFILLAMA_BASE_URL:-https://api.llama.fi}
DEFILLAMA_PROTOCOL_SLUG: ${DEFILLAMA_PROTOCOL_SLUG:-aave}
ORACLE_HTTP_TIMEOUT_MS: ${ORACLE_HTTP_TIMEOUT_MS:-5000}
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: refract
POSTGRES_USER: refract
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-refract_dev}
ports:
- "127.0.0.1:5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
- ./src/db/schema.sql:/docker-entrypoint-initdb.d/001-schema.sql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U refract -d refract"]
interval: 5s
timeout: 3s
retries: 10
start_period: 5s
# Ephemeral PostgreSQL instance used exclusively by the disaster-recovery
# restore drill (scripts/restore-drill.sh). It has NO persistent volume and
# is torn down after every run, so it can never hold or serve production data.
# The drill must NEVER be pointed at the production database: this service is
# the only target it is allowed to restore into.
postgres-drill:
image: postgres:16-alpine
profiles: ["drill"]
environment:
POSTGRES_DB: ${DRILL_POSTGRES_DB:-refract_drill}
POSTGRES_USER: ${DRILL_POSTGRES_USER:-refract_drill}
POSTGRES_PASSWORD: ${DRILL_POSTGRES_PASSWORD:-refract_drill}
ports:
- "127.0.0.1:${DRILL_POSTGRES_PORT:-55432}:5432"
tmpfs:
- /var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DRILL_POSTGRES_USER:-refract_drill} -d ${DRILL_POSTGRES_DB:-refract_drill}"]
interval: 5s
timeout: 3s
retries: 10
start_period: 5s
redis:
image: redis:7-alpine
command: ["redis-server", "--appendonly", "yes"]
ports:
- "127.0.0.1:6379:6379"
volumes:
- redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
backend:
build:
context: .
dockerfile: Dockerfile
# Must exceed SHUTDOWN_GRACE_PERIOD_MS so the app's own deadline fires
# before Docker sends SIGKILL (the default is only 10s).
stop_grace_period: 40s
environment:
<<: *backend-env
PORT: 4001
# API tier: serves reads and the WebSocket feed only. The payout
# pipeline runs in the `worker` service below.
PROCESS_ROLE: api
SHUTDOWN_GRACE_PERIOD_MS: ${SHUTDOWN_GRACE_PERIOD_MS:-30000}
ORACLE_SHUTDOWN_DRAIN_MS: ${ORACLE_SHUTDOWN_DRAIN_MS:-20000}
ORACLE_EVIDENCE_SPOOL_DIR: /var/lib/refract/oracle-evidence
volumes:
# Write-ahead spool for oracle evidence; must survive container restarts
# so readings taken during a Postgres outage are replayed, not lost.
- oracle-evidence:/var/lib/refract/oracle-evidence
ports:
- "4001:4001"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:4001/health/ready').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
worker:
# Oracle polling, consensus, on-chain publishing and claim settlement.
# Runs exactly one replica per relayer key (sequence numbers are managed
# in-process). Restarts independently of the API.
build:
context: .
dockerfile: Dockerfile
command: ["node", "dist/worker.js"]
environment:
<<: *backend-env
PROCESS_ROLE: worker
WORKER_HEALTH_PORT: 4002
ports:
- "127.0.0.1:4002:4002"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:4002/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
interval: 30s
timeout: 3s
retries: 3
start_period: 30s
volumes:
postgres-data:
redis-data:
oracle-evidence: