-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
293 lines (282 loc) · 8.28 KB
/
docker-compose.yml
File metadata and controls
293 lines (282 loc) · 8.28 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
# ===============================================
# SnowGuard AI - Docker Compose
# Single PostgreSQL + Redis + All Microservices With Service Discovery, Config Server, and Fault Tolerance
# ===============================================
services:
# ===============================================
# SHARED INFRASTRUCTURE
# ===============================================
postgres:
image: postgres:18-alpine
container_name: snowguard-postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
- ./init-databases.sql:/docker-entrypoint-initdb.d/init-databases.sql
networks:
- snowguard-net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:8-alpine
container_name: snowguard-redis
ports:
- "6379:6379"
networks:
- snowguard-net
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# ===============================================
# DISCOVERY & CONFIG
# ===============================================
discovery-service:
image: rahijamil/snowguard-discovery-service
# build: ./discovery-service
container_name: discovery-service
ports:
- "8761:8761"
networks:
- snowguard-net
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8761/actuator/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
restart: unless-stopped
config-service:
image: rahijamil/snowguard-config-service
# build: ./config-service
container_name: config-service
environment:
- SPRING_PROFILES_ACTIVE=native
ports:
- "8888:8888"
volumes:
- ./config-repo:/app/config-repo
networks:
- snowguard-net
depends_on:
discovery-service:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8888/actuator/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
restart: unless-stopped
# ===============================================
# MICROSERVICES
# ===============================================
user-service:
image: rahijamil/snowguard-user-service
# build: ./user-service
container_name: user-service
env_file:
- .env
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/userdb
- SPRING_DATASOURCE_USERNAME=postgres
- SPRING_DATASOURCE_PASSWORD=postgres
- SPRING_REDIS_HOST=redis
- SPRING_REDIS_PORT=6379
- SPRING_CONFIG_IMPORT=optional:configserver:http://config-service:8888
- EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://discovery-service:8761/eureka/
ports:
- "8081:8081"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
config-service:
condition: service_healthy
discovery-service:
condition: service_healthy
networks:
- snowguard-net
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8081/actuator/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 90s
hazard-service:
image: rahijamil/snowguard-hazard-service
# build: ./hazard-service
container_name: hazard-service
env_file:
- .env
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/hazarddb
- SPRING_DATASOURCE_USERNAME=postgres
- SPRING_DATASOURCE_PASSWORD=postgres
- SPRING_REDIS_HOST=redis
- SPRING_REDIS_PORT=6379
- OPENWEATHER_API_KEY=${OPENWEATHER_API_KEY}
- ROUTING_API_KEY=${ROUTING_API_KEY}
- SPRING_CONFIG_IMPORT=optional:configserver:http://config-service:8888
- EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://discovery-service:8761/eureka/
ports:
- "8082:8082"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
config-service:
condition: service_healthy
discovery-service:
condition: service_healthy
networks:
- snowguard-net
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8082/actuator/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 90s
ai-service:
image: rahijamil/snowguard-ai-service
# build: ./ai-service
container_name: ai-service
env_file:
- .env
environment:
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/aidb
- GEMINI_API_KEY=${GEMINI_API_KEY}
- GEMINI_MODEL=${GEMINI_MODEL:-gemini-2.5-flash}
- ENVIRONMENT=production
- PORT=8003
- LOG_LEVEL=INFO
- USER_SERVICE_URL=http://user-service:8081
- HAZARD_SERVICE_URL=http://hazard-service:8082
ports:
- "8003:8003"
depends_on:
postgres:
condition: service_healthy
user-service:
condition: service_healthy
hazard-service:
condition: service_healthy
networks:
- snowguard-net
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8003/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 90s
notification-service:
image: rahijamil/snowguard-notification-service
# build: ./notification-service
container_name: notification-service
env_file:
- .env
environment:
- NODE_ENV=production
- PORT=8004
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/notificationdb
- REDIS_HOST=redis
- REDIS_PORT=6379
- JWT_SECRET=${JWT_SECRET:-gyjKcS5rxZFa0bh4dM5tPUfkIHvM3938ucJUmf4g+Ic=}
- USER_SERVICE_URL=http://user-service:8081
- HAZARD_SERVICE_URL=http://hazard-service:8082
ports:
- "8004:8004"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
user-service:
condition: service_healthy
networks:
- snowguard-net
restart: unless-stopped
healthcheck:
test:
[
"CMD",
"node",
"-e",
"require('http').get('http://localhost:8004/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
# ===============================================
# API GATEWAY
# ===============================================
api-gateway:
image: rahijamil/snowguard-api-gateway
build: ./api-gateway
container_name: api-gateway
env_file:
- .env
environment:
- SPRING_REDIS_HOST=redis
- SPRING_REDIS_PORT=6379
- JWT_SECRET=${JWT_SECRET:-gyjKcS5rxZFa0bh4dM5tPUfkIHvM3938ucJUmf4g+Ic=}
- SPRING_CONFIG_IMPORT=optional:configserver:http://config-service:8888
- EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://discovery-service:8761/eureka/
# Service URLs (fallback if discovery fails)
- USER_SERVICE_URL=http://user-service:8081
- HAZARD_SERVICE_URL=http://hazard-service:8082
- AI_SERVICE_URL=http://ai-service:8003
- NOTIFICATION_SERVICE_URL=http://notification-service:8004
ports:
- "8000:8000"
depends_on:
redis:
condition: service_healthy
config-service:
condition: service_healthy
discovery-service:
condition: service_healthy
user-service:
condition: service_healthy
hazard-service:
condition: service_healthy
ai-service:
condition: service_healthy
notification-service:
condition: service_healthy
networks:
- snowguard-net
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/actuator/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 90s
# ===============================================
# VOLUMES
# ===============================================
volumes:
postgres-data:
driver: local
# ===============================================
# NETWORKS
# ===============================================
networks:
snowguard-net:
driver: bridge
name: snowguard-network