services:
  cheshire-cat-core:
    image: ghcr.io/cheshire-cat-ai/core:1.6.2
    container_name: miku_cheshire_cat_test
    depends_on:
      - cheshire-cat-vector-memory
    environment:
      PYTHONUNBUFFERED: "1"
      WATCHFILES_FORCE_POLLING: "true"
      CORE_HOST: ${CORE_HOST:-localhost}
      CORE_PORT: ${CORE_PORT:-1865}
      QDRANT_HOST: ${QDRANT_HOST:-cheshire-cat-vector-memory}
      QDRANT_PORT: ${QDRANT_PORT:-6333}
      CORE_USE_SECURE_PROTOCOLS: ${CORE_USE_SECURE_PROTOCOLS:-false}
      API_KEY: ${API_KEY:-}
      LOG_LEVEL: ${LOG_LEVEL:-INFO}
      DEBUG: ${DEBUG:-true}
      SAVE_MEMORY_SNAPSHOTS: ${SAVE_MEMORY_SNAPSHOTS:-false}
      OPENAI_API_BASE: "http://host.docker.internal:8091/v1"
    ports:
      - "${CORE_PORT:-1865}:80"
    # Allow connection to host services (llama-swap)
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./cat/static:/app/cat/static
      - ./cat/plugins:/app/cat/plugins
      - ./cat/data:/app/cat/data
      - ./cat/log.py:/app/cat/log.py  # Patched: fix loguru KeyError for third-party libs
    restart: unless-stopped
    networks:
      - miku-test-network
      - miku-discord_default  # Connect to existing miku bot network

  cheshire-cat-vector-memory:
    image: qdrant/qdrant:v1.9.1
    container_name: miku_qdrant_test
    environment:
      LOG_LEVEL: ${LOG_LEVEL:-INFO}
    ports:
      - "6333:6333"  # Expose for debugging
    ulimits:
      nofile:
        soft: 65536
        hard: 65536
    volumes:
      - ./cat/long_term_memory/vector:/qdrant/storage
    restart: unless-stopped
    networks:
      - miku-test-network

networks:
  miku-test-network:
    driver: bridge
  # Connect to main miku-discord network to access llama-swap
  default:
    external: true
    name: miku-discord_default
  miku-discord_default:
    external: true  # Connect to your existing bot's network
