FROM python:3.11-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ gcc \ g++ \ && rm -rf /var/lib/apt/lists/* # Copy requirements first (for Docker layer caching) COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy all backend code COPY . . # Set Python path so imports resolve correctly ENV PYTHONPATH=/app # Download NLTK data at build time RUN python -c "import nltk; nltk.download('punkt'); nltk.download('punkt_tab')" # HuggingFace Spaces uses port 7860 EXPOSE 7860 # Start the API CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"]