zapashwin commited on
Commit
444be2f
·
verified ·
1 Parent(s): acbfba6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -30
Dockerfile CHANGED
@@ -1,39 +1,29 @@
1
- # Step 1: Download model using lightweight image
2
- FROM alpine:latest AS downloader
3
- RUN apk add --no-cache curl
4
- WORKDIR /models
5
- RUN curl -L https://huggingface.co/unsloth/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q4_K_M.gguf -o model.gguf
6
-
7
- # Step 2: Main image combining llama-server + Open WebUI / lightweight UI
8
  FROM ghcr.io/ggml-org/llama.cpp:server
9
 
10
  USER root
11
- # Install python and Open WebUI dependencies
12
- RUN apt-get update && apt-get install -y --no-install-recommends \
13
- python3 python3-pip curl supervisor && \
14
- pip install open-webui --no-cache-dir && \
15
- rm -rf /var/lib/apt/lists/*
16
 
17
- COPY --from=downloader /models/model.gguf /models/model.gguf
 
 
 
 
 
 
 
18
 
19
- # Configure environment variables
20
- ENV PORT=7860
21
- ENV OPENAI_API_BASE_URL=http://127.0.0.1:8080/v1
22
  ENV LLAMA_ARG_MODEL=/models/model.gguf
23
- ENV LLAMA_ARG_HOST=127.0.0.1
24
- ENV LLAMA_ARG_PORT=8080
25
- ENV LLAMA_ARG_THREADS=2
26
 
27
- # Create supervisor config to manage both processes
28
- RUN echo '[supervisord]\n\
29
- nodaemon=true\n\
30
- [program:llama]\n\
31
- command=/app/llama-server --model /models/model.gguf --host 127.0.0.1 --port 8080 -t 2 -c 2048\n\
32
- autorestart=true\n\
33
- [program:webui]\n\
34
- command=open-webui serve --port 7860\n\
35
- autorestart=true' > /etc/supervisor/conf.d/supervisord.conf
36
 
37
- EXPOSE 7860
 
38
 
39
- CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
 
 
 
 
 
 
 
 
1
  FROM ghcr.io/ggml-org/llama.cpp:server
2
 
3
  USER root
 
 
 
 
 
4
 
5
+ # Download model directly in a single layer to minimize image size
6
+ RUN apt-get update && apt-get install -y --no-install-recommends curl && \
7
+ mkdir -p /models && \
8
+ curl -L https://huggingface.co/unsloth/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q4_K_M.gguf -o /models/model.gguf && \
9
+ chown -R 1000:1000 /models && \
10
+ apt-get purge -y curl && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
11
+
12
+ USER 1000
13
 
14
+ # Server & UI Configuration
 
 
15
  ENV LLAMA_ARG_MODEL=/models/model.gguf
16
+ ENV LLAMA_ARG_HOST=0.0.0.0
17
+ ENV LLAMA_ARG_PORT=7860
 
18
 
19
+ # --- Free CPU Performance Tuning ---
20
+ ENV LLAMA_ARG_THREADS=2
21
+ ENV LLAMA_ARG_CTX_SIZE=2048
22
+ ENV LLAMA_ARG_BATCH_SIZE=128
23
+ ENV LLAMA_ARG_UBATCH_SIZE=128
24
+ ENV LLAMA_ARG_MLOCK=false
 
 
 
25
 
26
+ HEALTHCHECK --interval=30s --timeout=15s --start-period=10s --retries=3 \
27
+ CMD curl -f http://localhost:7860/health || exit 1
28
 
29
+ ENTRYPOINT ["/app/llama-server"]