FROM python:3.11-slim # HF Spaces runs as user 1000 RUN useradd -m -u 1000 appuser WORKDIR /app # Install deps first (layer cache) COPY --chown=appuser:appuser requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy app COPY --chown=appuser:appuser main.py . COPY --chown=appuser:appuser static/ static/ USER appuser # Pre-warm the model cache at build time so startup is instant # (HF hub caches to ~/.cache/huggingface/hub) RUN python -c "\ from huggingface_hub import snapshot_download; \ snapshot_download('Kaikaku/epicure-core'); \ print('Model cached.')" EXPOSE 7860 CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]