File size: 1,033 Bytes
ad0d245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
32
33
34
35
36
37
# --- Base image ---
FROM python:3.11-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=on

# OS deps (git useful for HF repos; curl for HEALTHCHECK)
RUN apt-get update && apt-get install -y --no-install-recommends \

    git curl && \
    rm -rf /var/lib/apt/lists/*

# Non-root user
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

WORKDIR /app

# Python deps
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --upgrade pip && pip install -r requirements.txt

# App source
COPY --chown=user . /app

EXPOSE 7860

# Healthcheck pings your FastAPI health endpoint
HEALTHCHECK --interval=30s --timeout=3s --start-period=20s --retries=3 \

  CMD curl -fsS http://localhost:7860/api/health || exit 1

# Production server (Gunicorn + Uvicorn worker)
#CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]

CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "-w", "2", "-b", "0.0.0.0:7860", "server:app"]