Model / Dockerfile
Electro0023's picture
v2: Alpine base + runtime /admin/load (deepseek defaults + template kept)
d330add verified
Raw
History Blame Contribute Delete
1.34 kB
# ── 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"]