broadfield commited on
Commit
744efc7
·
verified ·
1 Parent(s): f2ff3f1

Update via HuggingBot

Browse files
Files changed (1) hide show
  1. Dockerfile +99 -0
Dockerfile ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ─────────────────────────────────────────────────────────────────────────────
2
+ # OpenJev decision API — ZERO GPU (pure CPU)
3
+ #
4
+ # Official, unmodified openjev-server, pointed at llama.cpp (CPU GGUF) instead
5
+ # of vLLM:
6
+ #
7
+ # 1. builder — compiles llama.cpp `llama-server` for CPU (no CUDA/HIP/Metal)
8
+ # and `pip install`s the official openjev-server package
9
+ # 2. runtime — runs llama.cpp on CPU + openjev-server on $PORT (7860 on HF)
10
+ #
11
+ # Why this works: openjev-server's `vllm` backend is really "any OpenAI-
12
+ # compatible server that returns logprobs". It sends standard /chat/completions
13
+ # JSON (logprobs + top_logprobs + allowed_token_ids) and, when vLLM's
14
+ # `logprob_token_ids` extension is absent, falls back to matching the top-K
15
+ # logprobs by label text (see openjev_server/backends/vllm.py `_scores`).
16
+ # llama.cpp's OpenAI endpoint supports exactly that, so the official code path
17
+ # runs unmodified. --force is set because llama.cpp's chat template follows the
18
+ # GGUF so closely that the probe letter-mass check stays above the threshold.
19
+ #
20
+ # HF Spaces ingress :7860 -> openjev-server (UI, /v1/systemone, /docs, ops)
21
+ # internal 127.0.0.1:8080 -> llama.cpp (OpenAI-compatible, logprobs on)
22
+ # ─────────────────────────────────────────────────────────────────────────────
23
+
24
+ FROM python:3.12-slim AS builder
25
+ WORKDIR /build
26
+ ENV DEBIAN_FRONTEND=noninteractive
27
+ RUN apt-get update && apt-get install -y --no-install-recommends \
28
+ build-essential git cmake ninja-build curl ca-certificates \
29
+ && rm -rf /var/lib/apt/lists/*
30
+
31
+ # ---- llama.cpp: CPU-only build (no CUDA/HIP/Metal flags anywhere) -----------
32
+ ARG LLAMA_CPP_REF=b4630
33
+ RUN git clone https://github.com/ggml-org/llama.cpp.git /llama.cpp \
34
+ && cd /llama.cpp \
35
+ && git checkout ${LLAMA_CPP_REF} \
36
+ && git submodule update --init --depth 1 \
37
+ && cmake -B build -DCMAKE_BUILD_TYPE=Release -DGGML_NATIVE=OFF -DGGML_CPU_ALL=ON \
38
+ && cmake --build build --target llama-server -j"$(nproc)" \
39
+ && cmake --install build --prefix /opt/llama
40
+
41
+ # ---- official openjev-server (unmodified, straight from the upstream repo) --
42
+ ARG OPENJEV_SERVER_REF=main
43
+ RUN git clone --depth 1 https://github.com/abhishekgahlot2/openjev-server.git /openjev-server \
44
+ && cd /openjev-server \
45
+ && git checkout ${OPENJEV_SERVER_REF} \
46
+ && pip install --no-cache-dir . \
47
+ && cp -r profiles /build/profiles
48
+
49
+ # ─────────────────────────────────────────────── runtime
50
+ FROM python:3.12-slim AS runtime
51
+ WORKDIR /app
52
+ ENV DEBIAN_FRONTEND=noninteractive \
53
+ PYTHONUNBUFFERED=1 \
54
+ PIP_NO_CACHE_DIR=1 \
55
+ HF_HOME=/data/.cache/huggingface \
56
+ OPENJEV_HOST=0.0.0.0 \
57
+ OPENJEV_PORT=7860 \
58
+ OPENJEV_BACKEND=vllm \
59
+ OPENJEV_VLLM_URL=http://127.0.0.1:8080/v1 \
60
+ OPENJEV_MODEL=openjev/openjev \
61
+ OPENJEV_SERVED_MODEL_NAME=openjev \
62
+ OPENJEV_PROFILE=openjev \
63
+ OPENJEV_TOKEN="" \
64
+ MODEL_REPO=openjev/openjev-GGUF \
65
+ MODEL_FILE=OpenJev-Q4_K_M.gguf \
66
+ TOKENIZER_REPO=openjev/openjev \
67
+ LLAMA_THREADS="" \
68
+ LLAMA_THREADS_BATCH="" \
69
+ LLAMA_CTX=8192 \
70
+ LLAMA_MAX_LOGPROBS=64 \
71
+ LLAMA_PARALLEL=1 \
72
+ LLAMA_PORT=8080
73
+
74
+ RUN apt-get update && apt-get install -y --no-install-recommends \
75
+ curl ca-certificates libgomp1 \
76
+ && rm -rf /var/lib/apt/lists/* \
77
+ && useradd -m -u 1000 app \
78
+ && mkdir -p /data /app/models \
79
+ && curl -fsSL https://raw.githubusercontent.com/abhishekgahlot2/openjev-server/main/README.md -o /usr/share/OPENJEV-README.md
80
+
81
+ # llama.cpp runtime binaries
82
+ COPY --from=builder /opt/llama /opt/llama
83
+ ENV PATH="/opt/llama/bin:${PATH}"
84
+
85
+ # openjev-server (installed in builder)
86
+ COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
87
+ COPY --from=builder /usr/local/bin /usr/local/bin
88
+ COPY --from=builder /build/profiles /usr/local/lib/python3.12/site-packages/profiles
89
+
90
+ COPY entrypoint.sh ./
91
+ RUN chmod +x /app/entrypoint.sh \
92
+ && chown -R app:app /data /app
93
+
94
+ USER app
95
+ EXPOSE 7860 8080
96
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=900s --retries=3 \
97
+ CMD curl -fsS http://127.0.0.1:7860/healthz || exit 1
98
+
99
+ ENTRYPOINT ["./entrypoint.sh"]