-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
183 lines (174 loc) · 5.5 KB
/
docker-compose.yml
File metadata and controls
183 lines (174 loc) · 5.5 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
services:
# Django backend service
backend:
build:
context: .
dockerfile: docker/Dockerfile
volumes:
- ./backend:/app
- sqlite-data:/app/db.sqlite3
ports:
- "8000:8000"
environment:
- POSTGRES_HOST=postgres
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/django_db
- SUPABASE_DB_CONNECTION_STRING=${SUPABASE_DB_CONNECTION_STRING}
- SUPABASE_URL=${SUPABASE_URL}
- SUPABASE_ANON_KEY=${SUPABASE_ANON_KEY}
- SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY}
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_DB=${REDIS_DB}
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD}@redis:${REDIS_PORT}/${REDIS_DB}
- CELERY_RESULT_BACKEND=redis://:${REDIS_PASSWORD}@redis:${REDIS_PORT}/${REDIS_DB}
- REDIS_URL=${REDIS_URL:-redis://:${REDIS_PASSWORD:-redis_password}@redis:${REDIS_PORT:-6379}/${REDIS_DB:-0}}
depends_on:
- redis
- postgres
command: >-
sh -c "python manage.py migrate &&
python manage.py runserver 0.0.0.0:8000"
networks:
- app-network
# PostgreSQL database
postgres:
image: postgres:14
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=django_db
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
ports:
- "5432:5432"
networks:
- app-network
# Redis for Celery and caching
redis:
image: redis:7-alpine
ports:
- "${REDIS_PORT:-6379}:${REDIS_PORT:-6379}"
volumes:
- redis-data:/data
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-redis_password} --maxmemory 256mb --maxmemory-policy allkeys-lru --port ${REDIS_PORT:-6379} --databases ${REDIS_DATABASES:-16}
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-redis_password}", "-p", "${REDIS_PORT:-6379}", "ping"]
interval: 5s
timeout: 5s
retries: 5
networks:
- app-network
# Celery worker for background tasks
celery:
build:
context: .
dockerfile: docker/Dockerfile
volumes:
- ./backend:/app
depends_on:
- redis
- postgres
- backend
env_file:
- .env
environment:
- POSTGRES_HOST=postgres
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/django_db
- SUPABASE_DB_CONNECTION_STRING=${SUPABASE_DB_CONNECTION_STRING}
- SUPABASE_URL=${SUPABASE_URL}
- SUPABASE_ANON_KEY=${SUPABASE_ANON_KEY}
- SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY}
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_DB=${REDIS_DB}
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD}@redis:${REDIS_PORT}/${REDIS_DB}
- CELERY_RESULT_BACKEND=redis://:${REDIS_PASSWORD}@redis:${REDIS_PORT}/${REDIS_DB}
command: celery -A core worker -l info
networks:
- app-network
# Celery beat for scheduled tasks
celery-beat:
build:
context: .
dockerfile: docker/Dockerfile
command: celery -A core beat -l info
volumes:
- ./backend:/app
environment:
- POSTGRES_HOST=postgres
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/django_db
- SUPABASE_DB_CONNECTION_STRING=${SUPABASE_DB_CONNECTION_STRING}
- SUPABASE_URL=${SUPABASE_URL}
- SUPABASE_ANON_KEY=${SUPABASE_ANON_KEY}
- SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY}
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_DB=${REDIS_DB}
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD}@redis:${REDIS_PORT}/${REDIS_DB}
- CELERY_RESULT_BACKEND=redis://:${REDIS_PASSWORD}@redis:${REDIS_PORT}/${REDIS_DB}
depends_on:
- postgres
- redis
- backend
- celery
networks:
- app-network
# Prometheus for metrics
prometheus:
image: prom/prometheus:latest
volumes:
- ./config/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus
ports:
- "${PROMETHEUS_PORT:-9090}:9090"
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
networks:
- app-network
restart: unless-stopped
# Grafana for visualization
grafana:
image: grafana/grafana:latest
volumes:
- grafana-data:/var/lib/grafana
- ./config/grafana/provisioning:/etc/grafana/provisioning
- ./config/grafana/dashboards:/etc/grafana/dashboards
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_USERNAME:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
- GF_USERS_ALLOW_SIGN_UP=false
- GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/etc/grafana/dashboards/redis_dashboard.json
ports:
- "${GRAFANA_PORT:-3000}:3000"
depends_on:
- prometheus
networks:
- app-network
restart: unless-stopped
# Redis Exporter for Prometheus metrics
redis-exporter:
image: oliver006/redis_exporter:latest
environment:
- REDIS_ADDR=redis://:${REDIS_PASSWORD:-redis_password}@redis:${REDIS_PORT:-6379}/${REDIS_DB:-0}
ports:
- "9121:9121"
depends_on:
- redis
networks:
- app-network
restart: unless-stopped
volumes:
redis-data:
prometheus-data:
sqlite-data:
grafana-data:
postgres-data:
networks:
app-network:
driver: bridge