viskav commited on
Commit
4acd6aa
·
verified ·
1 Parent(s): 73f597e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -8
Dockerfile CHANGED
@@ -1,21 +1,48 @@
 
 
 
 
 
1
  FROM python:3.11-slim
2
 
3
- # Install system dependencies needed for llama-cpp-python
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
5
  build-essential \
6
  cmake \
 
 
 
 
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
- # Workdir
10
- WORKDIR /app
 
 
 
 
 
 
 
11
 
12
- # Install Python deps
13
- COPY requirements.txt .
14
- RUN pip install --no-cache-dir -r requirements.txt
15
 
16
- # Copy app
17
- COPY app.py .
18
 
 
 
 
 
 
 
 
 
 
 
19
  EXPOSE 7860
20
 
 
21
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
+ # ---------------------------------------------------------
2
+ # Dockerfile for HuggingFace Spaces (Custom Docker Runtime)
3
+ # Runs FastAPI + llama-cpp-python + GGUF model
4
+ # ---------------------------------------------------------
5
+
6
  FROM python:3.11-slim
7
 
8
+ # Install system dependencies required by llama-cpp-python
9
  RUN apt-get update && apt-get install -y --no-install-recommends \
10
  build-essential \
11
  cmake \
12
+ git \
13
+ wget \
14
+ libgomp1 \
15
+ libopenblas-dev \
16
  && rm -rf /var/lib/apt/lists/*
17
 
18
+ # Set the working directory
19
+ WORKDIR /code
20
+
21
+ # Copy requirements first (for better Docker cache)
22
+ COPY requirements.txt /code/requirements.txt
23
+
24
+ # Install Python dependencies
25
+ RUN pip install --no-cache-dir --upgrade pip \
26
+ && pip install --no-cache-dir -r /code/requirements.txt
27
 
28
+ # Copy application file
29
+ COPY app.py /code/app.py
 
30
 
31
+ # Copy your model folder (GGUF file)
32
+ COPY model /code/model
33
 
34
+ # Environment variables for llama.cpp backend
35
+ ENV MODEL_PATH=/code/model/Phi-3.1-mini-4k-instruct-IQ2_M.gguf
36
+ ENV N_THREADS=4
37
+ ENV N_CTX=4096
38
+ ENV N_BATCH=512
39
+ ENV N_GPU_LAYERS=0
40
+ ENV MAX_CONCURRENT_REQUESTS=6
41
+ ENV PYTHONUNBUFFERED=1
42
+
43
+ # HuggingFace Spaces requires server to run on port 7860
44
  EXPOSE 7860
45
 
46
+ # Start FastAPI with uvicorn
47
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
48
+