File size: 708 Bytes
4cedae1
 
 
 
 
 
 
 
 
 
ba54e04
4cedae1
 
 
 
05bfdd2
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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