FROM python:3.10-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY download_model.py . RUN python download_model.py COPY utils/ ./utils/ COPY app.py . EXPOSE 7860 HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')" # Shell form so $WEB_CONCURRENCY is expanded at runtime (set to 4 in HF Spaces) # uvicorn.workers.UvicornWorker = correct ASGI worker class for FastAPI + Gunicorn CMD gunicorn app:app \ --workers ${WEB_CONCURRENCY:-4} \ --bind 0.0.0.0:7860 \ --timeout 120 \ --worker-class uvicorn.workers.UvicornWorker