-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose-prod.yaml
77 lines (72 loc) · 1.75 KB
/
docker-compose-prod.yaml
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
version: '3.8'
services:
db:
restart: always
image: postgres:15-alpine
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
env_file:
- .env # Specify the environment file for the db service
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"]
interval: 10s
timeout: 5s
retries: 5
backend:
restart: always
build:
context: ./backend
dockerfile: Dockerfile.prod
command: >
sh -c "python manage.py makemigrations && python manage.py migrate &&
python manage.py collectstatic --noinput && gunicorn backend.wsgi --bind 0.0.0.0:8000 --workers 3"
ports:
- "8000:8000"
env_file:
- .env
volumes:
- media_data:/usr/src/app/media
- static_data:/usr/src/app/static
depends_on:
db:
condition: service_healthy
deploy:
resources:
limits:
memory: 512M
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.prod
volumes:
- react_build:/usr/src/app/dist
env_file:
- .env
environment:
VITE_BACKEND_URL: ${VITE_BACKEND_URL}
VITE_FRONTEND_URL: ${VITE_FRONTEND_URL}
VITE_MEDIA_URL: ${VITE_MEDIA_URL}
nginx:
restart: always
image: nginx:alpine
ports:
- 80:8080
volumes:
- ./nginx/nginx-setup.conf:/etc/nginx/conf.d/default.conf:ro
- react_build:/var/www/react
- media_data:/var/www/media
- static_data:/var/www/static
depends_on:
- backend
- frontend
volumes:
react_build:
postgres_data:
media_data:
static_data: