-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
286 lines (276 loc) · 7.08 KB
/
docker-compose.prod.yml
File metadata and controls
286 lines (276 loc) · 7.08 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
# VocaTa生产环境 Docker Compose 配置
x-app-common: &app-common
restart: unless-stopped
networks:
- vocata-network
environment:
- TZ=Asia/Shanghai
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
x-healthcheck-web: &healthcheck-web
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
services:
# 后端服务
vocata-server:
<<: *app-common
image: ${SERVER_IMAGE:-ghcr.io/leivik/vocata-server:latest}
container_name: vocata-server
ports:
- "${SERVER_PORT:-9009}:9009"
environment:
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE:-prod}
- SERVER_PORT=9009
# 数据库配置
- DB_HOST=${DB_HOST}
- DB_PORT=${DB_PORT:-5432}
- DB_NAME=${DB_NAME}
- DB_USERNAME=${DB_USERNAME}
- DB_PASSWORD=${DB_PASSWORD}
# Redis配置
- REDIS_HOST=${REDIS_HOST}
- REDIS_PORT=${REDIS_PORT:-6379}
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_DATABASE=${REDIS_DATABASE:-0}
# 七牛云配置
- QINIU_ACCESS_KEY=${QINIU_ACCESS_KEY}
- QINIU_SECRET_KEY=${QINIU_SECRET_KEY}
- QINIU_BUCKET=${QINIU_BUCKET}
- QINIU_DOMAIN=${QINIU_DOMAIN}
- QINIU_REGION=${QINIU_REGION}
# 邮箱配置
- EMAIL_USER_NAME=${EMAIL_USER_NAME}
- EMAIL_USER_PASSWORD=${EMAIL_USER_PASSWORD}
# AI服务配置
- AI_LLM_PROVIDER=${AI_LLM_PROVIDER:-qiniu}
- QINIU_AI_API_KEY=${QINIU_AI_API_KEY}
- QINIU_AI_BASE_URL=${QINIU_AI_BASE_URL:-https://openai.qiniu.com/v1}
- QINIU_AI_MODEL=${QINIU_AI_MODEL:-x-ai/grok-4-fast}
- QINIU_AI_TIMEOUT=${QINIU_AI_TIMEOUT:-60}
- GEMINI_API_KEY=${GEMINI_API_KEY}
- OPENAI_API_KEY=${OPENAI_API_KEY}
# JVM优化配置
- JAVA_OPTS=-Xms1g -Xmx3g -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+OptimizeStringConcat
- TZ=Asia/Shanghai
volumes:
- server-logs:/var/log/vocata
- server-uploads:/app/uploads
- /etc/localtime:/etc/localtime:ro
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9009/api/health"]
interval: 30s
timeout: 15s
retries: 5
start_period: 120s
deploy:
resources:
limits:
memory: 4G
cpus: '2.0'
reservations:
memory: 1G
cpus: '1.0'
restart_policy:
condition: on-failure
delay: 10s
max_attempts: 3
window: 120s
# 前端客户端
vocata-web:
<<: *app-common
image: ${WEB_IMAGE:-ghcr.io/leivik/vocata-web:latest}
container_name: vocata-web
ports:
- "${WEB_PORT:-8080}:8080"
volumes:
- web-logs:/var/log/nginx
- /etc/localtime:/etc/localtime:ro
healthcheck: *healthcheck-web
depends_on:
vocata-server:
condition: service_healthy
deploy:
resources:
limits:
memory: 512M
cpus: '1.0'
reservations:
memory: 128M
cpus: '0.2'
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
# 管理后台
vocata-admin:
<<: *app-common
image: ${ADMIN_IMAGE:-ghcr.io/leivik/vocata-admin:latest}
container_name: vocata-admin
ports:
- "${ADMIN_PORT:-8081}:8080"
volumes:
- admin-logs:/var/log/nginx
- /etc/localtime:/etc/localtime:ro
healthcheck: *healthcheck-web
depends_on:
vocata-server:
condition: service_healthy
deploy:
resources:
limits:
memory: 512M
cpus: '1.0'
reservations:
memory: 128M
cpus: '0.2'
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
# Nginx反向代理
nginx:
<<: *app-common
image: nginx:1.25-alpine
container_name: vocata-nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/prod.conf:/etc/nginx/conf.d/default.conf:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
- ./nginx/includes:/etc/nginx/includes:ro
- nginx-logs:/var/log/nginx
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
depends_on:
- vocata-server
- vocata-web
- vocata-admin
deploy:
resources:
limits:
memory: 256M
cpus: '1.0'
reservations:
memory: 64M
cpus: '0.2'
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
# 监控服务 - Prometheus
prometheus:
<<: *app-common
image: prom/prometheus:v2.47.0
container_name: vocata-prometheus
ports:
- "${PROMETHEUS_PORT:-9090}:9090"
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=30d'
- '--web.enable-lifecycle'
depends_on:
- vocata-server
deploy:
resources:
limits:
memory: 1G
cpus: '1.0'
reservations:
memory: 256M
cpus: '0.2'
profiles:
- monitoring
# 监控可视化 - Grafana
grafana:
<<: *app-common
image: grafana/grafana:10.1.0
container_name: vocata-grafana
ports:
- "${GRAFANA_PORT:-3002}:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin123}
- GF_USERS_ALLOW_SIGN_UP=false
- GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource
- TZ=Asia/Shanghai
volumes:
- grafana-data:/var/lib/grafana
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning:ro
depends_on:
- prometheus
deploy:
resources:
limits:
memory: 512M
cpus: '1.0'
reservations:
memory: 128M
cpus: '0.2'
profiles:
- monitoring
# 数据卷
volumes:
server-logs:
driver: local
driver_opts:
type: none
o: bind
device: /var/log/vocata/server
server-uploads:
driver: local
driver_opts:
type: none
o: bind
device: /var/data/vocata/uploads
web-logs:
driver: local
driver_opts:
type: none
o: bind
device: /var/log/vocata/web
admin-logs:
driver: local
driver_opts:
type: none
o: bind
device: /var/log/vocata/admin
nginx-logs:
driver: local
driver_opts:
type: none
o: bind
device: /var/log/vocata/nginx
prometheus-data:
driver: local
driver_opts:
type: none
o: bind
device: /var/data/vocata/prometheus
grafana-data:
driver: local
driver_opts:
type: none
o: bind
device: /var/data/vocata/grafana
# 网络配置
networks:
vocata-network:
driver: bridge
name: ${COMPOSE_PROJECT_NAME:-vocata-prod}-network
driver_opts:
com.docker.network.bridge.name: vocata-br