| FROM python:3.12-slim | |
| # Install uv — 10-100x faster than pip, proper lockfiles | |
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv | |
| WORKDIR /app | |
| # Install system deps for FastEmbed / BGE-M3 CPU inference | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential curl git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy dependency files first (layer cache optimization) | |
| COPY pyproject.toml uv.lock* ./ | |
| # Install all Python dependencies into the project virtual env | |
| RUN uv sync --frozen --no-dev | |
| # Copy application source | |
| COPY . . | |
| # Pre-download BGE-M3 model so cold starts are instant | |
| RUN uv run python -c "from fastembed import TextEmbedding; TextEmbedding('BAAI/bge-m3')" || true | |
| EXPOSE 7860 | |
| CMD ["uv", "run", "python", "app.py"] | |