# Use official Python 3.11 slim image FROM python:3.11-slim # Set environment variables ENV PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ POETRY_VIRTUALENVS_CREATE=false # Install system dependencies for Python packages RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ git \ curl \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Copy only requirements first to leverage Docker cache COPY requirements.txt . # Upgrade pip and install Python dependencies RUN pip install --upgrade pip RUN pip install --no-cache-dir -r requirements.txt # Pre-download NLTK resources RUN python -m nltk.downloader punkt_tab # Copy application code COPY . . # Tell NLTK where to find resources at runtime ENV NLTK_DATA=/usr/local/nltk_data # Expose port for FastAPI / Hugging Face Spaces EXPOSE 7860 # Run FastAPI app with Uvicorn CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]