-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
197 lines (187 loc) · 4.34 KB
/
docker-compose.prod.yml
File metadata and controls
197 lines (187 loc) · 4.34 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
version: '3.8'
services:
# Django backend service
backend:
image: ghcr.io/${GITHUB_REPOSITORY}:production
restart: unless-stopped
volumes:
- static-data:/app/staticfiles
- media-data:/app/media
ports:
- "8000:8000"
depends_on:
- redis
env_file:
- .env.production
environment:
- DJANGO_DEBUG=False
- DJANGO_ALLOWED_HOSTS=${DOMAIN},backend
deploy:
resources:
limits:
cpus: '1.5'
memory: 1G
reservations:
cpus: '0.5'
memory: 512M
networks:
- app-network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Redis for Celery and caching
redis:
image: redis:7-alpine
restart: unless-stopped
volumes:
- redis-data:/data
command: redis-server --appendonly yes
networks:
- app-network
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "3"
# Celery worker for background tasks
celery:
image: ghcr.io/${GITHUB_REPOSITORY}:production
restart: unless-stopped
command: celery -A core worker -l info
depends_on:
- redis
- backend
env_file:
- .env.production
environment:
- C_FORCE_ROOT=true
deploy:
resources:
limits:
cpus: '1'
memory: 768M
networks:
- app-network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Celery beat for scheduled tasks
celery-beat:
image: ghcr.io/${GITHUB_REPOSITORY}:production
restart: unless-stopped
command: celery -A core beat -l info
depends_on:
- redis
- backend
env_file:
- .env.production
networks:
- app-network
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "3"
# Prometheus for metrics
prometheus:
image: prom/prometheus:v2.44.0
restart: unless-stopped
volumes:
- ./config/prometheus:/etc/prometheus
- prometheus-data:/prometheus
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --web.console.libraries=/etc/prometheus/console_libraries
- --web.console.templates=/etc/prometheus/consoles
- --web.enable-lifecycle
ports:
- "9090:9090"
networks:
- app-network
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "3"
# Grafana for visualization
grafana:
image: grafana/grafana:9.5.2
restart: unless-stopped
volumes:
- grafana-data:/var/lib/grafana
- ./config/grafana/provisioning:/etc/grafana/provisioning
- ./config/grafana/dashboards:/var/lib/grafana/dashboards
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin}
- GF_USERS_ALLOW_SIGN_UP=false
ports:
- "3000:3000"
networks:
- app-network
depends_on:
- prometheus
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "3"
# Node exporter for system metrics
node-exporter:
image: prom/node-exporter:v1.5.0
restart: unless-stopped
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- --path.procfs=/host/proc
- --path.rootfs=/rootfs
- --path.sysfs=/host/sys
- --collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)
ports:
- "9100:9100"
networks:
- app-network
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "3"
# NGINX for static files and reverse proxy
nginx:
image: nginx:1.25-alpine
restart: unless-stopped
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
- static-data:/var/www/static
- media-data:/var/www/media
- ./nginx/ssl:/etc/nginx/ssl
ports:
- "80:80"
- "443:443"
depends_on:
- backend
- grafana
- prometheus
networks:
- app-network
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "3"
networks:
app-network:
driver: bridge
volumes:
static-data:
media-data:
redis-data:
prometheus-data:
grafana-data: