services:
  db:
    image: pgvector/pgvector:pg17
    container_name: nexus-db
    environment:
      POSTGRES_USER: nexus_user
      POSTGRES_PASSWORD: nexus_password
      POSTGRES_DB: nexus_db
    ports:
      - "5432:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U nexus_user -d nexus_db"]
      interval: 5s
      timeout: 5s
      retries: 5

  web:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: nexus-web
    ports:
      - "5000:5000"
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ConnectionStrings__PostgresConnection=Host=db;Database=nexus_db;Username=nexus_user;Password=nexus_password
      - ConnectionStrings__QdrantConnection=Host=qdrant;Port=6334
      - ConnectionStrings__Neo4jConnection=bolt://neo4j:7687
      - Authentication__Google__ClientId=${GOOGLE_CLIENT_ID:-placeholder}
      - Authentication__Google__ClientSecret=${GOOGLE_CLIENT_SECRET:-placeholder}
      - Ai__Google__ApiKey=${GOOGLE_AI_API_KEY:-placeholder}
    depends_on:
      db:
        condition: service_healthy
      qdrant:
        condition: service_healthy
      neo4j:
        condition: service_healthy

  qdrant:
    image: qdrant/qdrant:latest
    container_name: nexus-qdrant
    ports:
      - "6333:6333"
      - "6334:6334"
    volumes:
      - qdrant_data:/qdrant/storage
    healthcheck:
      test: ["CMD-SHELL", "bash -c 'exec 3<>/dev/tcp/127.0.0.1/6333'"]
      interval: 5s
      timeout: 5s
      retries: 5

  neo4j:
    image: neo4j:5-community
    container_name: nexus-neo4j
    ports:
      - "7474:7474"
      - "7687:7687"
    environment:
      - NEO4J_AUTH=none
    volumes:
      - neo4j_data:/data
    healthcheck:
      test: ["CMD-SHELL", "cypher-shell -u neo4j -p '' 'RETURN 1' || exit 0"]
      interval: 5s
      timeout: 5s
      retries: 5

volumes:
  pgdata:
  qdrant_data:
  neo4j_data:
