-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
147 lines (139 loc) · 4.01 KB
/
Copy pathdocker-compose.yml
File metadata and controls
147 lines (139 loc) · 4.01 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
136
137
138
139
140
141
142
143
144
145
146
147
# Before running `docker compose up`, create code/backend/.env from
# code/backend/.env.example and fill in real values. Every service below
# loads that file via env_file, so this is the single source of truth for
# both local (non-Docker) and Docker Compose runs.
services:
db:
image: postgres:16-alpine
restart: unless-stopped
env_file:
- ./code/backend/.env
volumes:
- postgres_data:/var/lib/postgresql/data
- ./infrastructure/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER}"]
interval: 10s
timeout: 5s
retries: 5
ports:
- "5433:5433"
redis:
image: redis:7-alpine
restart: unless-stopped
command: redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
ports:
- "6379:6379"
backend:
build:
context: ./code/backend
dockerfile: Dockerfile
restart: unless-stopped
command: >
sh -c "python manage.py migrate --noinput &&
python manage.py collectstatic --noinput &&
gunicorn quantumwealth.wsgi:application
--bind 0.0.0.0:8000
--workers 4
--timeout 120
--log-level info"
volumes:
- static_files:/app/staticfiles
- media_files:/app/media
- ./code/ai_models:/app/ai_models:ro
env_file:
- ./code/backend/.env
environment:
# These three must differ from local-dev .env values (which point at
# localhost) regardless of what's in the .env file, so they stay as
# explicit overrides - Compose always prefers an explicit environment
# entry over the same key loaded from env_file.
DJANGO_SETTINGS_MODULE: quantumwealth.settings.production
DB_HOST: db
DB_PORT: 5433
REDIS_URL: redis://redis:6379/0
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/schema/"]
interval: 30s
timeout: 10s
retries: 3
celery_worker:
build:
context: ./code/backend
dockerfile: Dockerfile
restart: unless-stopped
command: celery -A quantumwealth worker --loglevel=info --concurrency=4
volumes:
- ./code/ai_models:/app/ai_models:ro
env_file:
- ./code/backend/.env
environment:
DJANGO_SETTINGS_MODULE: quantumwealth.settings.production
DB_HOST: db
DB_PORT: 5433
REDIS_URL: redis://redis:6379/0
depends_on:
- backend
- redis
- db
celery_beat:
build:
context: ./code/backend
dockerfile: Dockerfile
restart: unless-stopped
command: celery -A quantumwealth beat --loglevel=info --scheduler django_celery_beat.schedulers:DatabaseScheduler
volumes:
- ./code/ai_models:/app/ai_models:ro
env_file:
- ./code/backend/.env
environment:
DJANGO_SETTINGS_MODULE: quantumwealth.settings.production
DB_HOST: db
DB_PORT: 5433
REDIS_URL: redis://redis:6379/0
depends_on:
- backend
- redis
- db
frontend-build:
image: node:20-alpine
working_dir: /app
volumes:
- ./frontend:/app
- frontend_node_modules:/app/node_modules
- frontend_dist:/app/dist
command: sh -c "npm ci && npm run build"
nginx:
image: nginx:1.25-alpine
restart: unless-stopped
ports:
- "80:80"
volumes:
- ./infrastructure/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- frontend_dist:/usr/share/nginx/html:ro
- static_files:/app/staticfiles:ro
- media_files:/app/media:ro
depends_on:
frontend-build:
condition: service_completed_successfully
backend:
condition: service_healthy
volumes:
postgres_data:
redis_data:
static_files:
media_files:
frontend_node_modules:
frontend_dist: