File size: 1,044 Bytes
188f0cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45ad768
188f0cf
 
 
 
 
 
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
FROM python:3.11-slim

# HF Spaces enforces a non-root user (uid 1000) for the runtime.
RUN useradd -m -u 1000 user

WORKDIR /home/user/app
ENV PATH="/home/user/.local/bin:${PATH}" \
    PYTHONPATH=/home/user/app/src \
    PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    HF_HOME=/home/user/.cache/hf \
    XDG_CACHE_HOME=/home/user/.cache

RUN apt-get update && apt-get install -y --no-install-recommends \
        curl \
        ca-certificates \
    && rm -rf /var/lib/apt/lists/*

USER user

# Install CPU-only torch first so the wheel doesn't pull CUDA bloat.
RUN pip install --user --no-cache-dir \
    "torch>=2.1" --index-url https://download.pytorch.org/whl/cpu

COPY --chown=user requirements.txt ./
RUN pip install --user --no-cache-dir -r requirements.txt

COPY --chown=user config ./config
COPY --chown=user checkpoints ./checkpoints
COPY --chown=user src ./src

# HF Spaces routes traffic to port 7860.
EXPOSE 7860

CMD ["uvicorn", "recsys.serving.app:app", "--host", "0.0.0.0", "--port", "7860"]