[383a81]: / production / docker-compose-build-nginx.yml

Download this file

267 lines (263 with data), 8.1 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
# In Compose Specification, version key is deprecated.
# Reference: https://github.com/compose-spec/compose-spec/blob/master/spec.md
#version: "3.9"
services:
# Build streamlit ui server
ui:
build:
context: ./ui-server
dockerfile: Dockerfile
# Choose image name
image: nabot-ui
# Don't start ui server before chatbot server
depends_on:
rasa:
condition: service_healthy
# Choose container name
container_name: ui-server
restart: always
# Make the same network for chatbot server and ui server
networks:
- frontend-network
- nginx-network
# Mount .env file to the ui server to read chatbot URL
volumes:
- ./.env:/flask_server/.env
expose:
- 8501
# Healthcheck condition
healthcheck:
test: ["CMD", "printf", ".", ">", "/dev/tcp/127.0.0.1/8501"]
interval: 30s
timeout: 10s
retries: 30
# Build a monitoring server
monitoring:
build:
context: ./monitoring-server
dockerfile: Dockerfile
# Choose image name
image: monitoring-ui
# Don't start ui server before postgres server
depends_on:
rasa:
condition: service_healthy
# Choose container name
container_name: monitoring-server
restart: always
# Make the same network for chatbot server and ui server
networks:
- events-network
- nginx-network
# Mount .env file to the ui server to read chatbot URL
volumes:
- ./.env:/monitoring_ui/.env
# Map TCP port 8501 in the container to port 80 on the Docker host.
# This is a chatbot rest api port
#ports:
# - 8501:8501
expose:
- 8501
# Healthcheck condition
healthcheck:
test: ["CMD", "printf", ".", ">", "/dev/tcp/127.0.0.1/8501"]
interval: 30s
timeout: 10s
retries: 30
# Build chatbot server
rasa:
build:
context: ./rasa-server
dockerfile: Dockerfile
args:
# Pass model weights version as an argument
- VERSION=v0.1.0
# Choose image name
image: rasa-server
# Don't start chatbot server before action server
depends_on:
app:
condition: service_healthy
# Choose container name
container_name: chatbot-server
restart: always
# Expose 5005 port to ui server can see the chatbot server
expose:
- 5005
# Map TCP port 5005 in the container to port 5005 on the Docker host.
# This is a chatbot rest api port
# ports:
# - 5005:5005
# Healthcheck condition
healthcheck:
test: ["CMD", "printf", ".", ">", "/dev/tcp/127.0.0.1/5005"]
interval: 45s
timeout: 10s
retries: 30
# Store chatbot logs out side of the container
volumes:
- logs_data:/rasa-server/rasa/logs
- ./.env:/rasa-server/rasa/.env
# Make the same network for chatbot server and actions server
networks:
- rasa-network
- frontend-network
- events-network
- nginx-network
# Build action server
app:
build:
context: ./action-server
dockerfile: Dockerfile
# Choose image name
image: action-server
# Don't start action server before database
depends_on:
db_datasets:
condition: service_healthy
# Choose container name
container_name: action-server
restart: always
# Store chatbot logs out side of the container
volumes:
- logs_data:/action-server/logs
- ./.env:/action-server/.env
# Make the same network for chatbot server and actions server
# And also action server and postgres server
networks:
- rasa-network
- datasets-network
# Expose 5055 port to chatbot server can see the action server
expose:
- 5055
# Configuration of healthcheck for mysql action server
healthcheck:
test: ["CMD", "printf", ".", ">", "/dev/tcp/127.0.0.1/5055"]
interval: 45s
timeout: 10s
retries: 30
# Build mysql server
db_datasets:
# Use mysql image
image: mysql:8
container_name: datasets-server
# Use mysql_native_password instead of caching_sha2_password
command: '--default-authentication-plugin=mysql_native_password'
restart: always
volumes:
# Load mysql dumps (datasets) to the fresh mysql server during initialization
- ./datasets-server:/docker-entrypoint-initdb.d
# Store mysql records in the seperate volume. records won't be removed even with removing containers
- db-data:/var/lib/mysql
# Make the same network for mysql server and actions server
networks:
- datasets-network
# Read MYSQL password and database name from .env file
env_file:
- ./.env
environment:
- MYSQL_DATABASE=${MYSQL_DATASETS_DATABASE}
- MYSQL_ROOT_PASSWORD=${MYSQL_DATASETS_ROOT_PASSWORD}
# Expose 3306 port to action server can see the mysql server
expose:
- 3306
# Add the capability CAP_SYS_NICE to MySQL server can handle mbind error itself silently.
cap_add:
- SYS_NICE
# Configuration of healthcheck for mysql db
healthcheck:
test: ["CMD", 'mysqladmin', 'ping', '-h', 'localhost',
'-u', 'root', '-p$MYSQL_DATASETS_ROOT_PASSWORD' ]
interval: 3m30s
timeout: 45s
retries: 30
# Build mysql server
db_events:
# Use postgres image
image: postgres:12
container_name: events-server
restart: always
volumes:
# Store postgres records in the seperate volume. records won't be removed even with removing containers
- db-event:/var/lib/postgresql/data/
# Make the same network for mysql server and actions server
networks:
- events-network
# Read postgres password and database name from .env file
env_file:
- ./.env
environment:
- POSTGRES_DB=${POSTGRES_EVENTS_DATABASE}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_EVENTS_PASSWORD}
# Expose 5432 port to action server can see the postgres server
expose:
- 5432
# Add the capability CAP_SYS_NICE to MySQL server can handle mbind error itself silently.
cap_add:
- SYS_NICE
# Configuration of healthcheck for mysql db
healthcheck:
test: ["CMD", 'pg_isready', '-d', '$POSTGRES_EVENTS_DATABASE',
'-h', 'localhost']
interval: 3m30s
timeout: 45s
retries: 30
# Build nginx container
nginx:
container_name: nginx
image: nginx
# Map TCP port 80 and 443 of the container to port 80 and 443 of the Docker host, respectively.
ports:
- 80:80
- 443:443
volumes:
# Mount nginx default config file to the container
- ./nginx:/etc/nginx/conf.d
# Mount letsencrypt certifications to the container.
# If you're using different certificate authority, change the following line
- /etc/letsencrypt:/etc/letsencrypt:ro
# Nginx container depends on rasa, ui and monitoring containers
depends_on:
rasa:
condition: service_healthy
monitoring:
condition: service_healthy
ui:
condition: service_healthy
# Make the same network for rasa, ui and monitoring containers
networks:
- nginx-network
# List of docker networks
networks:
# network between chatbot and streamlit server
frontend-network:
name: nabot-frontend-network
driver: bridge
# network between chatbot and action server
rasa-network:
name: nabot-rasa-network
driver: bridge
# network between action server and mysql server
datasets-network:
name: nabot-datasets-network
driver: bridge
# network between ui/rasa server and postgres server
events-network:
name: nabot-events-network
driver: bridge
# A network for all endpoints (rasa - ui - monitoring)
nginx-network:
name: nabot-nginx-network
driver: bridge
# Seperate volumes
volumes:
# MYSQL datasets database volume
db-data:
name: data_db
# postgres events database volume
db-event:
name: event_db
# Storing logs volume
logs_data:
name: logs_db