FROM python:3.11-slim # System deps: Tesseract (OCR) + Poppler (PDF rasterization for scanned PDFs) RUN apt-get update && apt-get install -y --no-install-recommends \ tesseract-ocr \ poppler-utils \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Pre-download the embedding model at build time so the first request is fast. RUN python -c "from fastembed import TextEmbedding; TextEmbedding(model_name='BAAI/bge-small-en-v1.5')" COPY app ./app COPY static ./static # Most PaaS platforms inject $PORT; default to 8000 locally. ENV PORT=8000 EXPOSE 8000 CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT}"]