| |
| |
| |
| |
| |
| |
| ARG GGUF_REPO=openbmb/MiniCPM3-4B-GGUF |
| ARG GGUF_FILE=minicpm3-4b-q4_k_m.gguf |
| ARG LLAMA_CPP_TAG=b9616 |
| ARG LLAMA_CPP_ARCHIVE=llama-b9616-bin-ubuntu-x64.tar.gz |
|
|
| |
| |
| |
| FROM python:3.11-slim AS llama-bin |
| ARG LLAMA_CPP_TAG |
| ARG LLAMA_CPP_ARCHIVE |
|
|
| RUN apt-get update && apt-get install -y --no-install-recommends \ |
| ca-certificates curl tar \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| RUN mkdir -p /opt/llama.cpp \ |
| && curl -L --fail \ |
| "https://github.com/ggml-org/llama.cpp/releases/download/${LLAMA_CPP_TAG}/${LLAMA_CPP_ARCHIVE}" \ |
| | tar -xz --strip-components=1 -C /opt/llama.cpp \ |
| && test -x /opt/llama.cpp/llama-server |
|
|
| |
| |
| |
| FROM python:3.11-slim AS model-fetch |
| ARG GGUF_REPO |
| ARG GGUF_FILE |
|
|
| RUN pip install --no-cache-dir "huggingface_hub>=0.23" |
| RUN python3 -c "from huggingface_hub import hf_hub_download; \ |
| hf_hub_download(repo_id='${GGUF_REPO}', filename='${GGUF_FILE}', local_dir='/models')" |
|
|
| |
| |
| |
| FROM python:3.11-slim |
| ARG GGUF_FILE |
|
|
| |
| RUN apt-get update && apt-get install -y --no-install-recommends \ |
| libcurl4 libgomp1 curl \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| |
| RUN useradd -m -u 1000 user |
| ENV HOME=/home/user \ |
| PATH=/opt/llama.cpp:/home/user/.local/bin:$PATH \ |
| LD_LIBRARY_PATH=/opt/llama.cpp \ |
| PYTHONUNBUFFERED=1 \ |
| IRIS_MODEL_PATH=/models/${GGUF_FILE} |
|
|
| COPY --from=llama-bin /opt/llama.cpp /opt/llama.cpp |
| COPY --from=model-fetch /models /models |
|
|
| WORKDIR /app |
| COPY requirements.txt ./ |
| RUN pip install --no-cache-dir -r requirements.txt |
|
|
| COPY . /app |
| RUN python scripts/patch_gradio_templates.py \ |
| && chmod +x /app/scripts/space_entrypoint.sh \ |
| && chown -R user:user /app /models |
|
|
| USER user |
| EXPOSE 7860 |
| ENTRYPOINT ["/app/scripts/space_entrypoint.sh"] |
|
|