-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
220 lines (207 loc) · 6.18 KB
/
Copy pathdocker-compose.yml
File metadata and controls
220 lines (207 loc) · 6.18 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
services:
zookeeper:
image: confluentinc/cp-zookeeper:7.5.0
container_name: cancer-zookeeper
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
healthcheck:
test: ["CMD-SHELL", "echo ruok | timeout 2 bash -c 'cat > /dev/tcp/localhost/2181' >/dev/null 2>&1 || exit 1"]
interval: 10s
timeout: 5s
retries: 10
networks:
- cancer_net
kafka:
image: confluentinc/cp-kafka:7.5.0
container_name: cancer-kafka
depends_on:
zookeeper:
condition: service_healthy
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
healthcheck:
test: ["CMD-SHELL", "kafka-topics --bootstrap-server localhost:9092 --list >/dev/null 2>&1 || exit 1"]
interval: 10s
timeout: 10s
retries: 10
networks:
- cancer_net
kafka-init:
image: confluentinc/cp-kafka:7.5.0
container_name: cancer-kafka-init
depends_on:
kafka:
condition: service_healthy
env_file: .env
command:
- bash
- -c
- |
set -e
kafka-topics --bootstrap-server kafka:9092 --create --if-not-exists --topic "$$KAFKA_TOPIC_IMAGE_UPLOADS" --partitions 1 --replication-factor 1
kafka-topics --bootstrap-server kafka:9092 --create --if-not-exists --topic "$$KAFKA_TOPIC_ML_RESULT" --partitions 1 --replication-factor 1
kafka-topics --bootstrap-server kafka:9092 --create --if-not-exists --topic "$$KAFKA_TOPIC_IMAGE_DONE" --partitions 1 --replication-factor 1
echo "Kafka topics ready."
networks:
- cancer_net
redis:
image: redis:7-alpine
container_name: cancer-redis
command: redis-server --appendonly yes
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 10
networks:
- cancer_net
postgres:
image: postgres:16-alpine
container_name: cancer-postgres
env_file: .env
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 10s
timeout: 5s
retries: 10
networks:
- cancer_net
auth_service:
build:
context: ./auth_service
container_name: cancer-auth-service
env_file: .env
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "node -e \"const http = require('http'); const req = http.get('http://localhost:4000/health', {timeout: 2000}, (res) => {process.exit(res.statusCode === 200 ? 0 : 1)}); req.on('error', () => process.exit(1));\""]
interval: 15s
timeout: 5s
retries: 10
networks:
- cancer_net
api_gateway:
build:
context: ./api_gateway
container_name: cancer-api-gateway
env_file: .env
depends_on:
kafka:
condition: service_healthy
kafka-init:
condition: service_completed_successfully
redis:
condition: service_healthy
postgres:
condition: service_healthy
auth_service:
condition: service_healthy
# Bound to loopback only — public traffic uses frontend nginx → /api. Matches PORT inside the container.
ports:
- "127.0.0.1:${PORT:-3000}:${PORT:-3000}"
healthcheck:
# curl or wget failing thats why we use node to check health
test: ["CMD-SHELL", "node -e \"const http = require('http'); const req = http.get('http://localhost:3000/health', {timeout: 2000}, (res) => {process.exit(res.statusCode === 200 ? 0 : 1)}); req.on('error', () => process.exit(1));\""]
interval: 15s
timeout: 5s
retries: 10
networks:
- cancer_net
ml_service:
build:
context: ./ml_service
container_name: cancer-ml-service
env_file: .env
volumes:
- ./ml_service/models:/models:ro
depends_on:
kafka:
condition: service_healthy
kafka-init:
condition: service_completed_successfully
healthcheck:
test: ["CMD-SHELL", "python -c \"import socket; s=socket.create_connection(('kafka', 9092), 2); s.close()\""]
interval: 20s
timeout: 5s
retries: 10
networks:
- cancer_net
image_processor:
build:
context: ./image_processor
container_name: cancer-image-processor
env_file: .env
depends_on:
kafka:
condition: service_healthy
kafka-init:
condition: service_completed_successfully
healthcheck:
test: ["CMD-SHELL", "python -c \"import socket; s=socket.create_connection(('kafka', 9092), 2); s.close()\""]
interval: 20s
timeout: 5s
retries: 10
networks:
- cancer_net
result_aggregator:
build:
context: ./result_aggregator
container_name: cancer-result-aggregator
env_file: .env
depends_on:
kafka:
condition: service_healthy
kafka-init:
condition: service_completed_successfully
redis:
condition: service_healthy
postgres:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "node -e \"const net=require('net');const s=net.connect(9092,'kafka');s.on('connect',()=>{s.end();process.exit(0)});s.on('error',()=>process.exit(1));setTimeout(()=>process.exit(1),2000)\""]
interval: 20s
timeout: 5s
retries: 10
networks:
- cancer_net
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: cancer-frontend
depends_on:
api_gateway:
condition: service_healthy
auth_service:
condition: service_healthy
ports:
- "${FRONTEND_PORT:-80}:80"
networks:
- cancer_net
ollama:
image: ollama/ollama
container_name: cancer-ollama
volumes:
- ollama_data:/root/.ollama
# After first `docker compose up`, pull a model:
# docker exec cancer-ollama ollama pull llama3.2:3b
networks:
- cancer_net
volumes:
redis_data:
postgres_data:
ollama_data:
networks:
cancer_net:
driver: bridge