FROM python:3.12-slim # Hugging Face runs the container as uid 1000 and $HOME must be writable, or # httpx and friends fail trying to create a cache directory at startup. RUN useradd -m -u 1000 user USER user ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --user -r requirements.txt COPY --chown=user app.py . # 7860 is the port the platform proxies. Single worker on purpose: the rate # limiter counts in process memory, and a second worker would silently double # the limit. EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]