-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocker-compose.multi.yml
More file actions
84 lines (78 loc) · 2.2 KB
/
docker-compose.multi.yml
File metadata and controls
84 lines (78 loc) · 2.2 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
# PyClaw multi-worker deployment.
#
# 3 active-active workers behind nginx (ip_hash + Session Affinity Gateway),
# Redis as shared session/affinity/lock store, healthcheck on every service.
#
# Usage:
# cp deploy/.env.example deploy/.env
# # edit deploy/.env to set PYCLAW_WEB_JWT_SECRET / admin password / API keys
# docker compose -f deploy/docker-compose.multi.yml --env-file deploy/.env up -d
#
# Single entry point: http://localhost (nginx proxies to the 3 workers).
#
# To scale up: change replicas + add to nginx upstream block in deploy/nginx.conf.
services:
worker1: &worker
build:
context: ..
dockerfile: Dockerfile
image: pyclaw:latest
environment:
PYCLAW_STORAGE_SESSION_BACKEND: redis
PYCLAW_STORAGE_LOCK_BACKEND: redis
PYCLAW_REDIS_HOST: redis
PYCLAW_AFFINITY_ENABLED: "true"
PYCLAW_WEB_JWT_SECRET: ${PYCLAW_WEB_JWT_SECRET}
PYCLAW_WEB_ADMIN_TOKEN: ${PYCLAW_WEB_ADMIN_TOKEN}
volumes:
- ../configs:/app/configs:ro
- pyclaw-workspaces:/app/workspaces
- pyclaw-memory:/root/.pyclaw/memory
depends_on:
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-fsS", "http://localhost:8000/health"]
interval: 15s
timeout: 3s
retries: 4
start_period: 30s
restart: unless-stopped
worker2:
<<: *worker
worker3:
<<: *worker
redis:
image: redis:7-alpine
command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
volumes:
- redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 5
restart: unless-stopped
nginx:
image: nginx:alpine
ports:
- "${PYCLAW_NGINX_PORT:-80}:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
worker1:
condition: service_healthy
worker2:
condition: service_healthy
worker3:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost/health"]
interval: 15s
timeout: 3s
retries: 4
restart: unless-stopped
volumes:
redis-data:
pyclaw-workspaces:
pyclaw-memory: