version: '3.8'

services:
  # Redis for policy decision caching
  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data
    command: redis-server --appendonly yes
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

  # SolaceNet Go Gateway
  solacenet-gateway:
    build:
      context: ./gateway/go
      dockerfile: Dockerfile
    ports:
      - "8080:8080"
    environment:
      - GATEWAY_PORT=8080
      - BACKEND_URL=http://dbis-api:3000
      - POLICY_ENGINE_URL=http://dbis-api:3000
      - REDIS_URL=redis://redis:6379
      - CACHE_TTL=120
      - JWT_SECRET=${JWT_SECRET}
      - LOG_LEVEL=info
    depends_on:
      - redis
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
      interval: 30s
      timeout: 10s
      retries: 3

  # DBIS API (main application)
  dbis-api:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=${DATABASE_URL}
      - REDIS_URL=redis://redis:6379
      - KAFKA_BROKERS=${KAFKA_BROKERS:-localhost:9092}
      - NODE_ENV=production
    depends_on:
      - redis
    volumes:
      - ./src:/app/src
      - ./prisma:/app/prisma

volumes:
  redis-data:
