File size: 764 Bytes
c2c02ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Base image with Python and llama-cpp dependencies
FROM python:3.11-slim

# System dependencies for llama-cpp
RUN apt-get update && apt-get install -y \
    build-essential \
    cmake \
    wget \
    git \
    && rm -rf /var/lib/apt/lists/*

# Install Python packages
RUN pip install --no-cache-dir \
    llama-cpp-python==0.2.66 \
    fastapi \
    uvicorn \
    huggingface-hub

# Create app directory
WORKDIR /app
COPY . /app

# Download model from Hugging Face Hub (on container startup)
ENV MODEL_REPO=TheBloke/phi-2-GGUF
ENV MODEL_FILE=phi-2.Q4_K_M.gguf

# Create model loader script
RUN echo '#!/bin/bash\n'\
'python download_model.py\n'\
'uvicorn main:app --host 0.0.0.0 --port 7860' > entrypoint.sh && \
chmod +x entrypoint.sh

CMD ["./entrypoint.sh"]