Samixx commited on
Commit
6367463
·
verified ·
1 Parent(s): 2828128

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +53 -6
Dockerfile CHANGED
@@ -1,10 +1,57 @@
1
- FROM ghcr.io/ggml-org/llama.cpp:server
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  EXPOSE 7860
4
 
5
- CMD ["--hf-repo", "Qwen/Qwen2.5-3B-Instruct-GGUF", \
6
- "--hf-file", "qwen2.5-3b-instruct-q4_k_m.gguf", \
7
- "--port", "7860", \
 
 
8
  "--host", "0.0.0.0", \
9
- "--chat-template", "chatml", \
10
- "-c", "8192"]
 
 
 
 
1
+ FROM debian:bookworm-slim AS builder
2
 
3
+ RUN apt-get update && apt-get install -y \
4
+ build-essential \
5
+ cmake \
6
+ git \
7
+ curl \
8
+ libcurl4-openssl-dev \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ WORKDIR /build
12
+
13
+ # Pin a known-good release; bump as needed
14
+ RUN git clone --depth 1 --branch b3600 https://github.com/ggerganov/llama.cpp.git
15
+
16
+ WORKDIR /build/llama.cpp
17
+
18
+ # Build with CPU-only, no CUDA. Enable native arch optimizations (AVX2 etc if host supports it)
19
+ RUN cmake -B build \
20
+ -DGGML_NATIVE=ON \
21
+ -DGGML_CUDA=OFF \
22
+ -DLLAMA_CURL=ON \
23
+ -DCMAKE_BUILD_TYPE=Release \
24
+ && cmake --build build --config Release -j2 --target llama-server
25
+
26
+ # ---- Runtime stage ----
27
+ FROM debian:bookworm-slim
28
+
29
+ RUN apt-get update && apt-get install -y \
30
+ libcurl4 \
31
+ ca-certificates \
32
+ curl \
33
+ && rm -rf /var/lib/apt/lists/*
34
+
35
+ WORKDIR /app
36
+
37
+ COPY --from=builder /build/llama.cpp/build/bin/llama-server /app/llama-server
38
+
39
+ # Pull the GGUF model at build time (Q4_K_M quant, ~1GB for 1.5B model)
40
+ # Swap this URL for whichever quant repo you land on (e.g. bartowski/Qwen2.5-1.5B-Instruct-GGUF)
41
+ ARG MODEL_URL=https://huggingface.co/bartowski/Qwen2.5-1.5B-Instruct-GGUF/resolve/main/Qwen2.5-1.5B-Instruct-Q4_K_M.gguf
42
+ RUN curl -L -o /app/model.gguf "${MODEL_URL}"
43
+
44
+ # HF Spaces expects the app to listen on port 7860
45
  EXPOSE 7860
46
 
47
+ # --threads 2 to match vCPU count, avoid oversubscription
48
+ # --ctx-size kept small since bot commands are short
49
+ # -ngl 0 forces CPU-only (no GPU layers offloaded)
50
+ CMD ["/app/llama-server", \
51
+ "-m", "/app/model.gguf", \
52
  "--host", "0.0.0.0", \
53
+ "--port", "7860", \
54
+ "--threads", "2", \
55
+ "--ctx-size", "2048", \
56
+ "-ngl", "0", \
57
+ "--batch-size", "512"]