# Build-time downloads contain no application/user data. Weights are baked into
# the final image; runtime has neither a model URL nor Internet access.
FROM debian:bookworm-slim AS model
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && rm -rf /var/lib/apt/lists/*
RUN curl --fail --location --retry 3 'https://huggingface.co/bartowski/SmolLM2-135M-Instruct-GGUF/resolve/09816acd5d99df7be770d85ea30822623dab342c/SmolLM2-135M-Instruct-Q4_K_M.gguf' -o /model.gguf \
    && echo '2e8040ceae7815abe0dcb3540b9995eaa1fa0d2ca9e797d0a635ae4433c68c2d  /model.gguf' | sha256sum -c - \
    && chmod 444 /model.gguf
RUN curl --fail --location https://www.apache.org/licenses/LICENSE-2.0.txt -o /LICENSE-model.txt
FROM ghcr.io/ggml-org/llama.cpp:server
COPY --from=model /model.gguf /models/model.gguf
COPY --from=model /LICENSE-model.txt /licenses/LICENSE-model.txt
COPY MODEL-NOTICE.txt /licenses/MODEL-NOTICE.txt
# The image's llama-server entrypoint runs a single local CPU model.
# No tools, MCP, browser, external endpoints or runtime weight downloads.
USER 65532:65532
EXPOSE 8080
CMD ["-m", "/models/model.gguf", "--host", "0.0.0.0", "--port", "8080", "-c", "4096", "-np", "1", "-t", "2", "--no-webui", "--log-disable"]
