-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
361 lines (342 loc) · 10 KB
/
Copy pathdocker-compose.yml
File metadata and controls
361 lines (342 loc) · 10 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
359
360
361
version: "3.8" # Docker Compose file format version
services:
db:
image: postgres:15
environment:
POSTGRES_USER: adaptIq_user
POSTGRES_PASSWORD: adaptIq_pass
POSTGRES_DB: adaptIq_db
ports:
- "5432:5432"
volumes:
- db_data:/var/lib/postgresql/data
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U adaptIq_user -d adaptIq_db"]
interval: 10s
timeout: 5s
retries: 5
networks:
- adaptIq_net
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- adaptIq_net
minio:
image: minio/minio:latest
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
ports:
- "9000:9000"
- "9001:9001"
volumes:
- minio_data:/data
command: server /data --console-address ":9001"
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
- adaptIq_net
mqtt:
image: eclipse-mosquitto:2
ports:
- "1884:1883"
- "9002:9001"
volumes:
- ./mqtt/config:/mosquitto/config
- mqtt_data:/mosquitto/data
- mqtt_log:/mosquitto/log
healthcheck:
test:
[
"CMD-SHELL",
"mosquitto_sub -t '$$SYS/#' -C 1 -i healthcheck -W 3 || exit 1",
]
interval: 10s
timeout: 5s
retries: 5
networks:
- adaptIq_net
ml:
build: ./ml
ports:
- "5000:5000"
environment:
DB_HOST: db
DB_PORT: 5432
DB_USER: adaptIq_user
DB_PASS: adaptIq_pass
DB_NAME: adaptIq_db
depends_on:
db:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
networks:
- adaptIq_net
api:
build: ./api
volumes:
- ./api:/app
- /app/node_modules
ports:
- "3000:3000"
environment:
NODE_ENV: development
DB_HOST: db
DB_PORT: 5432
DB_USER: adaptIq_user
DB_PASS: adaptIq_pass
DB_NAME: adaptIq_db
REDIS_HOST: redis
MINIO_ENDPOINT: http://minio:9000
MINIO_ACCESS_KEY: minioadmin
MINIO_SECRET_KEY: minioadmin
MQTT_BROKER: mqtt://mqtt:1883
ML_SERVICE_URL: http://ml:5000
AUTH0_DOMAIN: ${AUTH0_DOMAIN}
AUTH0_MANAGEMENT_CLIENT_ID: ${AUTH0_MANAGEMENT_CLIENT_ID}
AUTH0_MANAGEMENT_CLIENT_SECRET: ${AUTH0_MANAGEMENT_CLIENT_SECRET}
OIDC_ISSUER: ${OIDC_ISSUER}
OIDC_AUDIENCE: ${OIDC_AUDIENCE}
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
minio:
condition: service_healthy
mqtt:
condition: service_healthy
ml:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
networks:
- adaptIq_net
web:
build:
context: ./web
dockerfile: Dockerfile.dev
ports:
- "3001:3002"
environment:
NEXT_PUBLIC_API_URL: http://localhost:3000
NODE_ENV: development
# Auth0 configuration
AUTH0_CLIENT_ID: ${AUTH0_CLIENT_ID}
AUTH0_CLIENT_SECRET: ${AUTH0_CLIENT_SECRET}
AUTH0_ISSUER: ${AUTH0_ISSUER}
AUTH0_DOMAIN: ${AUTH0_DOMAIN}
NEXT_PUBLIC_AUTH0_AUDIENCE: ${NEXT_PUBLIC_AUTH0_AUDIENCE}
# NextAuth configuration
NEXTAUTH_URL: http://localhost:3002
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
volumes:
- ./web:/app
- /app/node_modules
- /app/.next
depends_on:
api:
condition: service_healthy
healthcheck:
test:
[
"CMD-SHELL",
"wget --no-verbose --tries=1 --spider http://localhost:3002 || exit 1",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
networks:
- adaptIq_net
volumes:
db_data:
redis_data:
minio_data:
mqtt_data:
mqtt_log:
networks:
adaptIq_net:
driver: bridge
# services:
# # Define all the application services/containers
# db:
# # PostgreSQL database service
# image: postgres:15 # Use PostgreSQL version 15 official image
# environment:
# # Environment variables to configure Postgres
# POSTGRES_USER: adaptIq_user # Database username
# POSTGRES_PASSWORD: adaptIq_pass # Database password
# POSTGRES_DB: adaptIq_db # Database name to create at startup
# ports:
# - "5432:5432" # Map container port 5432 to host port 5432
# volumes:
# - db_data:/var/lib/postgresql/data # Persistent storage for DB data
# - ./db/init.sql:/docker-entrypoint-initdb.d/init.sql # Auto-run SQL seed script
# networks:
# - adaptIq_net # Connects to shared application network
# redis:
# # Redis in-memory cache service
# image: redis:7 # Use Redis version 7 official image
# ports:
# - "6379:6379" # Map container port 6379 to host port 6379
# volumes:
# - redis_data:/data # Persistent storage for Redis data
# networks:
# - adaptIq_net # Connects to shared application network
# minio:
# # MinIO object storage service (S3-compatible)
# image: minio/minio:latest # Latest MinIO image
# environment:
# # Credentials for MinIO
# MINIO_ROOT_USER: minioadmin
# MINIO_ROOT_PASSWORD: minioadmin
# ports:
# - "9000:9000" # Expose MinIO API
# - "9001:9001" # Expose MinIO console (web UI)
# volumes:
# - minio_data:/data # Persistent storage for object data
# command: server /data --console-address ":9001" # Start MinIO with console on port 9001
# healthcheck:
# # ← ADD THIS BLOCK
# test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
# interval: 30s
# timeout: 20s
# retries: 3
# start_period: 40s # Give MinIO time to initialize
# networks:
# - adaptIq_net # Connects to shared application network
# mqtt:
# # MQTT message broker service
# image: eclipse-mosquitto:2 # Eclipse Mosquitto version 2 image
# ports:
# - "1884:1883" # Standard MQTT protocol port, map host:1884 to container:1883
# - "9002:9001" # Expose WebSocket listener (mapped host:container = 9002:9001)
# volumes:
# - ./mqtt/config:/mosquitto/config # Mount custom config folder
# - mqtt_data:/mosquitto/data # Persistent data storage
# - mqtt_log:/mosquitto/log # Persistent log storage
# networks:
# - adaptIq_net # Connects to shared application network
# api:
# # Backend API service
# build: ./api # Build from Dockerfile inside ./api folder
# volumes:
# - ./api:/app
# - /app/node_modules
# ports:
# - "3000:3000" # Map container port 3000 to host port 3000
# environment:
# # Environment variables for connecting to other services
# DB_HOST: db # Postgres host (container name)
# DB_PORT: 5432
# DB_USER: adaptIq_user
# DB_PASS: adaptIq_pass
# DB_NAME: adaptIq_db
# REDIS_HOST: redis # Redis host (container name)
# MINIO_ENDPOINT: http://minio:9000 # MinIO API endpoint
# MINIO_ACCESS_KEY: minioadmin
# MINIO_SECRET_KEY: minioadmin
# MQTT_BROKER: mqtt://mqtt:1883 # MQTT broker address
# ML_SERVICE_URL: http://ml:5000
# depends_on:
# # Ensure dependencies are started before this service
# db:
# condition: service_started
# redis:
# condition: service_started
# minio:
# condition: service_healthy
# mqtt:
# condition: service_started
# ml:
# condition: service_healthy
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
# interval: 30s
# timeout: 10s
# retries: 3
# start_period: 20s
# networks:
# - adaptIq_net # Connects to shared application network
# web:
# # Frontend web application (Next.js)
# build:
# context: ./web # Build from ./web folder
# dockerfile: Dockerfile.dev # Use Dockerfile.dev for dev setup
# ports:
# - "3001:3002" # Map host port 3001 to container port 3002 (Next.js default)
# environment:
# NEXT_PUBLIC_API_URL: http://api:3000 # API endpoint for frontend
# volumes:
# - ./web:/app # Mount local source code for live development
# - /app/node_modules # Avoid overwriting node_modules inside container
# depends_on:
# # Start API before frontend
# api:
# condition: service_healthy
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:3002"]
# interval: 30s
# timeout: 10s
# retries: 3
# start_period: 20s
# networks:
# - adaptIq_net # Connects to shared application network
# ml:
# build: ./ml # Assuming your Flask ML code is in ./ml with a Dockerfile
# ports:
# - "5000:5000" # Expose for local dev (optional)
# environment:
# DB_HOST: db
# DB_PORT: 5432
# DB_USER: adaptIq_user
# DB_PASS: adaptIq_pass
# DB_NAME: adaptIq_db
# depends_on:
# db:
# condition: service_started
# healthcheck:
# test: ["CMD", "curl", "-f", "http://127.0.0.1:5000/health"]
# interval: 30s
# timeout: 10s
# retries: 3
# start_period: 20s
# networks:
# - adaptIq_net
# volumes:
# # Define persistent storage volumes for services
# db_data: # Named volume for Postgres
# redis_data: # Named volume for Redis
# minio_data: # Named volume for MinIO
# mqtt_data: # Named volume for Mosquitto data
# mqtt_log:
# # Named volume for Mosquitto logs
# networks:
# # Define custom networks
# adaptIq_net:
# # Application network shared by all services
# driver: bridge # Use bridge driver (default for single-host setups)