-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
docker-compose.yml
198 lines (190 loc) · 5.83 KB
/
docker-compose.yml
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
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
# User management service configuration
user-management:
# Build the image from the specified Dockerfile
build:
context: ./examples/user_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:sio_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
# 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"]
# Expose the service on port 8002
ports:
- '8002:8002'
# Attach the service to the custom network
networks:
- app_network