File size: 1,338 Bytes
d330add
 
 
 
 
300bbfa
d330add
 
 
300bbfa
d330add
 
300bbfa
 
 
 
 
 
 
 
 
 
d330add
 
300bbfa
d330add
300bbfa
 
 
 
 
 
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
# ── GGUF LLM API β€” HF Spaces (Docker SDK), Alpine base ────────────────────────
# Alpine (musl libc) is REQUIRED here: the prebuilt llama-cpp-python CPU wheels
# on abetlen's index are musl builds, and compiling from source exceeds HF's
# build-job timeout on the free builder. With the wheel, the build is minutes.
FROM python:3.11-alpine

# Runtime libraries the llama.cpp shared objects need (C++/OpenMP), plus a
# compiler-free environment β€” no gcc/cmake on purpose: wheels only.
RUN apk add --no-cache libstdc++ libgomp curl

# HF Spaces runs containers as uid 1000 with writable paths under its home.
RUN adduser -D -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    HF_HOME=/home/user/.cache/huggingface \
    N_THREADS=2 \
    OMP_NUM_THREADS=2

WORKDIR /home/user/app

COPY --chown=user requirements.txt ./
# --only-binary: fail loudly if any dependency would need a compiler instead of
# silently hitting the build timeout again.
RUN pip install --no-cache-dir --upgrade pip \
    && pip install --no-cache-dir --only-binary=:all: -r requirements.txt \
        --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu

COPY --chown=user . ./

EXPOSE 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]