-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
47 lines (45 loc) · 1.17 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
services:
web:
build: .
ports:
- "5001:5000"
environment:
- FLASK_APP=manage.py
- FLASK_ENV=development
- FLASK_CONFIG=development
- DATABASE_URL=postgresql://postgres:postgres@db:5432/flask_marketplace
- PYTHONUNBUFFERED=1
depends_on:
db:
condition: service_healthy
volumes:
- .:/app
command: >
sh -c "
echo 'Waiting for database...' &&
sleep 5 &&
echo 'Running migrations...' &&
rm -rf migrations &&
python -m flask db init &&
python -m flask db migrate -m 'initial migration' &&
python -m flask db upgrade &&
echo 'Starting gunicorn...' &&
gunicorn --bind 0.0.0.0:5000 --workers 4 --timeout 180 --log-level debug manage:app
"
db:
image: postgres:14-alpine
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=flask_marketplace
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
volumes:
postgres_data: