# StackShip — RAG Pipeline Stack
# Generated by: stackship deploy rag
# Docs: https://github.com/ai-engineering-lab/stackship

version: "3.8"

services:
  qdrant:
    image: qdrant/qdrant:latest
    container_name: stackship-qdrant
    restart: unless-stopped
    volumes:
      - qdrant_data:/qdrant/storage
    ports:
      - "6333:6333"
    healthcheck:
      test: ["CMD-SHELL", "wget -q --spider http://localhost:6333/healthz || exit 1"]
      interval: 5s
      timeout: 10s
      retries: 10
      start_period: 15s
    networks:
      - stackship

  embeddings:
    image: ghcr.io/huggingface/text-embeddings-inference:latest
    container_name: stackship-embeddings
    restart: unless-stopped
    ports:
      - "8081:80"
    environment:
      - MODEL_ID={{ embedding_model | default('BAAI/bge-small-en-v1.5') }}
    volumes:
      - embeddings_cache:/data
    networks:
      - stackship

  rag-api:
    image: python:3.11-slim
    container_name: stackship-rag-api
    restart: unless-stopped
    ports:
      - "{{ gateway_port | default('8080') }}:8080"
    environment:
      - QDRANT_URL=http://qdrant:6333
      - EMBEDDINGS_URL=http://embeddings:80
      - COLLECTION_NAME={{ collection_name | default('documents') }}
      - API_PORT=8080
{% for key, value in env_vars.items() %}
      - {{ key }}={{ value }}
{% endfor %}
    depends_on:
      qdrant:
        condition: service_healthy
      embeddings:
        condition: service_started
    networks:
      - stackship

volumes:
  qdrant_data:
  embeddings_cache:

networks:
  stackship:
    driver: bridge
