-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdocker-compose.yml
432 lines (407 loc) · 12.2 KB
/
docker-compose.yml
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
volumes:
node-data: {}
postgres_db: {}
redis_db: {}
caddy_config: {}
caddy_data: {}
services:
# Caddy Reverse Proxy with CORS enabled
caddy:
ulimits:
nofile:
soft: 65536 # Soft limit for open files (WebSocket connections count)
hard: 65536 # Hard limit for open files
image: caddy:latest
ports:
- "127.0.0.1:8000:8000"
volumes:
- ./indexers/Caddyfile:/etc/caddy/Caddyfile # Mount the Caddyfile
- caddy_data:/data # Volume for Let's Encrypt certificates
- caddy_config:/config
depends_on:
- node
restart: unless-stopped
# Subspace Node
node:
image: ghcr.io/autonomys/node:${NODE_DOCKER_TAG}
volumes:
- node-data:/var/subspace:rw
ports:
- "30333:30333/tcp"
- "30433:30433/tcp"
- "127.0.0.1:9944:9944/tcp"
restart: unless-stopped
command:
[
"run",
"--chain",
"${NETWORK_ID}",
"--base-path",
"/var/subspace",
"--state-pruning",
"archive",
"--blocks-pruning",
"archive",
"--listen-on",
"/ip4/0.0.0.0/tcp/30333",
"--dsn-listen-on",
"/ip4/0.0.0.0/tcp/30433",
"--rpc-cors",
"all",
"--rpc-methods",
"unsafe",
"--rpc-listen-on",
"0.0.0.0:9944",
"--rpc-max-subscriptions-per-connection",
"1000",
"--rpc-max-connections",
"20000",
"--name",
"astral",
"--sync",
"full",
]
healthcheck:
timeout: 5s
interval: 30s
retries: 60
# Postgres Database
postgres:
image: postgres:16-alpine
volumes:
- postgres_db:/var/lib/postgresql/data
- ./indexers/db/docker-entrypoint-initdb.d/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
- ./indexers/db/postgresql.conf:/etc/postgresql/postgresql.conf
restart: unless-stopped
hostname: postgres
shm_size: 8g
environment:
POSTGRES_DB: ${DB_DATABASE}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_MAX_CONNECTIONS: 500
ports:
- "${DB_PORT}:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
command: ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
# Hasura GraphQL Engine
hasura:
image: hasura/graphql-engine:v2.40.0
depends_on:
postgres:
condition: service_healthy
volumes:
- ./indexers/db/migrations:/hasura-migrations
- ./indexers/db/metadata:/hasura-metadata
restart: unless-stopped
environment:
# Essential Environment Variables
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:5432/${DB_DATABASE}
HASURA_GRAPHQL_DATABASE_URL: postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:5432/${DB_DATABASE} # Main database connection
HASURA_GRAPHQL_ADMIN_SECRET: ${HASURA_GRAPHQL_ADMIN_SECRET} # Admin access secret
HASURA_GRAPHQL_JWT_SECRET: ${HASURA_GRAPHQL_JWT_SECRET} # JWT authentication secret
# Console and Development Mode
HASURA_GRAPHQL_ENABLE_CONSOLE: ${HASURA_GRAPHQL_ENABLE_CONSOLE} # Disable console in production
HASURA_GRAPHQL_DEV_MODE: "true" # Disable development mode features
# Role and CORS Settings
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: user # Default role for unauthenticated users
HASURA_GRAPHQL_CORS_DOMAIN: ${HASURA_GRAPHQL_CORS_DOMAIN} # Allowed domains for CORS
HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES: "true"
# Performance and Connection Settings
HASURA_GRAPHQL_MAX_CONNECTIONS: 100 # Maximum number of database connections
HASURA_GRAPHQL_STRIPES: 2 # Number of connection pool stripes
HASURA_GRAPHQL_CONNECTIONS_PER_STRIPE: 50 # Connections per stripe
HASURA_GRAPHQL_IDLE_TIMEOUT: 180 # Idle connection timeout in seconds
HASURA_GRAPHQL_TIMEOUT: 60 # Request timeout in seconds
HASURA_GRAPHQL_ENABLE_QUERY_CACHE: true # Enable query caching
# Subscriptions
HASURA_GRAPHQL_ENABLE_SUBSCRIPTIONS: true # Enable subscriptions
HASURA_GRAPHQL_ENABLE_WEBSOCKETS: true # Enable WebSockets
HASURA_GRAPHQL_SUBSCRIPTIONS_PER_STRIPE: 10 # Subscriptions per stripe
HASURA_GRAPHQL_SUBSCRIPTIONS_TIMEOUT: 180 # Subscription timeout in seconds
# HASURA_GRAPHQL_WS_READ_COOKIE: true # Read cookies over WebSockets
# Logging Settings
HASURA_GRAPHQL_LOG_LEVEL: "warn" # Log verbosity level
HASURA_GRAPHQL_ENABLED_LOG_TYPES: "startup,http-log,webhook-log,websocket-log,query-log" # Enabled log types
# Security and Authorization
HASURA_GRAPHQL_ENABLE_ALLOWLIST: "false" # Disable query allowlisting
# Hasura Migrations and Metadata
HASURA_GRAPHQL_MIGRATIONS_DIR: /hasura-migrations
HASURA_GRAPHQL_METADATA_DIR: /hasura-metadata
# Task Board Action Endpoint
HASURA_GRAPHQL_ACTION_TASK_BOARD: http://taskboard:${BULL_PORT}
HASURA_GRAPHQL_ACTION_TASK_BOARD_SESSION_SECRET: ${BULL_SESSION_SECRET}
ports:
- "${HASURA_GRAPHQL_PORT}:8080"
command:
- graphql-engine
- serve
dictionary_subquery_node:
profiles: [dictionary, indexers]
build:
context: ./indexers/dictionary/${DICTIONARY_DIRECTORY}
depends_on:
"postgres":
condition: service_healthy
restart: unless-stopped
environment:
DB_USER: ${DB_USER}
DB_PASS: ${DB_PASSWORD}
DB_DATABASE: ${DB_DATABASE}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
volumes:
- ./indexers/dictionary/${DICTIONARY_DIRECTORY}:/dictionary
healthcheck:
test: ["CMD", "curl", "-f", "http://dictionary_subquery_node:3000/ready"]
interval: 3s
timeout: 5s
retries: 10
command:
- -f=/dictionary
- --disable-historical=true
dictionary_graphql_engine:
profiles: [dictionary, indexers]
image: onfinality/subql-query:latest
ports:
- "127.0.0.1:${DICTIONARY_SUBQUERY_NODE_PORT}:3000"
depends_on:
"postgres":
condition: service_healthy
"dictionary_subquery_node":
condition: service_healthy
restart: unless-stopped
environment:
DB_USER: ${DB_USER}
DB_PASS: ${DB_PASSWORD}
DB_DATABASE: ${DB_DATABASE}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
command:
- --name=dictionary
- --playground
# Indexers Subquery Nodes
consensus_subquery_node:
profiles: [indexers]
image: subquerynetwork/subql-node-substrate:latest
ports:
- "127.0.0.1:3001:3000"
depends_on:
"postgres":
condition: service_healthy
restart: unless-stopped
environment:
ENDPOINT: ${RPC_URLS}
CHAIN_ID: ${CHAIN_ID}
DB_USER: ${DB_USER}
DB_PASS: ${DB_PASSWORD}
DB_DATABASE: ${DB_DATABASE}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
volumes:
- ./indexers/consensus:/consensus
command:
- ${SUB_COMMAND:-} # set SUB_COMMAND env variable to "test" to run tests
- -f=/consensus
- --db-schema=consensus
- --workers=4
- --unsafe
- --batch-size=250
- --scale-batch-size
- --unfinalized-blocks=true
- --disable-historical=false
# - --profiler
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/ready"]
interval: 3s
timeout: 5s
retries: 10
leaderboard_subquery_node:
profiles: [indexers]
image: subquerynetwork/subql-node-substrate:latest
ports:
- "127.0.0.1:3002:3000"
depends_on:
"postgres":
condition: service_healthy
"dictionary_subquery_node":
condition: service_healthy
restart: unless-stopped
environment:
ENDPOINT: ${RPC_URLS}
CHAIN_ID: ${CHAIN_ID}
DICTIONARY: ${DICTIONARY_URL}
DB_USER: ${DB_USER}
DB_PASS: ${DB_PASSWORD}
DB_DATABASE: ${DB_DATABASE}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
volumes:
- ./indexers/leaderboard:/leaderboard
command:
- ${SUB_COMMAND:-} # set SUB_COMMAND env variable to "test" to run tests
- -f=/leaderboard
- --db-schema=leaderboard
- --workers=1
- --batch-size=100
- --scale-batch-size
- --unfinalized-blocks=true
- --disable-historical=false
# - --profiler
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/ready"]
interval: 3s
timeout: 5s
retries: 10
staking_subquery_node:
profiles: [indexers]
image: subquerynetwork/subql-node-substrate:latest
ports:
- "127.0.0.1:3003:3000"
depends_on:
"postgres":
condition: service_healthy
"dictionary_subquery_node":
condition: service_healthy
restart: unless-stopped
environment:
ENDPOINT: ${RPC_URLS}
CHAIN_ID: ${CHAIN_ID}
DICTIONARY: ${DICTIONARY_URL}
DB_USER: ${DB_USER}
DB_PASS: ${DB_PASSWORD}
DB_DATABASE: ${DB_DATABASE}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
volumes:
- ./indexers/staking:/staking
command:
- ${SUB_COMMAND:-} # set SUB_COMMAND env variable to "test" to run tests
- -f=/staking
- --db-schema=staking
- --workers=1
- --unsafe
- --batch-size=100
- --scale-batch-size
- --disable-historical=true
# - --profiler
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/ready"]
interval: 3s
timeout: 5s
retries: 10
files_subquery_node:
profiles: [indexers]
image: subquerynetwork/subql-node-substrate:latest
ports:
- "127.0.0.1:3004:3000"
depends_on:
"postgres":
condition: service_healthy
restart: unless-stopped
environment:
ENDPOINT: ${RPC_URLS}
CHAIN_ID: ${CHAIN_ID}
DB_USER: ${DB_USER}
DB_PASS: ${DB_PASSWORD}
DB_DATABASE: ${DB_DATABASE}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
volumes:
- ./indexers/files:/files
command:
- ${SUB_COMMAND:-} # set SUB_COMMAND env variable to "test" to run tests
- -f=/files
- --db-schema=files
- --workers=1
- --unsafe
- --batch-size=25
- --scale-batch-size
- --unfinalized-blocks=true
- --disable-historical=false
# - --profiler
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/ready"]
interval: 3s
timeout: 5s
retries: 10
# Redis
redis:
profiles: [task]
image: redis:latest
restart: unless-stopped
ports:
- "${REDIS_PORT}:6379"
volumes:
- redis_db:/data
hostname: redis
command: ["redis-server", "--bind", "0.0.0.0", "--port", "6379"]
healthcheck:
test:
[
"CMD-SHELL",
"redis-cli -h localhost -p 6379 ping | grep PONG || exit 1",
]
interval: 5s
timeout: 5s
retries: 10
# Express + BullMQ
taskboard:
profiles: [task]
build:
context: ./indexers/taskboard
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- ./indexers/taskboard:/app
hostname: taskboard
restart: unless-stopped
ports:
- "${BULL_PORT}:${BULL_PORT}"
environment:
BULL_USERNAME: ${BULL_USERNAME}
BULL_PASSWORD: ${BULL_PASSWORD}
BULL_PORT: ${BULL_PORT}
BULL_SESSION_SECRET: ${BULL_SESSION_SECRET}
REDIS_HOST: redis
REDIS_PORT: ${REDIS_PORT}
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_PASSWORD}
DB_DATABASE: ${DB_DATABASE}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
NETWORK_ID: ${NETWORK_ID}
LOG_LEVEL: ${LOG_LEVEL}
SLACK_TOKEN: ${SLACK_TOKEN}
SLACK_CONVERSATION_ID: ${SLACK_CONVERSATION_ID}
# NestJS API Service
api:
build:
context: ./indexers/api
dockerfile: Dockerfile
depends_on:
postgres:
condition: service_healthy
hasura:
condition: service_started
restart: unless-stopped
ports:
- "${API_PORT}:3000"
environment:
NODE_ENV: ${NODE_ENV}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_PASSWORD}
DB_DATABASE: ${DB_DATABASE}
hostname: api
volumes:
- ./indexers/api:/app
- /app/node_modules