File size: 942 Bytes
8eeadb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f540a2a
8eeadb9
 
 
 
 
 
 
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
FROM python:3.11-slim

# ---- System deps ----
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
    build-essential \
    git \
    curl \
    libgomp1 \
 && rm -rf /var/lib/apt/lists/*

# ---- Workdir ----
WORKDIR /app

# ---- Copy requirement & install ----
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -U pip \
 && pip install --no-cache-dir -r /app/requirements.txt

# ---- Runtime cache to /tmp (writeable) ----
ENV HF_HOME=/tmp/hf \
    SENTENCE_TRANSFORMERS_HOME=/tmp/sentence_transformers \
    XDG_CACHE_HOME=/tmp/.cache

# ---- Copy app ----
COPY . /app

# ---- Healthcheck ----
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
    CMD curl -f http://localhost:${PORT:-7860}/health || exit 1

# ---- Port & CMD ----
EXPOSE 7860
ENV PORT=7860 \
    PYTHONUNBUFFERED=1

CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT:-7860} --log-level info"]