-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
415 lines (402 loc) · 12.5 KB
/
docker-compose.yml
File metadata and controls
415 lines (402 loc) · 12.5 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
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
services:
traefik:
profiles: ["studio"]
image: traefik:v3.6
command:
# Core configuration
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.file.filename=/etc/traefik/tls.yml"
- "--providers.file.watch=true"
# Entrypoints for local development
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443" # Needed for frontend/hardhat labels
# API Dashboard (for local dev monitoring)
- "--api.dashboard=true"
# Extended timeouts for large contract state loading (20 minutes to match GenVM timeout)
- "--entryPoints.web.transport.respondingTimeouts.readTimeout=1200s"
- "--entryPoints.web.transport.respondingTimeouts.writeTimeout=1200s"
- "--entryPoints.web.transport.respondingTimeouts.idleTimeout=1200s"
- "--entryPoints.websecure.transport.respondingTimeouts.readTimeout=1200s"
- "--entryPoints.websecure.transport.respondingTimeouts.writeTimeout=1200s"
- "--entryPoints.websecure.transport.respondingTimeouts.idleTimeout=1200s"
# Server transport with extended forwarding timeouts
- "--serversTransport.forwardingTimeouts.responseHeaderTimeout=1200s"
- "--serversTransport.forwardingTimeouts.idleConnTimeout=1200s"
ports:
- "80:80"
- "443:443"
- "8081:8080" # Traefik dashboard (8081 to avoid conflict with frontend on 8080)
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /opt/genlayer-studio/nginx/ssl/:/etc/ssl/traefik:ro
- ./traefik/tls.yml:/etc/traefik/tls.yml:ro
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "10"
frontend:
build:
context: ./
dockerfile: ./docker/Dockerfile.frontend
target: ${FRONTEND_BUILD_TARGET:-final}
ports:
- "${FRONTEND_PORT}:8080"
volumes:
- ./examples:/app/src/assets/examples
- ./frontend/src:/app/src
depends_on:
jsonrpc:
condition: service_healthy
expose:
- "${FRONTEND_PORT}"
environment:
- VITE_GENLAYER_NETWORK=${VITE_GENLAYER_NETWORK}
- VITE_JSON_RPC_SERVER_URL=${VITE_JSON_RPC_SERVER_URL}
- VITE_WS_SERVER_URL=${VITE_WS_SERVER_URL}
- VITE_IS_HOSTED=${VITE_IS_HOSTED}
- VITE_FINALITY_WINDOW=${VITE_FINALITY_WINDOW}
- VITE_FINALITY_WINDOW_APPEAL_FAILED_REDUCTION=${VITE_FINALITY_WINDOW_APPEAL_FAILED_REDUCTION}
- VITE_MAX_ROTATIONS=${VITE_MAX_ROTATIONS}
- VITE_PLAUSIBLE_DOMAIN=${VITE_PLAUSIBLE_DOMAIN}
- VITE_APPKIT_PROJECT_ID=${VITE_APPKIT_PROJECT_ID}
restart: always
security_opt:
- "no-new-privileges=true"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
labels:
traefik.enable: true
traefik.http.routers.frontend.rule: Host(`${SERVER_NAME}`)
traefik.http.routers.frontend.entrypoints: websecure
traefik.http.routers.frontend.tls: true
explorer:
build:
context: ./
dockerfile: ./docker/Dockerfile.explorer
target: ${EXPLORER_BUILD_TARGET:-final}
ports:
- "${EXPLORER_PORT:-3001}:3000"
volumes:
- ./explorer/src:/app/src
depends_on:
jsonrpc:
condition: service_healthy
environment:
- BACKEND_URL=http://jsonrpc:4000
restart: always
security_opt:
- "no-new-privileges=true"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
jsonrpc:
build:
context: ./
dockerfile: ./docker/Dockerfile.backend
target: prod
environment:
- PYTHONUNBUFFERED=1
- WEBDRIVERHOST=${WEBDRIVERHOST}
- WEBDRIVERPORT=${WEBDRIVERPORT}
- REDIS_URL=${REDIS_URL:-redis://redis:6379/0}
- WEB_CONCURRENCY=${WEB_CONCURRENCY:-1}
- DATABASE_POOL_SIZE=${DATABASE_POOL_SIZE:-20}
- DATABASE_MAX_OVERFLOW=${DATABASE_MAX_OVERFLOW:-10}
- LOG_LEVEL=${LOG_LEVEL:-info}
- GENVMROOT=/genvm
- RATE_LIMIT_ENABLED=${RATE_LIMIT_ENABLED:-false}
- RATE_LIMIT_ANON_PER_MINUTE=${RATE_LIMIT_ANON_PER_MINUTE:-30}
- RATE_LIMIT_ANON_PER_HOUR=${RATE_LIMIT_ANON_PER_HOUR:-500}
- RATE_LIMIT_ANON_PER_DAY=${RATE_LIMIT_ANON_PER_DAY:-5000}
ports:
- "${RPCPORT}:${RPCPORT}"
expose:
- "${RPCPORT}"
volumes:
- ./.env:/app/.env
- ./backend:/app/backend
# - hardhat_artifacts:/app/hardhat/artifacts
# - hardhat_deployments:/app/hardhat/deployments
depends_on:
traefik:
condition: service_started
required: false
database-migration:
condition: service_completed_successfully
webdriver:
condition: service_healthy
redis:
condition: service_healthy
# hardhat:
# condition: service_healthy
# required: false
ollama:
condition: service_started
required: false
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${RPCPORT}/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 300s
restart: always
security_opt:
- "no-new-privileges=true"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
mem_limit: ${COMPOSE_RPC_MEM_LIMIT:-8g}
mem_reservation: ${COMPOSE_RPC_MEM_RESERVATION:-2g}
memswap_limit: ${COMPOSE_RPC_MEM_SWAP_LIMIT:-8g}
oom_kill_disable: false
deploy:
replicas: ${JSONRPC_REPLICAS:-3}
resources:
limits:
cpus: '${COMPOSE_RPC_CPU_LIMIT:-2}'
memory: ${COMPOSE_RPC_MEM_LIMIT:-8g}
reservations:
cpus: ${COMPOSE_RPC_CPU_RESERVATION:-1}
memory: ${COMPOSE_RPC_MEM_RESERVATION:-2g}
labels:
traefik.enable: true
# Define service with port
traefik.http.services.jsonrpc.loadbalancer.server.port: ${RPCPORT}
# HTTPS router for main API
traefik.http.routers.jsonrpc.rule: Host(`${SERVER_NAME}`) && (PathPrefix(`/api`) || PathPrefix(`/socket.io`) || PathPrefix(`/ws`) || PathPrefix(`/monitoring`))
traefik.http.routers.jsonrpc.entrypoints: websecure
traefik.http.routers.jsonrpc.tls: true
traefik.http.routers.jsonrpc.service: jsonrpc
# HTTP router for health endpoints (no TLS required)
traefik.http.routers.jsonrpc-health.rule: Host(`${SERVER_NAME}`) && (PathPrefix(`/health`) || PathPrefix(`/ready`) || PathPrefix(`/metrics`))
traefik.http.routers.jsonrpc-health.entrypoints: web
traefik.http.routers.jsonrpc-health.service: jsonrpc
webdriver:
image: yeagerai/genlayer-genvm-webdriver:0.0.9
shm_size: 2gb
environment:
- PORT=${WEBDRIVERPORT:-4444}
expose:
- "${WEBDRIVERPORT:-4444}"
restart: always
security_opt:
- "no-new-privileges=true"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
mem_limit: 16g
mem_reservation: 2g
memswap_limit: 24g
oom_kill_disable: false
deploy:
resources:
limits:
cpus: 2
memory: 16g
reservations:
cpus: 1
memory: 2g
ollama:
profiles: ["ollama"]
image: ollama/ollama:0.17.6
ports:
- 11434:11434
volumes:
- ./.ollama:/root/.ollama
container_name: ollama
tty: true
restart: always
security_opt:
- "no-new-privileges=true"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
postgres:
image: postgres:16-alpine
command: sh -c "if [ \"$REMOTE_DATABASE\" = \"true\" ]; then echo 'Postgres disabled in hosted environment' && exec tail -f /dev/null; else exec docker-entrypoint.sh postgres; fi"
ports:
- "${DBPORT}:5432"
environment:
- POSTGRES_USER=${DBUSER}
- POSTGRES_PASSWORD=${DBPASSWORD}
- POSTGRES_DB=${DBNAME}
- REMOTE_DATABASE=${REMOTE_DATABASE}
healthcheck:
test: if [ "$REMOTE_DATABASE" = "true" ]; then exit 0; else pg_isready -U ${DBUSER} -d ${DBNAME}; fi
interval: 10s
timeout: 3s
retries: 3
restart: always
security_opt:
- "no-new-privileges=true"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Database data - use 'docker compose down -v' to wipe
volumes:
- postgres_data:/var/lib/postgresql/data
database-migration:
build:
context: .
dockerfile: docker/Dockerfile.database-migration
environment:
- DBUSER=${DBUSER}
- DBPASSWORD=${DBPASSWORD}
- DBHOST=${DBHOST}
- DBPORT=${DBPORT}
- DBNAME=${DBNAME}
depends_on:
postgres:
condition: service_healthy
required: false
consensus-worker:
build:
context: ./
dockerfile: ./docker/Dockerfile.consensus-worker
target: ${CONSENSUS_BUILD_TARGET:-base}
environment:
- DBUSER=${DBUSER}
- DBPASSWORD=${DBPASSWORD}
- DBHOST=${DBHOST}
- DBNAME=${DBNAME}
- WORKER_PORT=4001
- WORKER_POLL_INTERVAL=${WORKER_POLL_INTERVAL:-5}
- TRANSACTION_TIMEOUT_MINUTES=${TRANSACTION_TIMEOUT_MINUTES:-30}
- LOG_LEVEL=${LOG_LEVEL:-info}
- WEBDRIVERHOST=${WEBDRIVERHOST}
- WEBDRIVERPORT=${WEBDRIVERPORT}
- REDIS_URL=${REDIS_URL:-redis://redis:6379/0}
volumes:
- ./.env:/app/.env
- ./backend:/app/backend
depends_on:
database-migration:
condition: service_completed_successfully
webdriver:
condition: service_healthy
redis:
condition: service_healthy
ollama:
condition: service_started
required: false
jsonrpc:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4001/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 180s
mem_limit: ${COMPOSE_WORKER_MEM_LIMIT:-8g}
mem_reservation: ${COMPOSE_WORKER_MEM_RESERVATION:-2g}
memswap_limit: ${COMPOSE_WORKER_MEM_SWAP_LIMIT:-8g}
oom_kill_disable: false
deploy:
replicas: ${CONSENSUS_WORKERS:-1} # Minimum 1 worker required for consensus processing
restart_policy:
condition: on-failure # Only restart on failure (not on clean exit)
delay: 5s
max_attempts: 0
window: 120s
resources:
limits:
cpus: '${COMPOSE_WORKER_CPU_LIMIT:-2}'
memory: ${COMPOSE_WORKER_MEM_LIMIT:-8g}
reservations:
cpus: ${COMPOSE_WORKER_CPU_RESERVATION:-1}
memory: ${COMPOSE_WORKER_MEM_RESERVATION:-2g}
restart: unless-stopped
security_opt:
- "no-new-privileges=true"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# hardhat:
# profiles: ["hardhat"]
# build:
# context: .
# dockerfile: docker/Dockerfile.hardhat
# ports:
# - "${HARDHAT_PORT:-8545}:8545"
# env_file:
# - .env
# volumes:
# - ./hardhat:/app/hardhat_src
# - hardhat_artifacts:/app/artifacts
# - hardhat_cache:/app/cache
# - hardhat_deployments:/app/deployments
# - hardhat_snapshots:/app/snapshots
# restart: always
# logging:
# driver: "json-file"
# options:
# max-size: "50m"
# max-file: "10"
# # For local dev, hardhat is accessed directly on its port
redis:
image: redis:8-alpine
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 3
restart: always
security_opt:
- "no-new-privileges=true"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
vector:
profiles: ["monitoring"] # Only run when monitoring is needed
image: timberio/vector:0.53.0-alpine
container_name: vector
environment:
- GOOGLE_APPLICATION_CREDENTIALS=/etc/vector/gcp_credentials.json
- VECTOR_LOG=info
- GCP_PROJECT_ID=${GCP_PROJECT_ID}
- SERVER_NAME=${SERVER_NAME}
volumes:
- ./vector.yaml:/etc/vector/vector.yaml:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./gcp_credentials.json:/etc/vector/gcp_credentials.json:ro
- /var/log:/var/log:ro # Mount the host's /var/log directory
# network_mode: host
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
labels:
org.label-schema.group: "monitoring"
volumes:
# hardhat_artifacts:
# hardhat_cache:
# hardhat_deployments:
ignition_deployments:
# hardhat_snapshots:
postgres_data:
redis_data: