Promise Emmanuel Oluwadare commited on
Commit
df729c3
·
1 Parent(s): 1dcc055

Optimize Docker build for faster HF Space startup

Browse files
Files changed (3) hide show
  1. Dockerfile +13 -9
  2. README.md +3 -2
  3. requirements.txt +1 -0
Dockerfile CHANGED
@@ -1,21 +1,25 @@
1
- FROM python:3.11-slim
2
 
3
  ENV PYTHONDONTWRITEBYTECODE=1 \
4
  PYTHONUNBUFFERED=1 \
5
  PIP_NO_CACHE_DIR=1 \
6
- CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS"
 
 
 
7
 
8
  RUN apt-get update && apt-get install -y --no-install-recommends \
9
- build-essential \
10
- cmake \
11
- pkg-config \
12
- libopenblas-dev \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
  WORKDIR /app
16
 
17
  COPY requirements.txt /app/requirements.txt
18
- RUN pip install --upgrade pip && pip install -r /app/requirements.txt
 
19
 
20
  COPY start_server.py /app/start_server.py
21
 
@@ -23,8 +27,8 @@ ENV PORT=7860 \
23
  MODEL_REPO=unsloth/Qwen3.5-0.8B-GGUF \
24
  MODEL_FILE=Qwen3.5-0.8B-Q4_K_M.gguf \
25
  MODEL_DIR=/tmp/models \
26
- N_CTX=4096 \
27
- N_THREADS=4 \
28
  CHAT_FORMAT=chatml
29
 
30
  EXPOSE 7860
 
1
+ FROM python:3.10-slim
2
 
3
  ENV PYTHONDONTWRITEBYTECODE=1 \
4
  PYTHONUNBUFFERED=1 \
5
  PIP_NO_CACHE_DIR=1 \
6
+ PIP_DISABLE_PIP_VERSION_CHECK=1 \
7
+ PIP_DEFAULT_TIMEOUT=120 \
8
+ HF_HOME=/tmp/hf-cache \
9
+ HF_HUB_ENABLE_HF_TRANSFER=1
10
 
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ ca-certificates \
13
+ curl \
14
+ git \
15
+ libgomp1 \
16
  && rm -rf /var/lib/apt/lists/*
17
 
18
  WORKDIR /app
19
 
20
  COPY requirements.txt /app/requirements.txt
21
+ RUN python -m pip install --upgrade pip setuptools wheel && \
22
+ pip install --prefer-binary -r /app/requirements.txt
23
 
24
  COPY start_server.py /app/start_server.py
25
 
 
27
  MODEL_REPO=unsloth/Qwen3.5-0.8B-GGUF \
28
  MODEL_FILE=Qwen3.5-0.8B-Q4_K_M.gguf \
29
  MODEL_DIR=/tmp/models \
30
+ N_CTX=2048 \
31
+ N_THREADS=2 \
32
  CHAT_FORMAT=chatml
33
 
34
  EXPOSE 7860
README.md CHANGED
@@ -5,6 +5,7 @@ colorFrom: yellow
5
  colorTo: gray
6
  sdk: docker
7
  app_port: 7860
 
8
  pinned: false
9
  ---
10
 
@@ -39,8 +40,8 @@ Recommended defaults:
39
 
40
  - `MODEL_REPO=unsloth/Qwen3.5-0.8B-GGUF`
41
  - `MODEL_FILE=Qwen3.5-0.8B-Q4_K_M.gguf`
42
- - `N_CTX=4096`
43
- - `N_THREADS=4`
44
  - `CHAT_FORMAT=chatml`
45
 
46
  Optional:
 
5
  colorTo: gray
6
  sdk: docker
7
  app_port: 7860
8
+ startup_duration_timeout: 2h
9
  pinned: false
10
  ---
11
 
 
40
 
41
  - `MODEL_REPO=unsloth/Qwen3.5-0.8B-GGUF`
42
  - `MODEL_FILE=Qwen3.5-0.8B-Q4_K_M.gguf`
43
+ - `N_CTX=2048`
44
+ - `N_THREADS=2`
45
  - `CHAT_FORMAT=chatml`
46
 
47
  Optional:
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  llama-cpp-python[server]>=0.2.90
2
  huggingface_hub>=0.25.0
 
 
1
  llama-cpp-python[server]>=0.2.90
2
  huggingface_hub>=0.25.0
3
+ hf_transfer>=0.1.8