-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-compose-disk.yml
191 lines (185 loc) · 4.87 KB
/
docker-compose-disk.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
services:
web:
container_name: trusted-web-main
build:
context: .
dockerfile: dockerFiles/api_docker
depends_on:
elasticsearch:
condition: service_healthy
mongo:
condition: service_started
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
- ./static:/app/static:cached
- ./trustly/templates:/app/trustly/templates:cached
- ./staticfiles:/app/staticfiles:cached
expose:
- "8070"
environment:
NLTK_DATA: /root/nltk_data
DJANGO_SETTINGS_MODULE: trustly.settings
DISABLE_TEMPLATE_CACHING: "1"
networks:
backend:
ipv4_address: 172.20.1.10
healthcheck:
test: ["CMD-SHELL", "exit 0"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 128M
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: curl -f http://localhost:9400/_cluster/health || exit 1
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
networks:
backend:
ipv4_address: 172.20.1.11
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:
- "8080:80"
depends_on:
- web
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./static:/app/static:cached
- ./staticfiles:/app/staticfiles:cached
- media_volume:/app/media
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:
backend:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.20.1.0/24
volumes:
redis:
mongo:
elastic:
static_volume:
media_volume: