FROM python:3.10-slim # HuggingFace Spaces requires non-root user with UID 1000 RUN useradd -m -u 1000 user WORKDIR /home/user/app # Install dependencies first (layer caching) COPY --chown=user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY --chown=user app.py . USER user EXPOSE 7860 ENV TRANSFORMERS_VERBOSITY=error ENV HF_HOME=/home/user/.cache/huggingface CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]