omaryasserhassan commited on
Commit
cea5896
·
verified ·
1 Parent(s): f8e14ab

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -25
Dockerfile CHANGED
@@ -1,37 +1,27 @@
 
1
  FROM python:3.11-slim
2
 
3
- # System deps for llama-cpp build
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
5
- build-essential cmake git && \
6
- rm -rf /var/lib/apt/lists/*
7
 
 
 
 
 
 
8
  WORKDIR /app
9
 
10
- # App deps
11
- COPY requirements.txt .
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
14
- # --- Bake model into the image (change these ENV if you prefer Phi-3 mini) ---
15
- ENV MODEL_REPO=Qwen/Qwen2.5-3B-Instruct-GGUF
16
- ENV MODEL_FILE=qwen2.5-3b-instruct-q4_k_m.gguf
17
-
18
- # Download GGUF at build time to /app/models (no symlinks)
19
- RUN python - <<'PY'
20
- from huggingface_hub import snapshot_download
21
- import os
22
- local_dir = "/app/models"
23
- os.makedirs(local_dir, exist_ok=True)
24
- snapshot_download(
25
- repo_id=os.environ.get("MODEL_REPO"),
26
- allow_patterns=[os.environ.get("MODEL_FILE")],
27
- local_dir=local_dir,
28
- local_dir_use_symlinks=False,
29
- )
30
- print("Model baked into image at /app/models")
31
- PY
32
-
33
  # App code
34
- COPY app.py .
35
 
 
36
  EXPOSE 7860
 
 
37
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use a small Python base
2
  FROM python:3.11-slim
3
 
4
+ # System deps (curl only for quick debugging if needed)
5
  RUN apt-get update && apt-get install -y --no-install-recommends \
6
+ curl \
7
+ && rm -rf /var/lib/apt/lists/*
8
 
9
+ # Set persistent cache location for Docker Spaces
10
+ ENV HF_HOME=/data/hf_cache
11
+ ENV HUGGINGFACE_HUB_CACHE=/data/hf_cache
12
+
13
+ # App dir
14
  WORKDIR /app
15
 
16
+ # Dependencies
17
+ COPY requirements.txt /app/requirements.txt
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  # App code
21
+ COPY app.py /app/app.py
22
 
23
+ # Expose Space port
24
  EXPOSE 7860
25
+
26
+ # Start the API
27
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]