-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
358 lines (349 loc) · 11.8 KB
/
docker-compose.yml
File metadata and controls
358 lines (349 loc) · 11.8 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
services:
# Redis Service
redis:
image: redis:7-alpine
container_name: vrecom_redis
ports:
- "${REDIS_PORT:-6379}:6379"
volumes:
- redis_data:/data
networks:
- vrecom_network
restart: unless-stopped
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
reservations:
cpus: "0.1"
memory: 128M
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 3
start_period: 5s
# Zookeeper Service
zookeeper:
image: confluentinc/cp-zookeeper:7.5.0
container_name: vrecom_zookeeper
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
KAFKA_HEAP_OPTS: "-Xms128m -Xmx256m"
volumes:
- zookeeper_data:/var/lib/zookeeper/data
- zookeeper_logs:/var/lib/zookeeper/log
networks:
- vrecom_network
restart: unless-stopped
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
reservations:
cpus: "0.1"
memory: 128M
healthcheck:
test:
[
"CMD-SHELL",
"curl -s http://localhost:8080/commands/ruok || exit 1",
]
interval: 30s
timeout: 10s
retries: 5
start_period: 15s
# Kafka Service
kafka:
image: confluentinc/cp-kafka:7.5.0
container_name: vrecom_kafka
depends_on:
zookeeper:
condition: service_healthy
ports:
- "${KAFKA_PORT:-9092}:9092"
- "9093:9093"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://kafka:9093
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT_INTERNAL
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
KAFKA_LOG_RETENTION_HOURS: 168
KAFKA_LOG_SEGMENT_BYTES: 1073741824
KAFKA_HEAP_OPTS: "-Xms256m -Xmx512m"
volumes:
- kafka_data:/var/lib/kafka/data
networks:
- vrecom_network
restart: unless-stopped
deploy:
resources:
limits:
cpus: "1.0"
memory: 1G
reservations:
cpus: "0.25"
memory: 256M
healthcheck:
test:
[
"CMD-SHELL",
"kafka-broker-api-versions --bootstrap-server localhost:9092 || exit 1",
]
interval: 30s
timeout: 15s
retries: 5
start_period: 30s
# Kafka UI (Optional - for monitoring)
kafka-ui:
image: provectuslabs/kafka-ui:latest
container_name: vrecom_kafka_ui
depends_on:
kafka:
condition: service_healthy
ports:
- "${KAFKA_UI_PORT:-8080}:8080"
environment:
KAFKA_CLUSTERS_0_NAME: vrecom-cluster
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9093
KAFKA_CLUSTERS_0_ZOOKEEPER: zookeeper:2181
JAVA_OPTS: "-Xms128m -Xmx256m"
networks:
- vrecom_network
restart: unless-stopped
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
reservations:
cpus: "0.1"
memory: 128M
healthcheck:
test:
[
"CMD-SHELL",
"wget --no-verbose --tries=1 --spider http://localhost:8080 || exit 1",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 15s
# API Server (Go)
api_server:
build:
context: ./backend/api_server
dockerfile: Dockerfile
# Enable BuildKit for better caching
container_name: vrecom_api_server
ports:
- "${API_SERVER_PORT:-2030}:${API_SERVER_PORT:-2030}"
environment:
- STATUS_DEV=${STATUS_DEV:-dev}
- HOST_ADDRESS=${API_SERVER_HOST:-0.0.0.0}
- HOST_PORT=${API_SERVER_PORT:-2030}
- HOST_READ_TIMEOUT=${API_SERVER_READ_TIMEOUT:-60}
- JWT_SECRET_KEY=${JWT_SECRET_KEY:-your-super-secret-jwt-key-change-in-production}
- SESSION_SECRET=${SESSION_SECRET:-your-super-secret-session-key-change-in-production}
- REDIS_HOST=${REDIS_HOST:-redis}
- REDIS_PORT=${REDIS_PORT:-6379}
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
- REDIS_DB=${REDIS_DB:-0}
- AI_SERVER_URL=${AI_SERVER_URL:-http://ai_server:9999}
- HOST_IP=${HOST_IP:-localhost}
- FRONTEND_URL=${FRONTEND_URL:-http://${HOST_IP:-localhost}:5173}
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID:-}
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET:-}
- GOOGLE_CALLBACK_URL=${GOOGLE_CALLBACK_URL:-http://${HOST_IP:-localhost}:2030/api/v1/auth/google/callback}
# Go runtime optimizations
- GOGC=100
- GOMEMLIMIT=450MiB
volumes:
- ./backend/api_server/logs:/app/logs
- ./backend/api_server/config:/app/config
- ./data/user_logs:/app/user_logs
networks:
- vrecom_network
depends_on:
redis:
condition: service_healthy
restart: unless-stopped
deploy:
resources:
limits:
cpus: "1.0"
memory: 512M
reservations:
cpus: "0.25"
memory: 128M
healthcheck:
test:
[
"CMD",
"curl",
"-f",
"http://localhost:${API_SERVER_PORT:-2030}/api/v1/ping",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
# AI Server (Python)
ai_server:
build:
context: ./backend/ai_server
dockerfile: Dockerfile
container_name: vrecom_ai_server
ports:
- "${AI_SERVER_PORT:-9999}:${AI_SERVER_PORT:-9999}"
environment:
- HOST=${AI_SERVER_HOST:-0.0.0.0}
- PORT=${AI_SERVER_PORT:-9999}
- JWT_SECRET_KEY=${JWT_SECRET_KEY:-your-super-secret-jwt-key-change-in-production}
- SESSION_SECRET=${SESSION_SECRET:-your-super-secret-session-key-change-in-production}
- MYSQL_HOST=${MYSQL_HOST:-mysql}
- MYSQL_PORT=${MYSQL_PORT:-3306}
- MYSQL_USER=${MYSQL_USER:-admin}
- MYSQL_PASSWORD=${MYSQL_PASSWORD:-pokiwar0981}
- MYSQL_DATABASE=${MYSQL_DATABASE:-shop}
- MONGODB_HOST=${MONGODB_HOST:-mongodb}
- MONGODB_PORT=${MONGODB_PORT:-27017}
- MONGODB_USERNAME=${MONGODB_USERNAME:-root}
- MONGODB_PASSWORD=${MONGODB_PASSWORD:-password}
- KAFKA_BOOTSTRAP_SERVERS=${KAFKA_BOOTSTRAP_SERVERS:-kafka:9093}
- KAFKA_GROUP_ID=${KAFKA_GROUP_ID:-vrecom_ai_server_group}
# Python optimizations
- PYTHONUNBUFFERED=1
- PYTHONDONTWRITEBYTECODE=1
- MALLOC_TRIM_THRESHOLD_=100000
volumes:
- ./backend/ai_server/src:/app/src
- ./backend/ai_server/config:/app/config
- ./backend/ai_server/tasks:/app/tasks
- ./backend/ai_server/logs:/app/logs
- ./backend/ai_server/models:/app/models
- ./data/uploads:/app/data/uploads
networks:
- vrecom_network
restart: unless-stopped
deploy:
resources:
limits:
cpus: "2.0"
memory: 2G
reservations:
cpus: "0.5"
memory: 512M
healthcheck:
test:
[
"CMD",
"curl",
"-f",
"http://localhost:${AI_SERVER_PORT:-9999}/api/v1/health",
]
interval: 30s
timeout: 15s
retries: 5
start_period: 30s
# Prometheus (Monitoring for AI Server)
prometheus:
image: prom/prometheus:latest
container_name: vrecom_prometheus
ports:
- "${PROMETHEUS_PORT:-9090}:9090"
volumes:
- ./backend/ai_server/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--storage.tsdb.retention.time=7d"
- "--storage.tsdb.retention.size=1GB"
networks:
- vrecom_network
restart: unless-stopped
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
reservations:
cpus: "0.1"
memory: 128M
healthcheck:
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"--spider",
"http://localhost:9090/-/healthy",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
# Frontend (React + Vite)
frontend:
build:
context: ./frontend/project
dockerfile: Dockerfile
args:
- VITE_API_SERVER_URL=${VITE_API_SERVER_URL:-http://localhost:2030}
- VITE_AI_SERVER_URL=${VITE_AI_SERVER_URL:-http://localhost:9999}
container_name: vrecom_frontend
ports:
- "${FRONTEND_PORT:-5173}:${FRONTEND_PORT:-5173}"
environment:
- VITE_API_SERVER_URL=${VITE_API_SERVER_URL:-http://localhost:2030}
- VITE_AI_SERVER_URL=${VITE_AI_SERVER_URL:-http://localhost:9999}
- FRONTEND_PORT=${FRONTEND_PORT:-5173}
volumes:
- ./frontend/project/src:/app/src
- ./frontend/project/public:/app/public
networks:
- vrecom_network
depends_on:
api_server:
condition: service_healthy
ai_server:
condition: service_healthy
restart: unless-stopped
deploy:
resources:
limits:
cpus: "0.5"
memory: 256M
reservations:
cpus: "0.1"
memory: 64M
healthcheck:
test:
[
"CMD-SHELL",
"wget --no-verbose --tries=1 --spider http://localhost:${FRONTEND_PORT:-5173} || exit 1",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
networks:
vrecom_network:
driver: bridge
driver_opts:
com.docker.network.driver.mtu: 1500
volumes:
redis_data:
prometheus_data:
zookeeper_data:
zookeeper_logs:
kafka_data: