forked from bcgov/biohubbc-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
312 lines (299 loc) · 10.3 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
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
version: "3.5"
services:
## Build postgres docker image
db:
image: ${DOCKER_PROJECT_NAME}-db-${DOCKER_NAMESPACE}-img
container_name: ${DOCKER_PROJECT_NAME}-db-${DOCKER_NAMESPACE}-container
build:
context: ./database/.docker/db
dockerfile: Dockerfile
args:
- POSTGRES_VERSION=${POSTGRES_VERSION}
- POSTGIS_VERSION=${POSTGIS_VERSION}
- TZ=${DB_TZ}
ports:
- ${DB_PORT}:5432
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $DB_ADMIN -p 5432 -d $DB_DATABASE"]
interval: 5s
retries: 20
environment:
- NODE_ENV=${NODE_ENV}
- POSTGRES_USER=${DB_ADMIN}
- POSTGRES_PASSWORD=${DB_ADMIN_PASS}
- POSTGRES_DB=${DB_DATABASE}
- PORT=${DB_PORT}
networks:
- local-network
volumes:
- postgres:/var/lib/postgresql/data
## Build the api docker image
api:
image: ${DOCKER_PROJECT_NAME}-api-${DOCKER_NAMESPACE}-img
container_name: ${DOCKER_PROJECT_NAME}-api-${DOCKER_NAMESPACE}-container
build:
context: ./api
dockerfile: ./.docker/api/Dockerfile
ports:
- ${API_PORT}:${API_PORT}
environment:
- NODE_ENV=${NODE_ENV}
- TZ=${API_TZ}
- API_HOST=${API_HOST}
- API_PORT=${API_PORT}
- DB_HOST=${DB_HOST}
- DB_USER_API=${DB_USER_API}
- DB_USER_API_PASS=${DB_USER_API_PASS}
- DB_PORT=${DB_PORT}
- DB_DATABASE=${DB_DATABASE}
- DB_SCHEMA=${DB_SCHEMA}
- KEYCLOAK_HOST=${KEYCLOAK_HOST}
- KEYCLOAK_REALM=${KEYCLOAK_REALM}
- KEYCLOAK_CLIENT_ID=${KEYCLOAK_CLIENT_ID}
- KEYCLOAK_ADMIN_USERNAME=${KEYCLOAK_ADMIN_USERNAME}
- KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN_PASSWORD}
- OBJECT_STORE_URL=${OBJECT_STORE_URL}
- OBJECT_STORE_ACCESS_KEY_ID=${OBJECT_STORE_ACCESS_KEY_ID}
- OBJECT_STORE_SECRET_KEY_ID=${OBJECT_STORE_SECRET_KEY_ID}
- OBJECT_STORE_BUCKET_NAME=${OBJECT_STORE_BUCKET_NAME}
- MAX_REQ_BODY_SIZE=${MAX_REQ_BODY_SIZE}
- MAX_UPLOAD_NUM_FILES=${MAX_UPLOAD_NUM_FILES}
- MAX_UPLOAD_FILE_SIZE=${MAX_UPLOAD_FILE_SIZE}
- LOG_LEVEL=${LOG_LEVEL}
- CLAMAV_PORT=${CLAMAV_PORT}
- CLAMAV_HOST=${CLAMAV_HOST}
- ENABLE_FILE_VIRUS_SCAN=${ENABLE_FILE_VIRUS_SCAN}
- GCNOTIFY_SECRET_API_KEY=${GCNOTIFY_SECRET_API_KEY}
- GCNOTIFY_ADMIN_EMAIL=${GCNOTIFY_ADMIN_EMAIL}
- GCNOTIFY_ONBOARDING_REQUEST_EMAIL_TEMPLATE=${GCNOTIFY_ONBOARDING_REQUEST_EMAIL_TEMPLATE}
- GCNOTIFY_ONBOARDING_REQUEST_SMS_TEMPLATE=${GCNOTIFY_ONBOARDING_REQUEST_SMS_TEMPLATE}
- GCNOTIFY_EMAIL_URL=${GCNOTIFY_EMAIL_URL}
- GCNOTIFY_SMS_URL=${GCNOTIFY_SMS_URL}
- APP_HOST=${APP_HOST}
volumes:
- ./api:/opt/app-root/src
- /opt/app-root/src/node_modules # prevents local node_modules overriding container node_modules
networks:
- local-network
depends_on:
- db
- db_setup
# Build the clamav docker image
clamav:
image: mkodockx/docker-clamav:latest
container_name: ${DOCKER_PROJECT_NAME}-clamav-${DOCKER_NAMESPACE}-container
ports:
- ${CLAMAV_PORT}:${CLAMAV_PORT}
networks:
- local-network
depends_on:
- api
# Build the n8n nginx proxy docker image
n8n_nginx:
image: ${DOCKER_PROJECT_NAME}-n8n-nginx-${DOCKER_NAMESPACE}-img
container_name: ${DOCKER_PROJECT_NAME}-n8n-nginx-${DOCKER_NAMESPACE}-container
build:
context: ./.docker/nginx/n8n
dockerfile: Dockerfile
restart: always
ports:
- 5100:5100
networks:
- local-network
depends_on:
- n8n
## Build the n8n workflow automation image
n8n:
image: n8nio/n8n:0.144.0
container_name: ${DOCKER_PROJECT_NAME}-n8n-${DOCKER_NAMESPACE}-container
ports:
- ${N8N_PORT}:${N8N_PORT}
environment:
- NODE_ENV=${NODE_ENV}
- N8N_HOST=${N8N_HOST}
- N8N_PROTOCOL=${N8N_PROTOCOL}
- N8N_PORT=${N8N_PORT}
- WEBHOOK_TUNNEL_URL=${WEBHOOK_TUNNEL_URL}
- DB_TYPE=${N8N_DB_TYPE}
- DB_POSTGRESDB_HOST=${DB_HOST}
- DB_POSTGRESDB_USER=${DB_ADMIN}
- DB_POSTGRESDB_PASSWORD=${DB_ADMIN_PASS}
- DB_POSTGRESDB_PORT=${DB_PORT}
- DB_POSTGRESDB_DATABASE=${DB_DATABASE}
- DB_POSTGRESDB_SCHEMA=${N8N_DB_SCHEMA}
- N8N_BASIC_AUTH_ACTIVE=${N8N_BASIC_AUTH_ACTIVE}
- N8N_BASIC_AUTH_USER=${N8N_BASIC_AUTH_USER}
- N8N_BASIC_AUTH_PASSWORD=${N8N_BASIC_AUTH_PASSWORD}
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
- N8N_API_HOST=${N8N_API_HOST}
- N8N_API_PORT=${API_PORT}
networks:
- local-network
volumes:
- ./n8n/.n8n:/home/node/.n8n
depends_on:
- api
- app
restart: always # n8n doesnt always start after db_setup is done, and can fail. Always restart to help resolve this.
command: ["n8n", "start"]
## Run the n8n setup
n8n_setup:
image: ${DOCKER_PROJECT_NAME}-n8n-setup-${DOCKER_NAMESPACE}-img
container_name: ${DOCKER_PROJECT_NAME}-n8n-setup-${DOCKER_NAMESPACE}-container
build:
context: ./n8n
dockerfile: ./.docker/n8n/Dockerfile.setup
environment:
- NODE_ENV=${NODE_ENV}
- DB_TYPE=${N8N_DB_TYPE}
- DB_POSTGRESDB_HOST=${DB_HOST}
- DB_POSTGRESDB_USER=${DB_ADMIN}
- DB_POSTGRESDB_PASSWORD=${DB_ADMIN_PASS}
- DB_POSTGRESDB_PORT=${DB_PORT}
- DB_POSTGRESDB_DATABASE=${DB_DATABASE}
- DB_POSTGRESDB_SCHEMA=${N8N_DB_SCHEMA}
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
volumes:
- /opt/app-root/src/node_modules # prevents local node_modules overriding container node_modules
- ./n8n:/opt/app-root/src
networks:
- local-network
depends_on:
- n8n
## Export the n8n credentials and workflows
n8n_export:
image: ${DOCKER_PROJECT_NAME}-n8n-export-${DOCKER_NAMESPACE}-img
container_name: ${DOCKER_PROJECT_NAME}-n8n-export-${DOCKER_NAMESPACE}-container
build:
context: ./n8n
dockerfile: ./.docker/n8n/Dockerfile.export
environment:
- NODE_ENV=${NODE_ENV}
- DB_TYPE=${N8N_DB_TYPE}
- DB_POSTGRESDB_HOST=${DB_HOST}
- DB_POSTGRESDB_USER=${DB_ADMIN}
- DB_POSTGRESDB_PASSWORD=${DB_ADMIN_PASS}
- DB_POSTGRESDB_PORT=${DB_PORT}
- DB_POSTGRESDB_DATABASE=${DB_DATABASE}
- DB_POSTGRESDB_SCHEMA=${N8N_DB_SCHEMA}
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
volumes:
- /opt/app-root/src/node_modules # prevents local node_modules overriding container node_modules
- ./n8n:/opt/app-root/src
networks:
- local-network
depends_on:
- n8n
## Build the app docker image
app:
image: ${DOCKER_PROJECT_NAME}-app-${DOCKER_NAMESPACE}-img
container_name: ${DOCKER_PROJECT_NAME}-app-${DOCKER_NAMESPACE}-container
build:
context: ./app
dockerfile: ./.docker/app/Dockerfile
stdin_open: true
ports:
- ${APP_PORT}:${APP_PORT}
environment:
- NODE_ENV=${NODE_ENV}
- REACT_APP_NODE_ENV=${NODE_ENV}
- PORT=${APP_PORT}
- REACT_APP_API_HOST=http://${API_HOST}
- REACT_APP_API_PORT=${API_PORT}
- REACT_APP_MAX_UPLOAD_NUM_FILES=${MAX_UPLOAD_NUM_FILES}
- REACT_APP_MAX_UPLOAD_FILE_SIZE=${MAX_UPLOAD_FILE_SIZE}
- REACT_APP_SITEMINDER_LOGOUT_URL=${SITEMINDER_LOGOUT_URL}
- REACT_APP_N8N_HOST=${N8N_HOST}
- REACT_APP_N8N_PORT=${N8N_PROXY_PORT}
- REACT_APP_KEYCLOAK_HOST=${KEYCLOAK_HOST}
- REACT_APP_KEYCLOAK_REALM=${KEYCLOAK_REALM}
- REACT_APP_KEYCLOAK_CLIENT_ID=${KEYCLOAK_CLIENT_ID}
volumes:
- ./app:/opt/app-root/src
- /opt/app-root/src/node_modules # prevents local node_modules overriding container node_modules
networks:
- local-network
## Run the database migrations and seeding
db_setup:
image: ${DOCKER_PROJECT_NAME}-db-setup-${DOCKER_NAMESPACE}-img
container_name: ${DOCKER_PROJECT_NAME}-db-setup-${DOCKER_NAMESPACE}-container
build:
context: ./database
dockerfile: ./.docker/db/Dockerfile.setup
environment:
- NODE_ENV=${NODE_ENV}
- DB_HOST=${DB_HOST}
- DB_ADMIN=${DB_ADMIN}
- DB_ADMIN_PASS=${DB_ADMIN_PASS}
- DB_PORT=5432
- DB_DATABASE=${DB_DATABASE}
- DB_SCHEMA=${DB_SCHEMA}
- DB_USER_API=${DB_USER_API}
- DB_USER_API_PASS=${DB_USER_API_PASS}
- DB_SCHEMA_DAPI_V1=${DB_SCHEMA_DAPI_V1}
volumes:
- /opt/app-root/src/node_modules # prevents local node_modules overriding container node_modules
networks:
- local-network
depends_on:
db:
condition: service_healthy
command: ["npm", "run", "setup"]
## Run the database migrations
db_migrate:
image: ${DOCKER_PROJECT_NAME}-db-migrate-${DOCKER_NAMESPACE}-img
container_name: ${DOCKER_PROJECT_NAME}-db-migrate-${DOCKER_NAMESPACE}-container
build:
context: ./database
dockerfile: ./.docker/db/Dockerfile.migrate
environment:
- NODE_ENV=${NODE_ENV}
- DB_HOST=${DB_HOST}
- DB_ADMIN=${DB_ADMIN}
- DB_ADMIN_PASS=${DB_ADMIN_PASS}
- DB_PORT=5432
- DB_DATABASE=${DB_DATABASE}
- DB_SCHEMA=${DB_SCHEMA}
- DB_USER_API=${DB_USER_API}
- DB_USER_API_PASS=${DB_USER_API_PASS}
- DB_SCHEMA_DAPI_V1=${DB_SCHEMA_DAPI_V1}
volumes:
- /opt/app-root/src/node_modules # prevents local node_modules overriding container node_modules
networks:
- local-network
depends_on:
db:
condition: service_healthy
command: ["npm", "run", "migrate-latest"]
## Rollback the latest database migrations
db_rollback:
image: ${DOCKER_PROJECT_NAME}-db-rollback-${DOCKER_NAMESPACE}-img
container_name: ${DOCKER_PROJECT_NAME}-db-rollback-${DOCKER_NAMESPACE}-container
build:
context: ./database
dockerfile: ./.docker/db/Dockerfile.rollback
environment:
- NODE_ENV=${NODE_ENV}
- DB_HOST=${DB_HOST}
- DB_ADMIN=${DB_ADMIN}
- DB_ADMIN_PASS=${DB_ADMIN_PASS}
- DB_PORT=5432
- DB_DATABASE=${DB_DATABASE}
- DB_SCHEMA=${DB_SCHEMA}
- DB_USER_API=${DB_USER_API}
- DB_USER_API_PASS=${DB_USER_API_PASS}
- DB_SCHEMA_DAPI_V1=${DB_SCHEMA_DAPI_V1}
volumes:
- /opt/app-root/src/node_modules # prevents local node_modules overriding container node_modules
networks:
- local-network
depends_on:
db:
condition: service_healthy
command: ["npm", "run", "migrate-rollback"]
networks:
local-network:
driver: bridge
volumes:
postgres:
name: ${DOCKER_PROJECT_NAME}-db-${DOCKER_NAMESPACE}-vol