-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocker-compose-production.yml
277 lines (264 loc) · 7.6 KB
/
docker-compose-production.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
services:
web:
container_name: trusted-web-main
build:
context: .
dockerfile: dockerFiles/api_docker
depends_on:
elasticsearch:
condition: service_healthy
mongo:
condition: service_healthy
env_file:
- .env
command:
- /bin/sh
- -c
- >
if [ "$PRODUCTION" = "1" ]; then
python manage.py collectstatic --noinput &&
echo "Production mode: Running compression..." &&
python manage.py compress --follow-links --force &&
echo "Production mode: Compressing static files..." &&
find /app/staticfiles -type f -exec gzip -k {} \;;
else
echo "Non-production mode: Skipping compression and gzip.";
fi &&
gunicorn trustly.wsgi:application --bind 0.0.0.0:8070 --reload &
sleep 10 && python manage.py cronjob_manager
volumes:
- .:/app:cached
- ./trustly/templates:/app/trustly/templates:cached
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./static:/app/static:cached
- ./staticfiles:/app/staticfiles:cached
- media_volume:/app/media
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- /var/www/certbot:/var/www/certbot
- /etc/letsencrypt:/etc/letsencrypt:ro
expose:
- "8070"
environment:
NLTK_DATA: /root/nltk_data
DJANGO_SETTINGS_MODULE: trustly.settings
DISABLE_TEMPLATE_CACHING: "1"
networks:
- backend
- shared_bridge
healthcheck:
test: ["CMD-SHELL", "exit 0"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 1G
swagger:
container_name: trusted-web-swagger
image: swaggerapi/swagger-ui:latest
ports:
- "8082:8080"
environment:
SWAGGER_JSON: /swagconfig/swaggerconfig.json
SWAGGER_UI_SYNTAX_HIGHLIGHT: "false"
SWAGGER_UI_CORS_ENABLED: "true"
SWAGGER_UI_DOC_EXPANSION: "none"
SWAGGER_UI_DEFAULT_MODELS_EXPAND_DEPTH: -1
SWAGGER_UI_DEFAULT_MODEL_EXPAND_DEPTH: -1
SWAGGER_UI_ALLOWED_ORIGINS: "*"
SWAGGER_UI_RESPONSE_HIGHLIGHT: "false"
volumes:
- ./swagconfig:/usr/share/nginx/html
restart: unless-stopped
depends_on:
- web
networks:
backend:
ipv4_address: 172.20.1.15
labels:
- "traefik.enable=true"
- "traefik.http.routers.swagger.rule=Host(`swagger.orion.genesistechnologies.org`)"
- "traefik.http.routers.swagger.tls=true"
- "traefik.http.routers.swagger.entrypoints=websecure"
- "traefik.http.services.swagger.loadbalancer.server.port=8080"
- "traefik.http.routers.swagger.middlewares=auth@file"
elasticsearch:
container_name: trusted-web-elastic
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.5
environment:
- discovery.type=single-node
- network.host=0.0.0.0
- http.port=9400
- ELASTIC_USERNAME=${ELASTIC_ROOT_USERNAME}
- ELASTIC_PASSWORD=${ELASTIC_ROOT_PASSWORD}
- xpack.security.enabled=false
- xpack.security.transport.ssl.enabled=false
- ES_JAVA_OPTS=-Xms512m -Xmx512m
- indices.memory.index_buffer_size=5%
- node.store.allow_mmap=false
env_file:
- .env
ports:
- "9400:9400"
volumes:
- elastic:/usr/share/elasticsearch/data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9400/_cluster/health"]
interval: 20s
timeout: 10s
retries: 5
start_period: 30s
networks:
backend:
ipv4_address: 172.20.1.11
deploy:
resources:
limits:
memory: 1G
traefik:
image: traefik:v2.10
container_name: trusted-web-traefik
ports:
- "9090:9090"
- "9443:9443"
command:
- "--entrypoints.web.address=:9090"
- "--entrypoints.websecure.address=:9443"
- "--providers.file.filename=/etc/traefik/dynamic.yml"
- "--providers.docker=true"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./dockerFiles/traefik/dynamic.yml:/etc/traefik/dynamic.yml:ro
- /etc/letsencrypt/live/orion.genesistechnologies.org/cert.pem:/certs/cert.pem:ro
- /etc/letsencrypt/live/orion.genesistechnologies.org/privkey.pem:/certs/privkey.pem:ro
restart: unless-stopped
networks:
- backend
- shared_bridge
dozzle:
container_name: trusted-web-dozzle
image: amir20/dozzle:latest
networks:
- backend
volumes:
- /var/run/docker.sock:/var/run/docker.sock
labels:
- "traefik.enable=true"
- "traefik.http.routers.dozzle.rule=Host(`dozzle.orion.genesistechnologies.org`)"
- "traefik.http.routers.dozzle.tls=true"
- "traefik.http.routers.dozzle.entrypoints=websecure"
- "traefik.http.routers.dozzle.middlewares=auth@file"
- "traefik.http.services.dozzle.loadbalancer.server.port=8080"
restart: unless-stopped
redis_server:
container_name: trusted-web-redis
image: redis:7.4.0
logging:
driver: none
command: ["redis-server", "--requirepass", "${REDIS_PASSWORD}"]
restart: always
env_file:
- .env
volumes:
- redis:/data
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
interval: 10s
timeout: 5s
retries: 3
networks:
backend:
ipv4_address: 172.20.1.12
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 128M
nginx:
container_name: trusted-web-nginx
image: nginx:latest
ports:
- "80:80"
- "443:443"
depends_on:
- web
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./static:/app/static:cached
- ./staticfiles:/app/staticfiles:cached
- media_volume:/app/media
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- /var/www/certbot:/var/www/certbot
- /etc/letsencrypt:/etc/letsencrypt:ro
networks:
backend:
ipv4_address: 172.20.1.13
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:80 || exit 1"]
interval: 30s
timeout: 5s
retries: 3
mongo:
image: mongo:latest
container_name: trustly-web-mongodb
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD}
ports:
- "27020:27017"
volumes:
- mongo:/data/db
command: >
bash -c "
mongod --bind_ip_all --fork --logpath /var/log/mongodb.log &&
sleep 10 &&
mongosh --eval '
db = db.getSiblingDB(\"admin\");
if (db.getUser(\"${MONGO_ROOT_USERNAME}\") === null) {
db.createUser({
user: \"${MONGO_ROOT_USERNAME}\",
pwd: \"${MONGO_ROOT_PASSWORD}\",
roles: [{ role: \"userAdminAnyDatabase\", db: \"admin\" }, { role: \"readWriteAnyDatabase\", db: \"admin\" }]
});
}
' &&
mongod --shutdown &&
sleep 5 &&
mongod --auth --bind_ip_all --fork --logpath /var/log/mongodb.log &&
tail -f /var/log/mongodb.log
"
networks:
backend:
ipv4_address: 172.20.1.14
healthcheck:
test: ["CMD-SHELL", "timeout 5 bash -c '</dev/tcp/localhost/27017' || exit 1"]
interval: 30s
timeout: 10s
retries: 3
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 128M
networks:
shared_bridge:
external: true
backend:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.20.1.0/24
volumes:
redis:
mongo:
elastic:
static_volume:
media_volume: