-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.ha.yml
More file actions
171 lines (160 loc) · 4.24 KB
/
docker-compose.ha.yml
File metadata and controls
171 lines (160 loc) · 4.24 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
version: '3.8'
services:
# Redis - 分布式锁
redis:
image: redis:7-alpine
container_name: quantmesh_redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redis_data:/data
command: redis-server --appendonly yes
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 3
networks:
- quantmesh
# PostgreSQL - 共享数据库
postgres:
image: postgres:15-alpine
container_name: quantmesh_postgres
restart: unless-stopped
environment:
POSTGRES_USER: quantmesh
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
POSTGRES_DB: quantmesh
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U quantmesh"]
interval: 10s
timeout: 3s
retries: 3
networks:
- quantmesh
# QuantMesh 实例 1
quantmesh-1:
image: quantmesh/market-maker:latest
container_name: quantmesh_instance_1
restart: unless-stopped
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
environment:
- INSTANCE_ID=instance-1
- INSTANCE_INDEX=0
- DATABASE_TYPE=postgres
- DATABASE_DSN=host=postgres user=quantmesh password=${POSTGRES_PASSWORD:-changeme} dbname=quantmesh port=5432 sslmode=disable
- REDIS_ADDR=redis:6379
- HTTPS_PROXY=${HTTPS_PROXY:-}
volumes:
- ./config-instance1.yaml:/app/config.yaml:ro
- instance1_data:/app/data
- instance1_logs:/app/logs
ports:
- "28881:28888"
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:28888/api/status"]
interval: 30s
timeout: 10s
retries: 3
networks:
- quantmesh
# QuantMesh 实例 2
quantmesh-2:
image: quantmesh/market-maker:latest
container_name: quantmesh_instance_2
restart: unless-stopped
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
environment:
- INSTANCE_ID=instance-2
- INSTANCE_INDEX=1
- DATABASE_TYPE=postgres
- DATABASE_DSN=host=postgres user=quantmesh password=${POSTGRES_PASSWORD:-changeme} dbname=quantmesh port=5432 sslmode=disable
- REDIS_ADDR=redis:6379
- HTTPS_PROXY=${HTTPS_PROXY:-}
volumes:
- ./config-instance2.yaml:/app/config.yaml:ro
- instance2_data:/app/data
- instance2_logs:/app/logs
ports:
- "28882:28888"
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:28888/api/status"]
interval: 30s
timeout: 10s
retries: 3
networks:
- quantmesh
# QuantMesh 实例 3 (热备)
quantmesh-3:
image: quantmesh/market-maker:latest
container_name: quantmesh_instance_3
restart: unless-stopped
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
environment:
- INSTANCE_ID=instance-3
- INSTANCE_INDEX=2
- DATABASE_TYPE=postgres
- DATABASE_DSN=host=postgres user=quantmesh password=${POSTGRES_PASSWORD:-changeme} dbname=quantmesh port=5432 sslmode=disable
- REDIS_ADDR=redis:6379
- HTTPS_PROXY=${HTTPS_PROXY:-}
- STANDBY_MODE=true
volumes:
- ./config-instance3.yaml:/app/config.yaml:ro
- instance3_data:/app/data
- instance3_logs:/app/logs
ports:
- "28883:28888"
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:28888/api/status"]
interval: 30s
timeout: 10s
retries: 3
networks:
- quantmesh
# Nginx 负载均衡
nginx:
image: nginx:alpine
container_name: quantmesh_nginx
restart: unless-stopped
depends_on:
- quantmesh-1
- quantmesh-2
- quantmesh-3
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
networks:
- quantmesh
volumes:
redis_data:
postgres_data:
instance1_data:
instance1_logs:
instance2_data:
instance2_logs:
instance3_data:
instance3_logs:
networks:
quantmesh:
driver: bridge