-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
211 lines (202 loc) · 6.21 KB
/
Copy pathdocker-compose.yml
File metadata and controls
211 lines (202 loc) · 6.21 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
services:
zookeeper:
image: confluentinc/cp-zookeeper:7.4.0
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
KAFKA_OPTS: "-Dzookeeper.4lw.commands.whitelist=ruok,srvr,stat,mntr,cons"
ports:
- "2181:2181"
healthcheck:
test: ["CMD-SHELL", "exec 3<>/dev/tcp/localhost/2181 && echo -e 'srvr' >&3 && cat <&3 | grep -i 'mode\\|version'"]
interval: 10s
timeout: 5s
retries: 10
start_period: 20s
networks:
- fleet-network
kafka:
image: confluentinc/cp-kafka:7.4.0
depends_on:
zookeeper:
condition: service_healthy
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:29092,PLAINTEXT_HOST://0.0.0.0:9092
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
ports:
- "9092:9092"
healthcheck:
test: ["CMD", "kafka-broker-api-versions", "--bootstrap-server", "localhost:9092"]
interval: 10s
timeout: 10s
retries: 6
start_period: 75s
volumes:
- ./scripts/kafka_topics.sh:/usr/local/bin/kafka_topics.sh
networks:
- fleet-network
postgres:
image: timescale/timescaledb:2.11.2-pg14
environment:
POSTGRES_DB: fleet
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d fleet"]
interval: 10s
timeout: 5s
retries: 10
start_period: 20s
volumes:
- postgres_data:/var/lib/postgresql/data
- ./infrastructure/docker/initdb:/docker-entrypoint-initdb.d:z
networks:
- fleet-network
minio:
image: minio/minio:RELEASE.2023-09-04T19-57-37Z
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
ports:
- "9000:9000"
- "9001:9001"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
command: server /data --console-address ":9001"
volumes:
- minio_data:/data
networks:
- fleet-network
# Initialises MinIO buckets once before the app starts.
# Runs once and exits — app depends on service_completed_successfully.
minio-init:
image: minio/mc
depends_on:
minio:
condition: service_healthy
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
entrypoint: >
/bin/sh -c "
mc alias set local http://minio:9000 minioadmin minioadmin &&
mc mb --ignore-existing local/mlflow-artifacts &&
mc mb --ignore-existing local/fleet-data &&
echo 'MinIO buckets ready.'
"
networks:
- fleet-network
mlflow:
build:
context: .
dockerfile: infrastructure/docker/mlflow/Dockerfile
environment:
- MLFLOW_TRACKING_URI=http://mlflow:5000
- MLFLOW_S3_ENDPOINT_URL=http://minio:9000
- AWS_ACCESS_KEY_ID=minioadmin
- AWS_SECRET_ACCESS_KEY=minioadmin
ports:
- "5000:5000"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
interval: 15s
timeout: 10s
retries: 5
start_period: 120s
command: >
mlflow server
--backend-store-uri postgresql://postgres:postgres@postgres:5432/fleet
--default-artifact-root s3://mlflow-artifacts/
--host 0.0.0.0
depends_on:
postgres:
condition: service_healthy
minio-init:
condition: service_completed_successfully
networks:
- fleet-network
app:
build:
context: .
dockerfile: Dockerfile
environment:
- KAFKA_BOOTSTRAP_SERVERS=kafka:29092
- POSTGRES_URL=postgresql://postgres:postgres@postgres:5432/fleet
- MINIO_URL=http://minio:9000
- MINIO_ACCESS_KEY=minioadmin
- MINIO_SECRET_KEY=minioadmin
- MLFLOW_TRACKING_URI=http://mlflow:5000
- MLFLOW_S3_ENDPOINT_URL=http://minio:9000
- AWS_ACCESS_KEY_ID=minioadmin
- AWS_SECRET_ACCESS_KEY=minioadmin
- AWS_REGION=us-east-1
- MLFLOW_S3_USE_PATH_STYLE=true
- MLFLOW_BUCKET_NAME=mlflow-artifacts
# NO bind mount of .:/app — that overwrites the image's installed packages,
# including setuptools and all pip dependencies, with the host filesystem.
# For live code editing during development use: docker compose exec app bash
volumes:
- ./mlflow-artifacts:/app/mlflow-artifacts
ports:
- "8000:8000"
- "8050:8050"
depends_on:
kafka:
condition: service_healthy
postgres:
condition: service_healthy
minio-init:
condition: service_completed_successfully
mlflow:
condition: service_healthy
networks:
- fleet-network
# cleanup_minio.py moved after init_minio.py — can't clean what doesn't exist yet.
# Buckets are now pre-created by minio-init, so cleanup_minio.py is a no-op on
# first run and correctly clears demo data on subsequent runs.
command: >
bash -c "python scripts/wait_for_services.py &&
python scripts/init_minio.py &&
python scripts/cleanup_minio.py &&
python scripts/seed_demo_data.py &&
python scripts/ensure_model_exists.py &&
faust -A src.data.stream_processor worker &
python src/api/app.py"
grafana:
image: grafana/grafana:10.0.3
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
ports:
- "3000:3000"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
volumes:
- grafana_data:/var/lib/grafana
- ./infrastructure/docker/grafana/provisioning:/etc/grafana/provisioning
depends_on:
- postgres
networks:
- fleet-network
volumes:
postgres_data:
minio_data:
grafana_data:
networks:
fleet-network:
driver: bridge