-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
237 lines (228 loc) · 6.42 KB
/
Copy pathdocker-compose.yml
File metadata and controls
237 lines (228 loc) · 6.42 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
services:
# MongoDB Database
mongodb:
image: mongo:7
container_name: intervai-mongodb
restart: unless-stopped
ports:
- "27017:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USER:-admin}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD:-password123}
MONGO_INITDB_DATABASE: ${MONGO_DB_NAME:-intervai_db}
volumes:
- mongodb_data:/data/db
- mongodb_config:/data/configdb
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
networks:
- intervai-network
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
# Redis Cache & Queue Backend
redis:
image: redis:7-alpine
container_name: intervai-redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redis_data:/data
networks:
- intervai-network
command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru --requirepass ${REDIS_PASSWORD:-redis123}
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 10s
timeout: 3s
retries: 5
start_period: 10s
# Main API Server
api:
build:
context: .
dockerfile: Dockerfile
container_name: intervai-api
restart: unless-stopped
env_file:
- .env
ports:
- "${PORT:-8000}:${PORT:-8000}"
environment:
NODE_ENV: ${NODE_ENV:-production}
PORT: ${PORT:-8000}
MONGO_URI: mongodb://${MONGO_ROOT_USER:-admin}:${MONGO_ROOT_PASSWORD:-password123}@mongodb:27017/${MONGO_DB_NAME:-intervai_db}?authSource=admin
JWT_SECRET: ${JWT_SECRET}
GROQ_API: ${GROQ_API_KEY}
GROQ_API_KEY: ${GROQ_API_KEY}
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: ${REDIS_PASSWORD:-redis123}
CLIENT_URL: ${CLIENT_URL:-http://localhost:3000}
depends_on:
mongodb:
condition: service_healthy
redis:
condition: service_healthy
networks:
- intervai-network
volumes:
- ./exports:/app/exports
- ./logs:/app/logs
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:${PORT:-8000}/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Background Worker for AI & Exports
worker:
build:
context: .
dockerfile: Dockerfile.worker
container_name: intervai-worker
restart: unless-stopped
env_file:
- .env
environment:
NODE_ENV: ${NODE_ENV:-production}
MONGO_URI: mongodb://${MONGO_ROOT_USER:-admin}:${MONGO_ROOT_PASSWORD:-password123}@mongodb:27017/${MONGO_DB_NAME:-intervai_db}?authSource=admin
GROQ_API: ${GROQ_API_KEY}
GROQ_API_KEY: ${GROQ_API_KEY}
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: ${REDIS_PASSWORD:-redis123}
depends_on:
mongodb:
condition: service_healthy
redis:
condition: service_healthy
networks:
- intervai-network
volumes:
- ./exports:/app/exports
- ./logs:/app/logs
healthcheck:
test: ["CMD", "node", "-e", "process.exit(0)"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
# Nginx Reverse Proxy
nginx:
image: nginx:1.27-alpine
container_name: intervai-nginx
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/certs:/etc/nginx/certs:ro
- nginx_logs:/var/log/nginx
depends_on:
- api
networks:
- intervai-network
healthcheck:
test: ["CMD", "nginx", "-t"]
interval: 30s
timeout: 5s
retries: 3
# Prometheus — Metrics Scraper
prometheus:
image: prom/prometheus:v2.53.0
container_name: intervai-prometheus
restart: unless-stopped
ports:
- "9090:9090"
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./monitoring/alerts.yml:/etc/prometheus/alerts.yml:ro
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=30d'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
- '--web.enable-lifecycle'
- '--web.enable-admin-api'
networks:
- intervai-network
depends_on:
- api
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:9090/-/healthy"]
interval: 30s
timeout: 10s
retries: 3
# Grafana — Metrics Dashboard
grafana:
image: grafana/grafana:11.1.0
container_name: intervai-grafana
restart: unless-stopped
ports:
- "3001:3000"
environment:
GF_SECURITY_ADMIN_USER: ${GRAFANA_USER:-admin}
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:-admin123}
GF_USERS_ALLOW_SIGN_UP: "false"
GF_SERVER_ROOT_URL: ${GRAFANA_URL:-http://localhost:3001}
GF_INSTALL_PLUGINS: grafana-clock-panel,grafana-simple-json-datasource
GF_SECURITY_SECRET_KEY: ${GRAFANA_SECRET:-changeme_in_prod}
volumes:
- grafana_data:/var/lib/grafana
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning:ro
- ./monitoring/grafana/dashboards:/var/lib/grafana/dashboards:ro
networks:
- intervai-network
depends_on:
- prometheus
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3000/api/health"]
interval: 30s
timeout: 10s
retries: 3
# Loki — Log Aggregation
loki:
image: grafana/loki:3.0.0
container_name: intervai-loki
restart: unless-stopped
ports:
- "3100:3100"
volumes:
- ./monitoring/loki-config.yml:/etc/loki/local-config.yaml:ro
- loki_data:/loki
command: -config.file=/etc/loki/local-config.yaml
networks:
- intervai-network
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3100/ready"]
interval: 30s
timeout: 10s
retries: 3
networks:
intervai-network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16
volumes:
mongodb_data:
driver: local
mongodb_config:
driver: local
redis_data:
driver: local
prometheus_data:
driver: local
grafana_data:
driver: local
loki_data:
driver: local
nginx_logs:
driver: local