-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
135 lines (126 loc) · 3.27 KB
/
docker-compose.prod.yml
File metadata and controls
135 lines (126 loc) · 3.27 KB
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
# Shark AI
# Author: Cristobal Barberis
# License: Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
# For academic use only. Commercial use is prohibited without prior written permission.
# Contact: [email protected]
#
# File: docker-compose.prod.yml
# Copyright (c) 2024
services:
backend:
build:
context: ./backend
dockerfile: Dockerfile.prod
command: /bin/sh -c "sleep 5 &&
python manage.py makemigrations --noinput &&
python manage.py migrate --noinput &&
python manage.py shell -c \"from django.contrib.auth.models import User; User.objects.filter(username='testuser').exists() or User.objects.create_superuser('testuser', '[email protected]', 'testpassword')\" &&
python manage.py runserver 0.0.0.0:8000"
volumes:
- static_volume:/usr/src/app/staticfiles
# - media_volume:/usr/src/app/mediafiles
- ./backend/:/usr/src/app/
expose:
- 8000
env_file:
- ./.env.prod
environment:
- CELERY_BROKER_URL=redis://redis:6379/0
depends_on:
- db
- redis
networks:
- backend
db:
image: postgres:15
volumes:
- postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=backend
- POSTGRES_PASSWORD=backend
- POSTGRES_DB=backend_prod
networks:
- backend
redis:
image: redis
ports:
- 6379:6379
networks:
- backend
celery_worker:
build:
context: ./backend
dockerfile: Dockerfile.prod
command: celery -A celery_app worker --loglevel=info --max-tasks-per-child=1
env_file:
- ./.env.prod
depends_on:
- db
- redis
environment:
- CELERYD_MAX_TASKS_PER_CHILD=1
- CELERYD_TASK_TIME_LIMIT=3600
- CELERYD_TASK_SOFT_TIME_LIMIT=3500
- LD_LIBRARY_PATH="$CUDNN_PATH/lib":"/usr/local/cuda/lib64"
- NVIDIA_VISIBLE_DEVICES=all
- TF_FORCE_GPU_ALLOW_GROWTH=true
- PATH="$PATH":"/usr/local/cuda/bin"
- PATH=/usr/local/cuda/bin:$PATH
- LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
# - TF_GPU_ALLOCATOR=cuda_malloc_async
volumes:
- ./backend/:/usr/src/app/
- static_volume:/usr/src/app/staticfiles
# - media_volume:/usr/src/app/mediafiles
deploy:
resources:
limits:
memory: 8g
reservations:
memory: 4g
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
runtime: nvidia
ipc: host
ulimits:
memlock:
soft: -1
hard: -1
stack:
soft: 67108864
hard: 67108864
networks:
- backend
restart: always
frontend:
build: ./frontend
command: npm run start
volumes:
- static_volume:/usr/src/app/.next/static
expose:
- 3000
env_file:
- ./.env.prod
networks:
- backend
nginx:
build: ./nginx
volumes:
- static_volume:/usr/src/app/staticfiles
# - media_volume:/usr/src/app/mediafiles
ports:
- "80:80"
- "443:443"
depends_on:
- backend
networks:
- backend
volumes:
postgres_data:
static_volume:
# media_volume:
networks:
backend:
driver: bridge