-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
140 lines (133 loc) · 4.69 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
version: "3.7"
networks:
backend:
frontend:
secrets:
mongodb_root_username:
file: secrets/mongodb_root_username.txt
# external: true
mongodb_root_password:
file: secrets/mongodb_root_password.txt
# external: true
countly_mongodb_username:
file: secrets/countly_mongodb_username.txt
# external: true
countly_mongodb_password:
file: secrets/countly_mongodb_password.txt
# external: true
services:
mongodb:
image: "mongo:4.2"
hostname: mongodb
environment:
# set root user and password to set mongo into authentication mode
- MONGO_INITDB_ROOT_USERNAME_FILE=/run/secrets/mongodb_root_username
- MONGO_INITDB_ROOT_PASSWORD_FILE=/run/secrets/mongodb_root_password
- MONGODB_DATABASE=${MONGODB_DATABASE}
volumes:
# make mongo database persistent
- ./data/mongodb:/data/db
# add folder with initialization script to create countly database user and password
- ./config/mongo:/docker-entrypoint-initdb.d:ro
networks:
backend:
secrets:
- mongodb_root_username
- mongodb_root_password
- countly_mongodb_username
- countly_mongodb_password
healthcheck:
test: [ "CMD", "echo", "'db.runCommand(\"ping\").ok'", "|", "mongo", "localhost", "--quiet" ]
timeout: 120s
interval: 10s
retries: 10
# deploy:
# placement:
# constraints: [node.role == manager]
# replicas: 1
# update_config:
# parallelism: 2
# delay: 10s
# restart_policy:
# condition: on-failure
api:
image: markdumay/countly-api:20.04
volumes:
- ./config/countly/config_api.js:/opt/countly/api/config.js:ro
- ./config/countly/config_frontend.js:/opt/countly/frontend/express/config.js:ro
environment:
- COUNTLY_CONFIG_API_MONGODB_HOST=mongodb
- COUNTLY_CONFIG_API_MONGODB_DB=${MONGODB_DATABASE}
- COUNTLY_CONFIG_FRONTEND_MONGODB_HOST=mongodb
- COUNTLY_CONFIG_FRONTEND_MONGODB_DB=${MONGODB_DATABASE}
- WAIT_HOSTS=mongodb:27017
- WAIT_SLEEP_INTERVAL=5
- WAIT_HOSTS_TIMEOUT=300
- COUNTLY_CONFIG_HOSTNAME=${DOMAINS_COUNTLY}
deploy:
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 600s
networks:
frontend:
backend:
secrets:
- countly_mongodb_username
- countly_mongodb_password
depends_on:
- mongodb
frontend:
image: markdumay/countly-frontend:20.04
volumes:
- ./config/countly/config_api.js:/opt/countly/api/config.js:ro
- ./config/countly/config_frontend.js:/opt/countly/frontend/express/config.js:ro
environment:
- COUNTLY_CONFIG_API_MONGODB_HOST=mongodb
- COUNTLY_CONFIG_API_MONGODB_DB=${MONGODB_DATABASE}
- COUNTLY_CONFIG_FRONTEND_MONGODB_HOST=mongodb
- COUNTLY_CONFIG_FRONTEND_MONGODB_DB=${MONGODB_DATABASE}
- WAIT_HOSTS=mongodb:27017
- WAIT_SLEEP_INTERVAL=5
- WAIT_HOSTS_TIMEOUT=300
- COUNTLY_CONFIG_HOSTNAME=${DOMAINS_COUNTLY}
networks:
frontend:
backend:
secrets:
- countly_mongodb_username
- countly_mongodb_password
depends_on:
- mongodb
deploy:
# There is usually no need in multiple frontends, so throttling down resources for it
mode: global
# resources:
# limits:
# cpus: '0.5'
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 600s
portal:
image: steveltn/https-portal:1
ports:
- 80:80
- 443:443
links:
- api
- frontend
restart: always
networks:
frontend:
volumes:
- ./data/portal:/var/lib/https-portal
- ./config/portal/http.conf.erb:/var/lib/nginx-conf/${DOMAINS_COUNTLY}.conf.erb:ro
- ./config/portal/https.conf.erb:/var/lib/nginx-conf/${DOMAINS_COUNTLY}.ssl.conf.erb:ro
environment:
DOMAINS: "${DOMAINS_COUNTLY} -> ${COUNTLY_FRONTEND_HOST}"
COUNTLY_API_HOST: "${COUNTLY_API_HOST}"
STAGE: local
# STAGE: production