viskav commited on
Commit
d10225f
·
verified ·
1 Parent(s): cb930f8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -27
Dockerfile CHANGED
@@ -2,42 +2,23 @@ FROM python:3.10-slim
2
 
3
  WORKDIR /code
4
 
5
- # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
8
- curl \
9
  git \
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # Copy requirements first for better caching
13
  COPY requirements.txt .
14
 
15
- # Install Python dependencies
16
- RUN pip install --no-cache-dir -r requirements.txt
 
17
 
18
- # Download model during build (optional - can also download at runtime)
19
- ARG HF_TOKEN=""
20
- RUN if [ -n "$HF_TOKEN" ]; then \
21
- python -c "from huggingface_hub import hf_hub_download; \
22
- hf_hub_download(repo_id='bartowski/Phi-3.1-mini-4k-instruct-GGUF', \
23
- filename='Phi-3.1-mini-4k-instruct-IQ2_M.gguf', \
24
- local_dir='/code', token='$HF_TOKEN')"; \
25
- else \
26
- echo "HF_TOKEN not provided, model will download at runtime"; \
27
- fi
28
-
29
- # Copy application code
30
  COPY app.py .
31
 
32
- # Create a directory for models if it doesn't exist
33
- RUN mkdir -p /code
34
-
35
- # Expose port (Hugging Face Spaces uses 7860)
36
  EXPOSE 7860
37
 
38
- # Health check
39
- HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
40
- CMD curl -f http://localhost:7860/health || exit 1
41
-
42
- # Run the app
43
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
 
2
 
3
  WORKDIR /code
4
 
5
+ # Install build dependencies for llama-cpp-python
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
 
8
  git \
9
+ cmake \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Copy requirements first
13
  COPY requirements.txt .
14
 
15
+ # Install with specific BLAS backend for better performance
16
+ RUN CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" \
17
+ pip install --no-cache-dir -r requirements.txt
18
 
19
+ # Copy app
 
 
 
 
 
 
 
 
 
 
 
20
  COPY app.py .
21
 
 
 
 
 
22
  EXPOSE 7860
23
 
24
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]