ramedde commited on
Commit
2cf086d
·
verified ·
1 Parent(s): 745bbdb

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +40 -20
Dockerfile CHANGED
@@ -1,17 +1,8 @@
1
  FROM python:3.11-slim
2
 
3
  RUN apt-get update && apt-get install -y \
4
- git \
5
- git-lfs \
6
- ffmpeg \
7
- libsm6 \
8
- libxext6 \
9
- cmake \
10
- rsync \
11
- libgl1 \
12
- g++ \
13
- gcc \
14
- build-essential \
15
  && rm -rf /var/lib/apt/lists/* \
16
  && git lfs install
17
 
@@ -21,25 +12,54 @@ WORKDIR /app
21
 
22
  ENV GRADIO_SERVER_NAME="0.0.0.0"
23
  ENV GRADIO_SERVER_PORT="7860"
 
24
 
25
- RUN pip install --no-cache-dir --upgrade pip
26
- # Download model using wget directly (no token needed for public models)
27
- RUN apt-get update && apt-get install -y wget && \
28
- wget -q --show-progress \
29
  "https://huggingface.co/unsloth/Qwen2.5-Coder-0.5B-Instruct-128K-GGUF/resolve/main/Qwen2.5-Coder-0.5B-Instruct-F16.gguf" \
30
  -O /app/model.gguf && \
31
  echo "✅ Model size: $(du -sh /app/model.gguf)"
32
 
 
 
 
 
 
 
 
 
 
33
 
34
-
35
  COPY requirements.txt .
36
- RUN pip install --no-cache-dir -r requirements.txt
 
37
 
 
38
  COPY --chown=user:user . /app
39
 
40
- USER user
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
 
42
  EXPOSE 7860
43
 
44
-
45
- CMD ["python", "app.py"]
 
1
  FROM python:3.11-slim
2
 
3
  RUN apt-get update && apt-get install -y \
4
+ git git-lfs ffmpeg libsm6 libxext6 \
5
+ cmake rsync libgl1 g++ gcc build-essential wget curl \
 
 
 
 
 
 
 
 
 
6
  && rm -rf /var/lib/apt/lists/* \
7
  && git lfs install
8
 
 
12
 
13
  ENV GRADIO_SERVER_NAME="0.0.0.0"
14
  ENV GRADIO_SERVER_PORT="7860"
15
+ ENV LLAMA_SERVER_URL="http://127.0.0.1:8080"
16
 
17
+ # ── 1. Download GGUF model ──────────────────────────────────────────────────
18
+ RUN wget -q --show-progress \
 
 
19
  "https://huggingface.co/unsloth/Qwen2.5-Coder-0.5B-Instruct-128K-GGUF/resolve/main/Qwen2.5-Coder-0.5B-Instruct-F16.gguf" \
20
  -O /app/model.gguf && \
21
  echo "✅ Model size: $(du -sh /app/model.gguf)"
22
 
23
+ # ── 2. Download pre-built llama-server binary (llama.cpp release b4786) ────
24
+ RUN wget -q --show-progress \
25
+ "https://github.com/ggerganov/llama.cpp/releases/download/b4786/llama-b4786-bin-ubuntu-x64.zip" \
26
+ -O /tmp/llama.zip && \
27
+ unzip /tmp/llama.zip -d /tmp/llama_bin && \
28
+ find /tmp/llama_bin -name "llama-server" -exec cp {} /usr/local/bin/llama-server \; && \
29
+ chmod +x /usr/local/bin/llama-server && \
30
+ rm -rf /tmp/llama.zip /tmp/llama_bin && \
31
+ echo "✅ llama-server: $(llama-server --version 2>&1 | head -1)"
32
 
33
+ # ── 3. Python deps ──────────────────────────────────────────────────────────
34
  COPY requirements.txt .
35
+ RUN pip install --no-cache-dir --upgrade pip && \
36
+ pip install --no-cache-dir -r requirements.txt
37
 
38
+ # ── 4. App code ─────────────────────────────────────────────────────────────
39
  COPY --chown=user:user . /app
40
 
41
+ # ── 5. Startup script: launch llama-server then the Gradio app ─────────────
42
+ RUN echo '#!/bin/bash\n\
43
+ llama-server \
44
+ --model /app/model.gguf \
45
+ --host 127.0.0.1 \
46
+ --port 8080 \
47
+ --ctx-size 512 \
48
+ --threads 2 \
49
+ --n-predict 256 \
50
+ --no-mmap \
51
+ &\n\
52
+ # Wait until the server is ready\n\
53
+ echo "[startup] Waiting for llama-server..."\n\
54
+ for i in $(seq 1 30); do\n\
55
+ curl -sf http://127.0.0.1:8080/health && break\n\
56
+ sleep 2\n\
57
+ done\n\
58
+ echo "[startup] llama-server ready, launching app"\n\
59
+ exec python app.py\n\
60
+ ' > /app/start.sh && chmod +x /app/start.sh
61
 
62
+ USER user
63
  EXPOSE 7860
64
 
65
+ CMD ["/app/start.sh"]