-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
334 lines (319 loc) · 9.44 KB
/
docker-compose.yml
File metadata and controls
334 lines (319 loc) · 9.44 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
services:
# NATS server with JetStream enabled
nats:
image: nats:2.10-alpine
container_name: causality-nats
ports:
- "4222:4222" # Client connections
- "8222:8222" # HTTP monitoring
command: ["--jetstream", "--store_dir=/data", "-m", "8222"]
volumes:
- nats-data:/data
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8222/healthz"]
interval: 5s
timeout: 3s
retries: 3
# MinIO for S3-compatible object storage
minio:
image: minio/minio:latest
container_name: causality-minio
ports:
- "9000:9000" # API
- "9001:9001" # Console
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
command: server /data --console-address ":9001"
volumes:
- minio-data:/data
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 5s
timeout: 3s
retries: 3
# MinIO bucket initialization
minio-init:
image: minio/mc:latest
container_name: causality-minio-init
depends_on:
minio:
condition: service_healthy
entrypoint: >
/bin/sh -c "
mc alias set myminio http://minio:9000 minioadmin minioadmin;
mc mb --ignore-existing myminio/causality-events;
mc anonymous set download myminio/causality-events;
exit 0;
"
# PostgreSQL for Hive Metastore and Redash
postgres:
image: postgres:16-alpine
container_name: causality-postgres
ports:
- "5433:5432"
environment:
POSTGRES_USER: hive
POSTGRES_PASSWORD: hive
POSTGRES_DB: metastore
volumes:
- postgres-data:/var/lib/postgresql/data
- ./docker/postgres/init-redash.sql:/docker-entrypoint-initdb.d/01-init-redash.sql:ro
- ./docker/postgres/init-reaction-engine.sql:/docker-entrypoint-initdb.d/02-init-reaction-engine.sql:ro
- ./docker/postgres/init-causality-server.sql:/docker-entrypoint-initdb.d/03-init-causality-server.sql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U hive -d metastore"]
interval: 5s
timeout: 3s
retries: 3
# Hive Metastore (for schema registry)
hive-metastore:
image: apache/hive:4.0.0
container_name: causality-hive-metastore
depends_on:
postgres:
condition: service_healthy
minio:
condition: service_healthy
hive-init-driver:
condition: service_completed_successfully
ports:
- "9083:9083"
environment:
SERVICE_NAME: metastore
DB_DRIVER: postgres
SERVICE_OPTS: >-
-Djavax.jdo.option.ConnectionDriverName=org.postgresql.Driver
-Djavax.jdo.option.ConnectionURL=jdbc:postgresql://postgres:5432/metastore
-Djavax.jdo.option.ConnectionUserName=hive
-Djavax.jdo.option.ConnectionPassword=hive
volumes:
- ./docker/hive/core-site.xml:/opt/hive/conf/core-site.xml:ro
- hive-lib:/opt/hive/lib
- hive-warehouse:/opt/hive/data/warehouse
healthcheck:
test: ["CMD", "bash", "-c", "echo > /dev/tcp/localhost/9083"]
interval: 10s
timeout: 5s
retries: 10
start_period: 60s
# Download PostgreSQL JDBC driver and Hadoop AWS JARs for Hive
hive-init-driver:
image: alpine:latest
container_name: causality-hive-init-driver
volumes:
- hive-lib:/opt/hive/lib
command: >
sh -c "
apk add --no-cache curl &&
echo 'Downloading PostgreSQL driver...' &&
curl -L -o /opt/hive/lib/postgresql-42.7.4.jar https://jdbc.postgresql.org/download/postgresql-42.7.4.jar &&
echo 'Downloading Hadoop AWS...' &&
curl -L -o /opt/hive/lib/hadoop-aws-3.3.4.jar https://repo1.maven.org/maven2/org/apache/hadoop/hadoop-aws/3.3.4/hadoop-aws-3.3.4.jar &&
echo 'Downloading AWS SDK bundle...' &&
curl -L -o /opt/hive/lib/aws-java-sdk-bundle-1.12.262.jar https://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk-bundle/1.12.262/aws-java-sdk-bundle-1.12.262.jar &&
chmod 644 /opt/hive/lib/*.jar &&
echo 'All JARs downloaded'
"
# Trino for SQL queries
trino:
image: trinodb/trino:444
container_name: causality-trino
hostname: trino
depends_on:
hive-metastore:
condition: service_healthy
ports:
- "8085:8080"
environment:
- AWS_ACCESS_KEY_ID=minioadmin
- AWS_SECRET_ACCESS_KEY=minioadmin
volumes:
- ./docker/trino/etc:/etc/trino
healthcheck:
test: ["CMD-SHELL", "curl -sf http://localhost:8080/v1/info >/dev/null"]
interval: 10s
timeout: 5s
retries: 30
start_period: 15s
restart: always
# Redis for Redash
redis:
image: redis:7-alpine
container_name: causality-redis
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 3
# Redash database initialization
redash-init-db:
image: redash/redash:10.1.0.b50633
platform: linux/amd64
container_name: causality-redash-init-db
command: python manage.py database create_tables
env_file:
- ./docker/redash/.env
environment:
PYTHONUNBUFFERED: 0
REDASH_DATABASE_URL: postgresql://hive:hive@postgres:5432/redash
REDASH_REDIS_URL: redis://redis:6379/0
depends_on:
- postgres
restart: "no"
# Redash for visualization
redash-server:
image: redash/redash:10.1.0.b50633
platform: linux/amd64
container_name: causality-redash
command: /app/entrypoint.sh
env_file:
- ./docker/redash/.env
environment:
PYTHONUNBUFFERED: 0
REDASH_DATABASE_URL: postgresql://hive:hive@postgres:5432/redash
REDASH_REDIS_URL: redis://redis:6379/0
REDASH_ADMIN_NAME: Causality Admin
REDASH_ADMIN_EMAIL: admin@causality.local
REDASH_ADMIN_PASSWORD: admin123
ports:
- "5050:5000"
volumes:
- ./docker/redash/entrypoint.sh:/app/entrypoint.sh:ro
- ./docker/redash/init-admin.sh:/app/init-admin.sh:ro
depends_on:
redash-init-db:
condition: service_started
postgres:
condition: service_started
redis:
condition: service_started
trino:
condition: service_healthy
restart: unless-stopped
redash-worker:
image: redash/redash:10.1.0.b50633
platform: linux/amd64
container_name: causality-redash-worker
command: worker
env_file:
- ./docker/redash/.env
environment:
PYTHONUNBUFFERED: 0
REDASH_DATABASE_URL: postgresql://hive:hive@postgres:5432/redash
REDASH_REDIS_URL: redis://redis:6379/0
depends_on:
- postgres
- redis
# Causality HTTP Server
causality-server:
build:
context: .
dockerfile: Dockerfile
target: server
container_name: causality-server
depends_on:
nats:
condition: service_healthy
postgres:
condition: service_healthy
ports:
- "8080:8080"
environment:
HTTP_ADDR: ":8080"
NATS_URL: "nats://nats:4222"
DATABASE_HOST: "postgres"
DATABASE_PORT: "5432"
DATABASE_USER: "hive"
DATABASE_PASSWORD: "hive"
DATABASE_NAME: "causality_server"
DATABASE_SSL_MODE: "disable"
DEDUP_WINDOW: "10m"
MAX_BODY_SIZE: "5242880"
RATE_LIMIT_ENABLED: "true"
RATE_LIMIT_PER_KEY_RPS: "1000"
LOG_LEVEL: "info"
LOG_FORMAT: "json"
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/health"]
interval: 5s
timeout: 3s
retries: 3
# Warehouse Sink
warehouse-sink:
build:
context: .
dockerfile: Dockerfile
target: warehouse-sink
container_name: causality-warehouse-sink
stop_grace_period: 2m
depends_on:
nats:
condition: service_healthy
minio:
condition: service_healthy
minio-init:
condition: service_completed_successfully
ports:
- "9090:9090" # Prometheus metrics
environment:
NATS_URL: "nats://nats:4222"
S3_ENDPOINT: "http://minio:9000"
S3_REGION: "us-east-1"
S3_BUCKET: "causality-events"
S3_ACCESS_KEY_ID: "minioadmin"
S3_SECRET_ACCESS_KEY: "minioadmin"
S3_USE_PATH_STYLE: "true"
BATCH_MAX_EVENTS: "10"
BATCH_FLUSH_INTERVAL: "30s"
METRICS_ADDR: ":9090"
SHUTDOWN_TIMEOUT: "90s"
COMPACTION_ENABLED: "true"
COMPACTION_SCHEDULE: "1h"
COMPACTION_TARGET_SIZE: "134217728"
COMPACTION_MIN_FILES: "2"
LOG_LEVEL: "info"
LOG_FORMAT: "json"
# Reaction Engine
reaction-engine:
build:
context: .
dockerfile: Dockerfile
target: reaction-engine
container_name: causality-reaction-engine
stop_grace_period: 1m
depends_on:
nats:
condition: service_healthy
postgres:
condition: service_healthy
ports:
- "9091:9091" # Prometheus metrics
environment:
NATS_URL: "nats://nats:4222"
DATABASE_HOST: "postgres"
DATABASE_PORT: "5432"
DATABASE_USER: "hive"
DATABASE_PASSWORD: "hive"
DATABASE_NAME: "reaction_engine"
DATABASE_SSL_MODE: "disable"
CONSUMER_NAME: "analysis-engine"
METRICS_ADDR: ":9091"
SHUTDOWN_TIMEOUT: "30s"
CONSUMER_WORKER_COUNT: "2"
CONSUMER_FETCH_BATCH_SIZE: "100"
ENGINE_RULE_REFRESH_INTERVAL: "30s"
DISPATCHER_WORKERS: "5"
DISPATCHER_POLL_INTERVAL: "1s"
ANOMALY_CONFIG_REFRESH_INTERVAL: "30s"
LOG_LEVEL: "info"
LOG_FORMAT: "json"
volumes:
nats-data:
minio-data:
postgres-data:
hive-warehouse:
hive-lib:
networks:
default:
name: causality-network