-
-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
248 lines (238 loc) · 7.58 KB
/
docker-compose.yml
File metadata and controls
248 lines (238 loc) · 7.58 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
networks:
# Define a custom bridge network for communication between services
app_network:
driver: bridge
services:
base:
build:
context: .
dockerfile: scripts/base.Dockerfile
networks:
- app_network
image: base:latest
# Redis service configuration
redis:
# Use the latest Redis image
image: redis:latest
# Command to start Redis with a password for security
command: redis-server --requirepass 'password'
# Expose Redis on port 6379
ports:
- '6379:6379'
# Configure a health check to ensure Redis is running
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 3
# Attach Redis to the custom network
networks:
- app_network
# MySQL database service configuration
mysql:
# Use the latest MySQL image
image: mysql:latest
# Set the container name for easier reference
container_name: mysql-container
# Environment variables for configuring the MySQL database
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: construction_hazard_detection
MYSQL_USER: username
MYSQL_PASSWORD: password
# Expose MySQL on port 3306
ports:
- '3306:3306'
# Mount an initialisation SQL script to the MySQL entrypoint directory
volumes:
- ./scripts/init.sql:/docker-entrypoint-initdb.d/init.sql
# Configure a health check to ensure MySQL is running
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 3
# Attach MySQL to the custom network
networks:
- app_network
# Database management service configuration
user-management:
# Build the image from the specified Dockerfile
build:
context: ./examples/db_management
dockerfile: Dockerfile
# Environment variables for database connection
environment:
DATABASE_URL: mysql+asyncmy://username:password@mysql/construction_hazard_detection
# Mount the examples directory for application access
volumes:
- ./examples:/app/examples
# Ensure the service starts only after MySQL is healthy
depends_on:
base:
condition: service_started
mysql:
condition: service_healthy
# Expose the user management service on port 8001
ports:
- '8001:8001'
# Attach the service to the custom network
networks:
- app_network
# YOLO Server API service configuration
yolo-server-api:
# Build the image from the specified Dockerfile
build:
context: .
dockerfile: examples/YOLO_server_api/Dockerfile
# Environment variables for connecting to Redis and MySQL
environment:
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: password
DATABASE_URL: mysql+asyncmy://username:password@mysql/construction_hazard_detection
# Ensure the service starts only after Redis and MySQL are healthy
depends_on:
base:
condition: service_started
redis:
condition: service_healthy
mysql:
condition: service_healthy
# Mount the examples directory for application access
volumes:
- ./examples:/app/examples
- ./models/pt:/app/models/pt
# Expose the YOLO Server API on port 5000
ports:
- '6000:6000'
# Attach the service to the custom network
networks:
- app_network
# Streaming web backend service configuration
streaming-web-backend:
# Build the image from the specified Dockerfile
build:
context: ./examples/streaming_web/backend
dockerfile: Dockerfile
# Environment variables for connecting to Redis
environment:
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: password
PYTHONPATH: /app
# Mount the examples directory for application access
volumes:
- ./examples:/app/examples
# Ensure the backend starts only after Redis is healthy
depends_on:
base:
condition: service_started
redis:
condition: service_healthy
# Command to run the backend using Uvicorn
command: ["uvicorn", "examples.streaming_web.backend.app:app", "--host", "0.0.0.0", "--port", "8000"]
# Expose the backend on port 8000
ports:
- '8000:8000'
# Attach the backend to the custom network
networks:
- app_network
local-notification-server:
# Build the image from the specified Dockerfile
build:
context: ./examples/local_notification_server
dockerfile: Dockerfile
# Environment variables for connecting to Redis
environment:
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: password
# Mount the examples directory for application access
volumes:
- ./examples:/app/examples
# Ensure the service starts only after Redis is healthy
depends_on:
base:
condition: service_started
redis:
condition: service_healthy
# Command to run the local notification server using Uvicorn
command: ["uvicorn", "examples.streaming_web.backend.app:app", "--host", "0.0.0.0", "--port", "8003"]
violation-records:
# Build the image from the specified Dockerfile
build:
context: ./examples/violation_records
dockerfile: Dockerfile
# Environment variables for connecting to Redis and MySQL
environment:
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: password
DATABASE_URL: mysql+asyncmy://username:password@mysql/construction_hazard_detection
# Mount the examples directory for application access
volumes:
- ./examples:/app/examples
# Ensure the service starts only after Redis and MySQL are healthy
depends_on:
base:
condition: service_started
redis:
condition: service_healthy
mysql:
condition: service_healthy
# Command to run the violation records service using Uvicorn
command: ["uvicorn", "examples.streaming_web.backend.app:app", "--host", "0.0.0.0", "--port", "8001"]
## Remove
# Streaming web frontend service configuration
# streaming-web-frontend:
# # Build the image from the specified Dockerfile
# build:
# context: ./examples/streaming_web/frontend
# dockerfile: Dockerfile
# # Ensure the frontend starts only after the backend is running
# depends_on:
# streaming-web-backend:
# condition: service_started
# # Expose the frontend on port 80
# ports:
# - '80:80'
# # Attach the frontend to the custom network
# networks:
# - app_network
# Construction hazard detection service configuration
construction-hazard-detection:
# Build the image from the specified Dockerfile
build:
context: .
dockerfile: Dockerfile
# Environment variables for connecting to Redis
environment:
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: password
env_file:
- .env
# Mount the configuration directory for application access
volumes:
- ./config:/app/config
- ./models/pt:/app/models/pt
- ./.env:/app/.env
# Ensure the service starts only after Redis is healthy
depends_on:
base:
condition: service_started
redis:
condition: service_healthy
yolo-server-api:
condition: service_started
# Command to run the application with the specified configuration
# command: ["--config", "/app/config/configuration.yaml"]
# Command to run the main application
command: ["python", "main.py"]
# Expose the service on port 8002
ports:
- '8002:8002'
# Attach the service to the custom network
networks:
- app_network