-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.production.yml
More file actions
118 lines (108 loc) · 2.79 KB
/
docker-compose.production.yml
File metadata and controls
118 lines (108 loc) · 2.79 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
version: '3.8'
services:
# Redis for caching and session storage
redis:
image: redis:7-alpine
restart: always
ports:
- "6379:6379"
volumes:
- redis_data:/data
command: redis-server --appendonly yes --maxmemory 1gb --maxmemory-policy allkeys-lru
# MongoDB with optimized configuration
mongodb:
image: mongo:7
restart: always
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
- ./mongodb.conf:/etc/mongod.conf
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
command: mongod --config /etc/mongod.conf
# Multiple backend instances with load balancing
backend-1:
build: ./backend
restart: always
environment:
- MONGO_URL=mongodb://admin:${MONGO_PASSWORD}@mongodb:27017/observer_ai?authSource=admin
- REDIS_URL=redis://redis:6379
- JWT_SECRET=${JWT_SECRET}
- WORKERS=4
depends_on:
- mongodb
- redis
command: uvicorn server:app --host 0.0.0.0 --port 8001 --workers 4
backend-2:
build: ./backend
restart: always
environment:
- MONGO_URL=mongodb://admin:${MONGO_PASSWORD}@mongodb:27017/observer_ai?authSource=admin
- REDIS_URL=redis://redis:6379
- JWT_SECRET=${JWT_SECRET}
- WORKERS=4
depends_on:
- mongodb
- redis
command: uvicorn server:app --host 0.0.0.0 --port 8001 --workers 4
backend-3:
build: ./backend
restart: always
environment:
- MONGO_URL=mongodb://admin:${MONGO_PASSWORD}@mongodb:27017/observer_ai?authSource=admin
- REDIS_URL=redis://redis:6379
- JWT_SECRET=${JWT_SECRET}
- WORKERS=4
depends_on:
- mongodb
- redis
command: uvicorn server:app --host 0.0.0.0 --port 8001 --workers 4
# Nginx load balancer
nginx:
image: nginx:alpine
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./ssl:/etc/nginx/ssl
depends_on:
- backend-1
- backend-2
- backend-3
- frontend
# Frontend with optimization
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.production
restart: always
environment:
- REACT_APP_BACKEND_URL=${BACKEND_URL}
command: serve -s build -l 3000
# Monitoring stack
prometheus:
image: prom/prometheus
restart: always
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
grafana:
image: grafana/grafana
restart: always
ports:
- "3001:3000"
volumes:
- grafana_data:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}
volumes:
mongodb_data:
redis_data:
prometheus_data:
grafana_data: