FROM python:3.10-slim # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* # Set up a new user named "user" with UID 1000 per Hugging Face specifications RUN useradd -m -u 1000 user USER user # Set environmental paths for the local user context ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Copy files ensuring the user owns them COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --user -r requirements.txt # Copy the rest of the application files COPY --chown=user . . # Hugging Face Spaces expects port 7860 EXPOSE 7860 # Run with gunicorn CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]