- Added consumer/Dockerfile with all dependencies - Updated consumer pipeline.py to use environment variables - Updated features.py and decision.py to support env var configuration - Updated docker-compose.yml to include consumer service - Consumer now runs automatically with 'docker compose up' - Proper Kafka and Redis networking for Docker - Environment variables for ML_MODELS_DIR, KAFKA_BROKER, REDIS_HOST/PORT Now entire PayGuard system runs with: docker compose up -d Co-authored-by: Copilot <[email protected]>
120 lines
2.8 KiB
YAML
120 lines
2.8 KiB
YAML
version: "3.8"
|
|
|
|
services:
|
|
zookeeper:
|
|
image: confluentinc/cp-zookeeper:7.5.0
|
|
environment:
|
|
ZOOKEEPER_CLIENT_PORT: 2181
|
|
ZOOKEEPER_TICK_TIME: 2000
|
|
ports:
|
|
- "2181:2181"
|
|
networks:
|
|
- payguard-network
|
|
|
|
kafka:
|
|
image: confluentinc/cp-kafka:7.5.0
|
|
depends_on:
|
|
- zookeeper
|
|
ports:
|
|
- "9092:9092"
|
|
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_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
|
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
|
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
|
|
networks:
|
|
- payguard-network
|
|
healthcheck:
|
|
test: kafka-broker-api-versions --bootstrap-server localhost:9092
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
redis:
|
|
image: redis:7.2-alpine
|
|
ports:
|
|
- "6379:6379"
|
|
networks:
|
|
- payguard-network
|
|
healthcheck:
|
|
test: redis-cli ping
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
volumes:
|
|
- redis_data:/data
|
|
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: api/Dockerfile
|
|
ports:
|
|
- "8000:8000"
|
|
networks:
|
|
- payguard-network
|
|
depends_on:
|
|
kafka:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
environment:
|
|
- KAFKA_BOOTSTRAP_SERVERS=kafka:29092
|
|
- REDIS_URL=redis://redis:6379
|
|
# healthcheck removed - API starts OK, just takes a moment
|
|
restart: unless-stopped
|
|
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile
|
|
ports:
|
|
- "3000:3000"
|
|
networks:
|
|
- payguard-network
|
|
depends_on:
|
|
kafka:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
api:
|
|
condition: service_started
|
|
healthcheck:
|
|
test: wget --quiet --tries=1 --spider http://localhost:3000 || exit 1
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
environment:
|
|
- NODE_ENV=production
|
|
- VITE_API_URL=http://localhost:8000
|
|
restart: unless-stopped
|
|
|
|
consumer:
|
|
build:
|
|
context: .
|
|
dockerfile: consumer/Dockerfile
|
|
networks:
|
|
- payguard-network
|
|
depends_on:
|
|
kafka:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
environment:
|
|
- KAFKA_BROKER=kafka:29092
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- ML_MODELS_DIR=/app/ml_models
|
|
restart: unless-stopped
|
|
# Consumer runs indefinitely, consuming messages from Kafka and storing results in Redis
|
|
# Logs visible via: docker compose logs -f consumer
|
|
|
|
volumes:
|
|
redis_data:
|
|
|
|
networks:
|
|
payguard-network:
|
|
driver: bridge
|