forked from StellarCheckMate/Checkmate-Escrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
242 lines (233 loc) · 8.92 KB
/
Copy pathdocker-compose.yml
File metadata and controls
242 lines (233 loc) · 8.92 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
version: '3.8'
services:
# ── Stellar standalone node (local Soroban network + RPC) ─────────────────
# Provides a throwaway local network for contract deployment and testing —
# no testnet/mainnet access needed for local full-stack development.
stellar-standalone:
image: stellar/quickstart:latest
restart: unless-stopped
command: ["--standalone", "--enable-soroban-rpc"]
ports:
- "8000:8000"
healthcheck:
test:
- "CMD-SHELL"
- >-
curl -sf -X POST http://localhost:8000/soroban/rpc
-H 'Content-Type: application/json'
-d '{"jsonrpc":"2.0","id":1,"method":"getHealth"}'
| grep -q healthy
interval: 10s
timeout: 5s
retries: 15
start_period: 30s
# ── PostgreSQL ─────────────────────────────────────────────────────────────
postgres:
image: postgres:15-alpine
restart: unless-stopped
environment:
POSTGRES_USER: event_indexer
POSTGRES_PASSWORD: event_indexer_pass
POSTGRES_DB: event_indexer
ports:
- "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U event_indexer"]
interval: 5s
timeout: 5s
retries: 5
# ── Redis (shared API response cache) ─────────────────────────────────────
# Both replicas share this cache, so an invalidation performed by the leader
# after ingesting an event is immediately visible to the follower serving
# reads. Without it each replica caches independently and can serve a stale
# response for up to one TTL after the other has invalidated.
redis:
image: redis:7-alpine
restart: unless-stopped
# Cache-only workload: no persistence, and a bounded memory footprint with
# LRU eviction so it can never grow into the host's memory.
command: >
redis-server
--save ""
--appendonly no
--maxmemory 256mb
--maxmemory-policy allkeys-lru
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
# ── Event Indexer Replica #1 (leader-eligible) ───────────────────────────
event-indexer-1:
build:
context: .
dockerfile: services/event-indexer/Dockerfile
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "8080:8080"
environment:
DATABASE_URL: postgres://event_indexer:event_indexer_pass@postgres:5432/event_indexer
REDIS_URL: ${REDIS_URL:-redis://redis:6379}
STELLAR_RPC_URL: ${STELLAR_RPC_URL:-https://soroban-testnet.stellar.org}
CONTRACT_ESCROW: ${CONTRACT_ESCROW}
EVENT_INDEXER_INSTANCE_ID: indexer-1
EVENT_INDEXER_BIND_ADDR: 0.0.0.0
EVENT_INDEXER_PORT: 8080
EVENT_INDEXER_CACHE_SIZE: ${EVENT_INDEXER_CACHE_SIZE:-10000}
EVENT_INDEXER_POLL_INTERVAL: ${EVENT_INDEXER_POLL_INTERVAL:-5}
EVENT_INDEXER_LOG_LEVEL: ${EVENT_INDEXER_LOG_LEVEL:-info}
EVENT_INDEXER_API_KEY: ${EVENT_INDEXER_API_KEY:-}
EVENT_INDEXER_LEADER_TTL_SECS: 30
EVENT_INDEXER_LEADER_HEARTBEAT_SECS: 10
EVENT_INDEXER_DB_POOL_SIZE: 5
EVENT_INDEXER_DB_READ_POOL_SIZE: 10
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 10s
timeout: 5s
retries: 3
# ── Event Indexer Replica #2 (leader-eligible) ───────────────────────────
event-indexer-2:
build:
context: .
dockerfile: services/event-indexer/Dockerfile
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "8081:8080"
environment:
DATABASE_URL: postgres://event_indexer:event_indexer_pass@postgres:5432/event_indexer
REDIS_URL: ${REDIS_URL:-redis://redis:6379}
STELLAR_RPC_URL: ${STELLAR_RPC_URL:-https://soroban-testnet.stellar.org}
CONTRACT_ESCROW: ${CONTRACT_ESCROW}
EVENT_INDEXER_INSTANCE_ID: indexer-2
EVENT_INDEXER_BIND_ADDR: 0.0.0.0
EVENT_INDEXER_PORT: 8080
EVENT_INDEXER_CACHE_SIZE: ${EVENT_INDEXER_CACHE_SIZE:-10000}
EVENT_INDEXER_POLL_INTERVAL: ${EVENT_INDEXER_POLL_INTERVAL:-5}
EVENT_INDEXER_LOG_LEVEL: ${EVENT_INDEXER_LOG_LEVEL:-info}
EVENT_INDEXER_API_KEY: ${EVENT_INDEXER_API_KEY:-}
EVENT_INDEXER_LEADER_TTL_SECS: 30
EVENT_INDEXER_LEADER_HEARTBEAT_SECS: 10
EVENT_INDEXER_DB_POOL_SIZE: 5
EVENT_INDEXER_DB_READ_POOL_SIZE: 10
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 10s
timeout: 5s
retries: 3
# ── Event Indexer Replica #3 (optional, for testing 3+ instance HA) ─────
event-indexer-3:
build:
context: .
dockerfile: services/event-indexer/Dockerfile
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "8082:8080"
environment:
DATABASE_URL: postgres://event_indexer:event_indexer_pass@postgres:5432/event_indexer
REDIS_URL: ${REDIS_URL:-redis://redis:6379}
STELLAR_RPC_URL: ${STELLAR_RPC_URL:-https://soroban-testnet.stellar.org}
CONTRACT_ESCROW: ${CONTRACT_ESCROW}
EVENT_INDEXER_INSTANCE_ID: indexer-3
EVENT_INDEXER_BIND_ADDR: 0.0.0.0
EVENT_INDEXER_PORT: 8080
EVENT_INDEXER_CACHE_SIZE: ${EVENT_INDEXER_CACHE_SIZE:-10000}
EVENT_INDEXER_POLL_INTERVAL: ${EVENT_INDEXER_POLL_INTERVAL:-5}
EVENT_INDEXER_LOG_LEVEL: ${EVENT_INDEXER_LOG_LEVEL:-info}
EVENT_INDEXER_API_KEY: ${EVENT_INDEXER_API_KEY:-}
EVENT_INDEXER_LEADER_TTL_SECS: 30
EVENT_INDEXER_LEADER_HEARTBEAT_SECS: 10
EVENT_INDEXER_DB_POOL_SIZE: 5
EVENT_INDEXER_DB_READ_POOL_SIZE: 10
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 10s
timeout: 5s
retries: 3
profiles:
- testing
# ── Oracle service (Lichess/Chess.com result submission) ─────────────────
# Requires CONTRACT_ESCROW, CONTRACT_ORACLE and ORACLE_SIGNING_KEY to be set
# in .env once contracts are deployed to stellar-standalone — see
# docs/local-dev.md for the full local deployment walkthrough.
oracle-service:
build:
context: .
dockerfile: oracle-service/Dockerfile
restart: unless-stopped
depends_on:
stellar-standalone:
condition: service_healthy
ports:
- "8095:8000"
environment:
STELLAR_RPC_URL: ${ORACLE_RPC_URL:-http://stellar-standalone:8000/soroban/rpc}
STELLAR_NETWORK: ${STELLAR_NETWORK:-standalone}
CONTRACT_ESCROW: ${CONTRACT_ESCROW}
CONTRACT_ORACLE: ${CONTRACT_ORACLE}
ORACLE_SIGNING_KEY: ${ORACLE_SIGNING_KEY}
LICHESS_API_TOKEN: ${LICHESS_API_TOKEN:-}
CHESSDOTCOM_API_KEY: ${CHESSDOTCOM_API_KEY:-}
ORACLE_POLL_INTERVAL_SECS: ${ORACLE_POLL_INTERVAL_SECS:-30}
ORACLE_MAX_RETRIES: ${ORACLE_MAX_RETRIES:-5}
ORACLE_RETRY_BASE_DELAY_SECS: ${ORACLE_RETRY_BASE_DELAY_SECS:-10}
ORACLE_RECONCILIATION_INTERVAL_SECS: ${ORACLE_RECONCILIATION_INTERVAL_SECS:-60}
ORACLE_QUEUE_DIR: /data/oracle-queue
volumes:
- oracle-queue-data:/data/oracle-queue
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 10s
timeout: 5s
retries: 3
# ── WebSocket server (real-time match events) ────────────────────────────
websocket-server:
build:
context: services/websocket-server
dockerfile: Dockerfile
restart: unless-stopped
depends_on:
event-indexer-1:
condition: service_healthy
ports:
- "8090:8090"
environment:
WS_PORT: 8090
WS_HOST: 0.0.0.0
EVENT_INDEXER_URL: http://event-indexer-1:8080
WS_POLL_INTERVAL_MS: ${WS_POLL_INTERVAL_MS:-5000}
WS_HEARTBEAT_INTERVAL_MS: ${WS_HEARTBEAT_INTERVAL_MS:-30000}
WS_HEARTBEAT_TIMEOUT_MS: ${WS_HEARTBEAT_TIMEOUT_MS:-60000}
WS_RATE_LIMIT_MAX_SUBSCRIBES: ${WS_RATE_LIMIT_MAX_SUBSCRIBES:-20}
WS_RATE_LIMIT_WINDOW_MS: ${WS_RATE_LIMIT_WINDOW_MS:-60000}
WS_MAX_SUBSCRIPTIONS_PER_CLIENT: ${WS_MAX_SUBSCRIPTIONS_PER_CLIENT:-50}
LOG_LEVEL: ${WS_LOG_LEVEL:-info}
healthcheck:
test: ["CMD", "node", "-e", "require('net').createConnection(8090,'localhost').on('connect',()=>process.exit(0)).on('error',()=>process.exit(1))"]
interval: 10s
timeout: 5s
retries: 3
volumes:
postgres-data:
driver: local
oracle-queue-data:
driver: local