# MCP Server Service
FROM python:3.11-slim

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Install Python dependencies cleanly
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy server code
COPY server.py .

# Mount volumes at these paths (configured in docker-compose)
# ./docs -> /docs  
# ./data -> /data
# /data holds: db.sqlite, sqlite file for SQLite storage

# Expose MCP port
EXPOSE 8788

# Healthcheck
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD python -c "import socket; s=socket.create_connection(('127.0.0.1', 8788), 5); s.close()"

# Run the MCP server using streamable HTTP transport
CMD ["python", "server.py"]
