-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
219 lines (210 loc) · 5.74 KB
/
docker-compose.prod.yml
File metadata and controls
219 lines (210 loc) · 5.74 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# Production Docker Compose Configuration
version: '3.8'
services:
# PostgreSQL Database
postgres:
image: postgres:16-alpine
container_name: sentinel-postgres-prod
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB:-sentinel_orm}
POSTGRES_USER: ${POSTGRES_USER:-sentinel}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_INITDB_ARGS: "-E UTF8"
ports:
- "${POSTGRES_PORT:-5432}:5432"
volumes:
- postgres_prod_data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-sentinel}" ]
interval: 10s
timeout: 5s
retries: 5
networks:
- sentinel-network
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
# ClickHouse Database
clickhouse:
image: clickhouse/clickhouse-server:latest
container_name: sentinel-clickhouse-prod
restart: unless-stopped
ports:
- "${CLICKHOUSE_PORT:-9000}:9000"
- "8123:8123"
volumes:
- clickhouse_prod_data:/var/lib/clickhouse
- clickhouse_logs:/var/log/clickhouse-server
environment:
- CLICKHOUSE_DB=${CLICKHOUSE_DB:-sentinel_events}
- CLICKHOUSE_USER=${CLICKHOUSE_USER:-default}
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD}
- CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1
ulimits:
nofile:
soft: 262144
hard: 262144
healthcheck:
test: [ "CMD", "clickhouse-client", "--query", "SELECT 1" ]
interval: 10s
timeout: 5s
retries: 5
networks:
- sentinel-network
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
# Redis Cache
redis:
image: redis:7-alpine
container_name: sentinel-redis-prod
restart: unless-stopped
command: redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru
ports:
- "${REDIS_PORT:-6379}:6379"
volumes:
- redis_prod_data:/data
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
interval: 10s
timeout: 5s
retries: 5
networks:
- sentinel-network
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
# Redpanda (Kafka alternative)
redpanda:
image: docker.redpanda.com/redpandadata/redpanda:latest
container_name: sentinel-redpanda-prod
restart: unless-stopped
command:
- redpanda
- start
- --kafka-addr internal://0.0.0.0:9092,external://0.0.0.0:19092
- --advertise-kafka-addr internal://redpanda:9092,external://localhost:19092
- --pandaproxy-addr internal://0.0.0.0:8082,external://0.0.0.0:18082
- --advertise-pandaproxy-addr internal://redpanda:8082,external://localhost:18082
- --schema-registry-addr internal://0.0.0.0:8081,external://0.0.0.0:18081
- --rpc-addr redpanda:33145
- --advertise-rpc-addr redpanda:33145
- --smp 1
- --memory 1G
- --mode dev-container
- --default-log-level=info
ports:
- "18081:18081"
- "18082:18082"
- "19092:19092"
- "19644:9644"
volumes:
- redpanda_prod_data:/var/lib/redpanda/data
healthcheck:
test: [ "CMD-SHELL", "rpk cluster health | grep -E 'Healthy:.+true' || exit 1" ]
interval: 15s
timeout: 3s
retries: 5
networks:
- sentinel-network
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
# Backend API
backend:
build:
context: .
dockerfile: Dockerfile
container_name: sentinel-backend-prod
restart: unless-stopped
ports:
- "8000:8000"
environment:
- ENVIRONMENT=${ENVIRONMENT:-production}
- DEBUG=${DEBUG:-false}
- LOG_LEVEL=${LOG_LEVEL:-INFO}
- SECRET_KEY=${SECRET_KEY}
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_DB=${POSTGRES_DB:-sentinel_orm}
- POSTGRES_USER=${POSTGRES_USER:-sentinel}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- CLICKHOUSE_HOST=clickhouse
- CLICKHOUSE_PORT=9000
- CLICKHOUSE_DB=${CLICKHOUSE_DB:-sentinel_events}
- CLICKHOUSE_USER=${CLICKHOUSE_USER:-default}
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD}
- REDIS_HOST=redis
- REDIS_PORT=6379
- KAFKA_BOOTSTRAP_SERVERS=redpanda:9092
- RAPIDAPI_KEY=${RAPIDAPI_KEY}
- TWITTER_BEARER_TOKEN=${TWITTER_BEARER_TOKEN}
- REDDIT_CLIENT_ID=${REDDIT_CLIENT_ID}
- REDDIT_CLIENT_SECRET=${REDDIT_CLIENT_SECRET}
depends_on:
postgres:
condition: service_healthy
clickhouse:
condition: service_healthy
redis:
condition: service_healthy
redpanda:
condition: service_healthy
volumes:
- ./ml:/app/ml
- backend_logs:/app/logs
networks:
- sentinel-network
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:8000/health" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Nginx for serving frontend and reverse proxy
nginx:
image: nginx:alpine
container_name: sentinel-nginx-prod
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./frontend:/usr/share/nginx/html:ro
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
- nginx_logs:/var/log/nginx
depends_on:
- backend
networks:
- sentinel-network
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
volumes:
postgres_prod_data:
clickhouse_prod_data:
clickhouse_logs:
redis_prod_data:
redpanda_prod_data:
backend_logs:
nginx_logs:
networks:
sentinel-network:
driver: bridge