FROM python:3.10-slim # Create a non-root user (required by Hugging Face Spaces) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR /home/user/app # Install dependencies COPY --chown=user requirements.txt ./requirements.txt RUN pip install --no-cache-dir -r requirements.txt # Download NLTK data required by feature_extraction.py RUN python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords'); nltk.download('wordnet'); nltk.download('punkt_tab')" # Copy application files COPY --chown=user . ./ # Hugging Face Spaces exposes port 7860 EXPOSE 7860 ENV PORT=7860 # Run with gunicorn for production CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "300", "app:app"]