FROM python:3.12-slim RUN pip install --no-cache-dir fastapi==0.136.3 uvicorn==0.52.4 huggingface_hub==1.31.0 httpx==0.28.1 # Spaces run the container as uid 1000; the Hub cache lives in its home RUN useradd -m -u 1000 user USER user ENV HOME=/home/user HF_HOME=/home/user/.cache/huggingface WORKDIR /home/user/app COPY --chown=user app.py . CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]