ChoruYt commited on
Commit
56f52c6
·
verified ·
1 Parent(s): 7e90db7

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -5
Dockerfile CHANGED
@@ -1,26 +1,39 @@
1
  FROM python:3.11-slim
2
 
 
3
  RUN apt-get update && apt-get install -y --no-install-recommends gcc libc6-dev && rm -rf /var/lib/apt/lists/*
4
 
5
  WORKDIR /app
6
 
 
7
  RUN pip install --no-cache-dir flask flask-cors Pillow litert-lm huggingface_hub
8
 
9
- COPY server.py .
10
-
11
- RUN mkdir -p models/gemma
12
-
13
  RUN printf 'void vkGetInstanceProcAddr(){}\nvoid vkCreateInstance(){}\nvoid vkDestroyInstance(){}\nvoid vkEnumeratePhysicalDevices(){}\nvoid vkGetDeviceProcAddr(){}' > /tmp/vk.c \
14
  && gcc -shared -fPIC -o /app/libvulkan.so.1 /tmp/vk.c \
15
  && rm /tmp/vk.c
16
 
 
 
 
 
 
 
 
 
 
 
 
17
  RUN useradd -m -u 1000 user
18
  RUN chown -R user:user /app
19
  USER user
20
 
 
21
  ENV PORT=7860
22
  ENV LD_LIBRARY_PATH=/app
 
 
23
 
24
  EXPOSE 7860
25
 
26
- CMD ["python3", "server.py"]
 
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 (added huggingface_hub which includes the CLI)
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 CHANGE: Download the model during the Docker build ---
20
+ # This bakes the model into your Hugging Face Space image
21
+ RUN huggingface-cli download litert-community/gemma-4-E2B-it-litert-lm gemma-4-E2B-it.litertlm --local-dir /app/models/gemma
22
+
23
+ # Copy the server code
24
+ COPY server.py .
25
+
26
+ # Setup permissions for Hugging Face Spaces (requires user 1000)
27
  RUN useradd -m -u 1000 user
28
  RUN chown -R user:user /app
29
  USER user
30
 
31
+ # Set environment variables
32
  ENV PORT=7860
33
  ENV LD_LIBRARY_PATH=/app
34
+ # --- KEY CHANGE: Point the Python script directly to the baked-in model ---
35
+ ENV GEMMA_MODEL_PATH=/app/models/gemma/gemma-4-E2B-it.litertlm
36
 
37
  EXPOSE 7860
38
 
39
+ CMD ["python3", "server.py"]