CJHauser commited on
Commit
cce27f2
·
verified ·
1 Parent(s): 4da6bd3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -31
Dockerfile CHANGED
@@ -1,39 +1,37 @@
1
- FROM python:3.11-slim
 
2
 
3
- # Install system dependencies
4
- RUN apt-get update && apt-get install -y --no-install-recommends gcc libc6-dev && rm -rf /var/lib/apt/lists/*
 
 
5
 
 
6
  WORKDIR /app
7
 
8
- # Install Python dependencies
9
- RUN pip install --no-cache-dir flask flask-cors Pillow litert-lm huggingface_hub
 
 
10
 
11
- # Create dummy Vulkan library to satisfy litert-lm on CPU
12
- RUN printf 'void vkGetInstanceProcAddr(){}\nvoid vkCreateInstance(){}\nvoid vkDestroyInstance(){}\nvoid vkEnumeratePhysicalDevices(){}\nvoid vkGetDeviceProcAddr(){}' > /tmp/vk.c \
13
- && gcc -shared -fPIC -o /app/libvulkan.so.1 /tmp/vk.c \
14
- && rm /tmp/vk.c
15
 
16
- # Create model directory
17
- RUN mkdir -p /app/models/gemma
18
-
19
- # --- KEY FIX: Updated 'hf download' to fetch the 12B model ---
20
- RUN hf download litert-community/gemma-4-E2B-it-litert-lm gemma-4-E2B-it.litertlm --local-dir /app/models/gemma
21
- # Copy the server code
22
- COPY server.py .
23
-
24
- # Setup permissions for Hugging Face Spaces (requires user 1000)
25
- RUN useradd -m -u 1000 user
26
- RUN chown -R user:user /app
27
- USER user
28
-
29
- # Set environment variables
30
- ENV PORT=7860
31
- ENV LD_LIBRARY_PATH=/app
32
-
33
- # --- KEY FIX: Updated path to point to the 12B model file ---
34
- ENV GEMMA_MODEL_PATH=/app/models/gemma/gemma-4-E2B-it.litertlm
35
- # KV-cache size (prompt + generation combined). The model file supports up to 32k.
36
- ENV MAX_NUM_TOKENS=32768
37
  EXPOSE 7860
38
 
39
- CMD ["python3", "server.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a lightweight Python base image
2
+ FROM python:3.10-slim
3
 
4
+ # Install only curl to fetch the model (no build-essential or compiler tools needed)
5
+ RUN apt-get update && apt-get install -y \
6
+ curl \
7
+ && rm -rf /var/lib/apt/lists/*
8
 
9
+ # Set working directory
10
  WORKDIR /app
11
 
12
+ # Upgrade pip and instruct pip to install the pre-compiled CPU wheels
13
+ RUN pip install --no-cache-dir --upgrade pip && \
14
+ PIP_EXTRA_INDEX_URL=https://github.io \
15
+ pip install --no-cache-dir "llama-cpp-python[server]"
16
 
17
+ # Download the model
18
+ RUN curl -L -o meta-llama-3.1-8b-instruct-abliterated.Q4_K_M.gguf "https://huggingface.co/mlabonne/Meta-Llama-3.1-8B-Instruct-abliterated-GGUF/resolve/main/meta-llama-3.1-8b-instruct-abliterated.Q4_K_M.gguf"
 
 
19
 
20
+ # Expose Hugging Face Space's mandatory port
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  EXPOSE 7860
22
 
23
+ # Set environment variables for the llama-cpp server
24
+ # This enforces the API key requirement
25
+ ENV API_KEY=sk-dummykey
26
+
27
+ # Launch the server with optimized CPU and 16k context settings
28
+ # --cache_type_k/v q8_0 drastically reduces the RAM footprint of the 16k context
29
+ # Launch server
30
+ CMD ["python3", "-m", "llama_cpp.server", \
31
+ "--model", "/app/meta-llama-3.1-8b-instruct-abliterated.Q4_K_M.gguf", \
32
+ "--host", "0.0.0.0", \
33
+ "--port", "7860", \
34
+ "--n_ctx", "16384", \
35
+ "--cache_type_k", "q8_0", \
36
+ "--cache_type_v", "q8_0", \
37
+ "--api_key", "sk-dummykey"]