-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose.yml
55 lines (54 loc) · 1.6 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
services:
web:
build: .
command: sh -c "python manage.py collectstatic --no-input && gunicorn my_fundz.wsgi:application --bind 0.0.0.0:8000"
volumes:
- .:/app
ports:
- "8000:8000"
environment:
- DJANGO_ENV=production # Set DJANGO_ENV to production
- SECRET_KEY=${SECRET_KEY}
- PGDATABASE=${PGDATABASE}
- PGUSER=${PGUSER}
- PGPASSWORD=${PGPASSWORD}
- PGHOST=${PGHOST}
- PGPORT=${PGPORT}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_STORAGE_BUCKET_NAME=${AWS_STORAGE_BUCKET_NAME}
- DEBUG=False
# Only include db service for production mode
depends_on:
- db
- migrations # Just specify "migrations", not "migrations:service_healthy"
db:
image: postgres:14.5
environment:
POSTGRES_DB: ${PGDATABASE}
POSTGRES_USER: ${PGUSER}
POSTGRES_PASSWORD: ${PGPASSWORD}
volumes:
- pgdata:/var/lib/postgresql/data/
healthcheck:
test: ["CMD", "pg_isready", "-h", "localhost", "-p", "5432", "-U", "postgres"]
interval: 5s # Check every 5 seconds
timeout: 5s # Timeout after 5 seconds
retries: 5 # Retry 5 times
migrations:
build: .
command: sh -c "python manage.py makemigrations && python manage.py migrate"
volumes:
- .:/app
depends_on:
- db
environment:
- DJANGO_ENV=production
- SECRET_KEY=${SECRET_KEY}
- PGDATABASE=${PGDATABASE}
- PGUSER=${PGUSER}
- PGPASSWORD=${PGPASSWORD}
- PGHOST=${PGHOST}
- PGPORT=${PGPORT}
volumes:
pgdata: