File size: 734 Bytes
6942820
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# For Hugging Face Spaces (Docker SDK). Spaces runs the container as user 1000 and sends traffic to port 7860.
FROM python:3.11-slim

RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH \
    HF_HOME=/home/user/.cache/huggingface \
    HOST=0.0.0.0 PORT=7860 PYTHONUNBUFFERED=1
WORKDIR /home/user/app

# CPU-only torch first: the default Linux wheel pulls in several GB of CUDA libraries a CPU Space can't use.
RUN pip install --no-cache-dir --user torch==2.9.1 --index-url https://download.pytorch.org/whl/cpu
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt

COPY --chown=user server.py references.json ./

EXPOSE 7860
CMD ["python", "server.py"]