FROM python:3.9-slim WORKDIR /app # Install system dependencies if needed (e.g. for Pillow or other libs in future) # RUN apt-get update && apt-get install -y --no-install-recommends ... COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . # Create a user to avoid running as root (required for HF Spaces) RUN useradd -m -u 1000 user # Fix permissions for the app directory RUN chown -R user:user /app USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Expose port 7860 EXPOSE 7860 # Start Gunicorn with timeout config CMD ["gunicorn", "-b", "0.0.0.0:7860", "--timeout", "120", "--workers", "2", "app:app"]