-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-compose.yml
152 lines (152 loc) · 4.46 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
version: '3.7'
x-images: # Only to create template
django: &django
env_file: docker.env
environment:
- GUNICORN_WORKERS=8
- GUNICORN_WORKER_CLASS=sync
tty: true
# image: "${DJANGO_IMAGE}:${DJANGO_IMAGE_VERSION}-dev"
# latest image is only used in prod (without dev & test tools)
depends_on:
- db
- redis
- setup-postgres
working_dir: /code/src
command:
- sh
- '-c'
- >-
:
&& dockerize -wait http://setup-postgres -timeout $${POSTGRES_STARTUP_TIMEOUT:-120s}
&& /bin/bash /code/init/init.sh
volumes:
- mediafiles:/code/public/media
- statics:/code/public/static
- logs:/logs/
- share:/share/ # To share file between containers
services:
redis:
image: 'corpusops/redis:4.0-alpine'
hostname: redis
volumes:
- 'redis:/data'
db:
image: 'corpusops/pgrouting:10-2.5-2.6'
env_file: docker.env
volumes:
- postgresql:/var/lib/postgresql/data
nginx:
restart: always
image: 'corpusops/nginx:1.14-alpine'
env_file: docker.env
depends_on:
- django
- elasticsearch
ports:
- ${VISU_PORT:-80}:80
volumes:
- ./prod/etc/nginx/vhost.conf.template:/etc/nginx/conf.d/default.conf.template
- mediafiles:/public/media/:ro
- statics:/public/static/
- logs:/logs/
- cache:/cache/
command: >
/bin/sh -c "
CONF_PREFIX=FRONT_ confenvsubst.sh /etc/nginx/conf.d/default.conf.template
&& exec /bin/supervisord.sh"
environment:
- SUPERVISORD_CONFIGS=/etc/supervisor.d/cron /etc/supervisor.d/nginx /etc/supervisor.d/rsyslog
django:
<<: [*django]
healthcheck:
test:
[
'CMD-SHELL',
'curl --fail http://localhost:8000/api/settings || exit 1',
]
celery:
<<: [*django]
healthcheck:
test:
['CMD-SHELL', '/code/venv/bin/celery -A project.celery inspect ping']
environment:
- DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-project.settings.prod}
command:
- sh
- '-c'
- >-
:
&& dockerize -wait http://setup-postgres -timeout $${POSTGRES_STARTUP_TIMEOUT:-120s}
&& /code/venv/bin/celery -A project.celery worker -l INFO --autoscale 10,3
depends_on:
- django
celerybeat:
<<: [*django]
healthcheck:
test:
['CMD-SHELL', '/code/venv/bin/celery -A project.celery inspect ping']
environment:
- DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-project.settings.prod}
command:
- sh
- '-c'
- >-
:
&& dockerize -wait http://setup-postgres -timeout $${POSTGRES_STARTUP_TIMEOUT:-120s}
&& /code/venv/bin/celery -A project.celery beat -l INFO
depends_on:
- django
elasticsearch:
hostname: elasticsearch
image: elasticsearch:7.16.2
env_file: docker.env
environment:
ES_JAVA_OPTS: ${ES_JAVA_OPTS:--Xms1g -Xmx1g}
healthcheck:
test:
[
'CMD-SHELL',
'curl --silent --fail localhost:9200/_cluster/health || exit 1',
]
interval: 30s
timeout: 30s
retries: 3
volumes:
- ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- elasticsearch:/usr/share/elasticsearch/data/
setup-postgres:
image: corpusops/pgrouting:10-2.5-2.6
env_file: docker.env
depends_on:
- db
entrypoint:
- /bin/sh
- '-c'
- |-
set -ex
POSTGRES_STARTUP_TIMEOUT=$${POSTGRES_STARTUP_TIMEOUT:-120s}
POSTGRES_HOST=$${POSTGRES_HOST:-db}
POSTGRES_PORT=$${POSTGRES_PORT:-5432}
flag=/started_$$(echo $$POSTGRES_DB|sed -re "s![/:]!__!g")
if [ -e "$$flag" ];then rm -f "$$flag";fi
echo "Try connection to pgsql: $$POSTGRES_DB & wait for db init" >&2 \
&& ( while true;do if ( \
echo "select 1 from spatial_ref_sys limit 1;select postgis_version();"\
| psql -v ON_ERROR_STOP=1 \
"postgres://$$POSTGRES_USER:$$POSTGRES_PASSWORD@$$POSTGRES_HOST:$$POSTGRES_PORT/$$POSTGRES_DB"\
);then touch $$flag && break;fi;done )&
set -x \
&& dockerize -wait file://$$flag -timeout $${POSTGRES_STARTUP_TIMEOUT:-120s} \
&& while true;do printf "HTTP/1.1 200 OK\nContent-Length: 8\n\nstarted"| ( busybox nc -l -p 80 || /bin/true );done
volumes:
postgresql:
redis:
mediafiles:
statics:
name: 'visu-back-statics'
external: false
logs:
elasticsearch:
cache:
share: