-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdocker-compose.yml
112 lines (105 loc) · 2.67 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
version: "3"
services:
postgres:
image: mdillon/postgis:10-alpine
container_name: osmvalidator_postgres
restart: always
environment:
PG_DATABASE: $PG_DATABASE
# https://docs.docker.com/samples/library/postgres/#environment-variables
POSTGRES_USER: $PG_USER
POSTGRES_PASSWORD: $PG_PASSWORD
# https://www.postgresql.org/docs/10/static/libpq-envars.html
PGUSER: $PG_USER
PGPASSWORD: $PG_PASSWORD
volumes:
# https://github.com/docker-library/postgres/blob/master/10/docker-entrypoint.sh#L126
- ./config/db-init.sh:/docker-entrypoint-initdb.d/osmvalidator.sh
- db-data:/var/lib/postgresql/data
ports:
- 5432
redis:
image: redis:4-alpine
container_name: osmvalidator_redis
restart: always
ports:
- 6379
scheduler:
container_name: osmvalidator_scheduler
image: osmvalidator
build: .
env_file:
- .env
environment:
PGPASSWORD: $PG_PASSWORD
PG_HOST: postgres
REDIS_HOST: redis
links:
- postgres
- redis
depends_on:
- postgres
- redis
command:
- bash
- -c
- |
until [[ $$((echo > /dev/tcp/postgres/5432) >/dev/null 2>&1; echo $$?) -eq 0 ]]; do
echo waiting until postgres will be available
sleep 10
done
pipenv run alembic upgrade head
while true; do
pipenv run python schedule.py
sleep $OSM_CHECK_TIMEOUT
done
web:
container_name: osmvalidator_web
restart: always
image: osmvalidator
build: .
env_file:
- .env
environment:
PGPASSWORD: $PG_PASSWORD
PG_HOST: postgres
REDIS_HOST: redis
links:
- postgres
- redis
depends_on:
- postgres
- redis
- scheduler
command:
- bash
- -c
- |
until [[ $$((echo > /dev/tcp/postgres/5432) >/dev/null 2>&1; echo $$?) -eq 0 ]]; do
echo waiting until postgres will be available
sleep 10
done
until [[ $$(pipenv run alembic current 2>/dev/null) == *" (head)" ]]; do
echo waiting until migrations will be applied
sleep 10
done
pipenv run python main.py --host 0.0.0.0 --port 8080
nginx:
image: nginx:stable-alpine
container_name: osmvalidator_nginx
restart: always
environment:
NGINX_PORT: $NGINX_PORT
volumes:
- ./config/nginx.conf:/tmp/nginx.conf
ports:
- 8080:$NGINX_PORT
depends_on:
- web
command:
- sh
- -c
- |
envsubst '$${NGINX_PORT}' < /tmp/nginx.conf > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'
volumes:
db-data: