FROM python:3.11-slim # Install system dependencies: Tesseract OCR + poppler (pdf2image) RUN apt-get update && apt-get install -y --no-install-recommends \ tesseract-ocr \ poppler-utils \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt \ && python -m spacy download en_core_web_sm # Copy source code COPY src/ src/ COPY .env.example .env.example # Pre-download NLTK data and HuggingFace model at build time (faster cold start) RUN python -c "import nltk; nltk.download('punkt'); nltk.download('punkt_tab'); nltk.download('stopwords')" RUN python -c "from transformers import pipeline; pipeline('sentiment-analysis', model='distilbert-base-uncased-finetuned-sst-2-english')" # HuggingFace Spaces uses port 7860; override with PORT env var for local use EXPOSE 7860 CMD ["sh", "-c", "uvicorn src.main:app --host 0.0.0.0 --port ${PORT:-7860}"]