aleks-gotsa commited on
Commit
849e756
·
1 Parent(s): 0699509

fix: build on llama.cpp ubuntu24 base, resolves glibc mismatch

Browse files
Files changed (2) hide show
  1. Dockerfile +26 -25
  2. start.sh +1 -1
Dockerfile CHANGED
@@ -1,46 +1,47 @@
1
  # Paper Decoder — HF Space (Docker SDK)
2
- # llama.cpp server (official image binaries) + Tesseract OCR (ukr/rus) + Gradio 6
 
 
 
3
 
4
- # Stage 1: take llama-server + shared libs from the official CPU server image.
5
- # Layout verified 2026-06-10 against .devops/cpu.Dockerfile: binary and all
6
- # *.so* live flat in /app; runtime needs libgomp1 and curl.
7
- FROM ghcr.io/ggml-org/llama.cpp:server AS llama
8
 
9
- FROM python:3.11-slim-bookworm
 
10
 
11
- # System deps: OCR (Ukrainian + Russian traineddata), llama.cpp runtime libs
12
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
 
13
  tesseract-ocr \
14
  tesseract-ocr-ukr \
15
  tesseract-ocr-rus \
16
- libgomp1 \
17
- curl \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
- COPY --from=llama /app /opt/llama
21
- ENV LD_LIBRARY_PATH=/opt/llama
22
-
23
- # Bake the model into the image at build time: faster Space restarts,
24
- # no runtime download. Exact file pin recorded after first build.
25
- RUN pip install --no-cache-dir "huggingface_hub>=1.0,<2.0" && \
26
  hf download unsloth/Qwen3-4B-Instruct-2507-GGUF \
27
- --include "*Q4_K_M*.gguf" --local-dir /opt/models && \
28
- find /opt/models -name "*.gguf" -exec ls -lh {} \;
29
 
30
  COPY requirements.txt /tmp/requirements.txt
31
- RUN pip install --no-cache-dir -r /tmp/requirements.txt
32
 
33
- # HF Spaces convention: run as non-root user with UID 1000
34
- RUN useradd -m -u 1000 user
35
- USER user
36
- ENV HOME=/home/user \
37
- PATH=/home/user/.local/bin:$PATH \
38
  GRADIO_SERVER_NAME=0.0.0.0 \
39
  GRADIO_SERVER_PORT=7860
40
 
41
- WORKDIR /home/user/app
42
- COPY --chown=user app.py start.sh ./
43
  RUN chmod +x start.sh
44
 
45
  EXPOSE 7860
 
 
46
  CMD ["./start.sh"]
 
1
  # Paper Decoder — HF Space (Docker SDK)
2
+ # Base: official llama.cpp server image (Ubuntu 24.04). Building directly on it
3
+ # avoids the glibc mismatch hit when copying its binaries into Debian bookworm
4
+ # (binaries need GLIBC_2.38; bookworm ships 2.36).
5
+ # llama-server binary and its libs live in /app.
6
 
7
+ FROM ghcr.io/ggml-org/llama.cpp:server
 
 
 
8
 
9
+ ENV DEBIAN_FRONTEND=noninteractive \
10
+ LD_LIBRARY_PATH=/app
11
 
12
+ # Python + OCR (Ukrainian + Russian traineddata). curl is already in the base.
13
  RUN apt-get update && apt-get install -y --no-install-recommends \
14
+ python3 \
15
+ python3-pip \
16
  tesseract-ocr \
17
  tesseract-ocr-ukr \
18
  tesseract-ocr-rus \
 
 
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
+ # Bake the model into the image at build time.
22
+ # Pin confirmed from first build log: Qwen3-4B-Instruct-2507-Q4_K_M.gguf
23
+ # Ubuntu 24.04 pip is PEP 668 managed -> --break-system-packages.
24
+ RUN pip3 install --no-cache-dir --break-system-packages "huggingface_hub>=1.0,<2.0" && \
 
 
25
  hf download unsloth/Qwen3-4B-Instruct-2507-GGUF \
26
+ --include "Qwen3-4B-Instruct-2507-Q4_K_M.gguf" --local-dir /opt/models && \
27
+ ls -lh /opt/models
28
 
29
  COPY requirements.txt /tmp/requirements.txt
30
+ RUN pip3 install --no-cache-dir --break-system-packages -r /tmp/requirements.txt
31
 
32
+ # Ubuntu 24.04 already ships a UID-1000 user named 'ubuntu' — reuse it
33
+ # (useradd -u 1000 would fail as non-unique).
34
+ USER ubuntu
35
+ ENV HOME=/home/ubuntu \
36
+ PATH=/home/ubuntu/.local/bin:$PATH \
37
  GRADIO_SERVER_NAME=0.0.0.0 \
38
  GRADIO_SERVER_PORT=7860
39
 
40
+ WORKDIR /home/ubuntu/app
41
+ COPY --chown=ubuntu app.py start.sh ./
42
  RUN chmod +x start.sh
43
 
44
  EXPOSE 7860
45
+ # Parent image's ENTRYPOINT is /app/llama-server — reset it.
46
+ ENTRYPOINT []
47
  CMD ["./start.sh"]
start.sh CHANGED
@@ -8,7 +8,7 @@ if [ -z "$MODEL" ]; then
8
  fi
9
  echo ">> starting llama-server with $MODEL"
10
 
11
- /opt/llama/llama-server \
12
  -m "$MODEL" \
13
  --host 127.0.0.1 \
14
  --port 8081 \
 
8
  fi
9
  echo ">> starting llama-server with $MODEL"
10
 
11
+ /app/llama-server \
12
  -m "$MODEL" \
13
  --host 127.0.0.1 \
14
  --port 8081 \