build-small-hackathon/MiniCPM5-1B-Agent
3
1# MiniCPM5-1B-Agent demo Space - llama.cpp server (Q8_0 GGUF) + the agent-loop UI (app.py).2# Based on the proven usermma/MiniCPM-5-Q4 pattern (FROM ghcr.io/ggml-org/llama.cpp:full), but instead3# of the raw chat UI we run app.py, which starts llama-server itself and drives the write->run->verify loop.4FROM ghcr.io/ggml-org/llama.cpp:full5 6WORKDIR /app7 8# Python venv for the app deps (keep separate from the image's own python usage).9RUN apt-get update && apt-get install -y --no-install-recommends python3-pip python3-venv \10 && rm -rf /var/lib/apt/lists/*11RUN python3 -m venv /opt/venv12ENV PATH="/opt/venv/bin:$PATH"13 14COPY requirements.txt /app/requirements.txt15RUN pip install --no-cache-dir -U pip && pip install --no-cache-dir -r /app/requirements.txt16 17# The :full image ships the standalone binaries under /app (entrypoint is /app/tools.sh dispatcher).18# Make `llama-server` resolvable on PATH for agent.py (CODEAGENT_LLAMA_BIN). Prefer the known19# /app/llama-server; fall back to a search. Fail the build loudly if neither resolves.20RUN if [ -x /app/llama-server ]; then ln -sf /app/llama-server /usr/local/bin/llama-server; \21 else ln -sf "$(find / -name llama-server -type f 2>/dev/null | head -1)" /usr/local/bin/llama-server; fi \22 && llama-server --version 2>&1 | head -123 24# The GGUF is pulled at RUNTIME by app.py from the (now public) model repo - HF_TOKEN optional25# (MODEL_REPO/MODEL_FILE below) - not baked into the image, so the private model never lives in the layers.26 27# App code + bundled backend / schema. The tokenizer is NOT bundled - app.py pulls it at runtime from the28# model repo (MODEL_REPO/tokenizer) so the tokenizer lives in exactly one place (the GGUF repo, with the model).29COPY app.py /app/app.py30COPY backend /app/backend31COPY data /app/data32 33ENV CODEAGENT_PROJ=/app \34 CODEAGENT_LLAMA_BIN=llama-server \35 CODEAGENT_GGUF=/app/model.gguf \36 CODEAGENT_CTX=131072 \37 CODEAGENT_THREADS=2 \38 CODEAGENT_MAX_ITERS=20 \39 CODEAGENT_BASH_TIMEOUT=150 \40 MODEL_REPO=Luminia/MiniCPM5-1B-Agent-GGUF \41 MODEL_FILE=MiniCPM5-1B-Agent-v4-Q8_0.gguf \42 HF_HOME=/app/.hf43# HF_TOKEN optional now the model repo is public (kept for back-compat; popped after download).44 45# Override the llama.cpp image's entrypoint - we launch the Python app, which spawns llama-server itself.46ENTRYPOINT []47CMD ["python3", "/app/app.py"]48 