version: "3.9"

services:
  # ── PeerCortex MCP Server ───────────────────────────────
  peercortex:
    build: .
    container_name: peercortex
    restart: unless-stopped
    environment:
      - OLLAMA_BASE_URL=http://ollama:11434
      - OLLAMA_MODEL=${OLLAMA_MODEL:-llama3.1}
      - PEERINGDB_API_KEY=${PEERINGDB_API_KEY:-}
      - RIPE_STAT_SOURCE_APP=${RIPE_STAT_SOURCE_APP:-peercortex}
      - ROUTINATOR_URL=${ROUTINATOR_URL:-http://routinator:8323}
      - CACHE_DB_PATH=/app/data/peercortex-cache.db
      - CACHE_TTL_SECONDS=${CACHE_TTL_SECONDS:-3600}
      - MCP_TRANSPORT=${MCP_TRANSPORT:-stdio}
      - MCP_PORT=3100
      - LOG_LEVEL=${LOG_LEVEL:-info}
    volumes:
      - peercortex-data:/app/data
    ports:
      - "${MCP_PORT:-3100}:3100"
    depends_on:
      - ollama
    networks:
      - peercortex-net

  # ── Ollama (Local AI) ──────────────────────────────────
  ollama:
    image: ollama/ollama:latest
    container_name: peercortex-ollama
    restart: unless-stopped
    volumes:
      - ollama-models:/root/.ollama
    ports:
      - "11434:11434"
    networks:
      - peercortex-net
    # Uncomment for GPU support:
    # deploy:
    #   resources:
    #     reservations:
    #       devices:
    #         - driver: nvidia
    #           count: 1
    #           capabilities: [gpu]

  # ── Routinator (RPKI Validator) — Optional ─────────────
  # Uncomment to run a local RPKI validator
  # routinator:
  #   image: nlnetlabs/routinator:latest
  #   container_name: peercortex-routinator
  #   restart: unless-stopped
  #   ports:
  #     - "8323:8323"
  #   volumes:
  #     - routinator-data:/home/routinator/.rpki-cache
  #   networks:
  #     - peercortex-net

volumes:
  peercortex-data:
  ollama-models:
  # routinator-data:

networks:
  peercortex-net:
    driver: bridge
