File size: 1,281 Bytes
d67838f
0f77255
2de07d9
 
 
 
0f77255
2de07d9
e477640
d67838f
2de07d9
d67838f
 
 
 
 
 
 
 
2de07d9
19623b8
2de07d9
 
d67838f
 
 
 
2de07d9
 
0f77255
d67838f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2de07d9
 
 
19623b8
2de07d9
0f77255
2de07d9
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
FROM python:3.10-slim AS builder

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    PORT=7860

WORKDIR /app

# Build deps: required to compile llama-cpp-python from source on HF
RUN apt-get update \
    ; apt-get install -y --no-install-recommends \
        build-essential \
        gcc \
        g++ \
        cmake \
        git \
        libgomp1 \
        ca-certificates \
    ; rm -rf /var/lib/apt/lists/*

# Install deps first (better layer caching)
COPY requirements.txt ./

# Optional: keep build simple and CPU-friendly
ENV CMAKE_ARGS="-DLLAMA_BLAS=OFF"

RUN pip install --upgrade pip \
    ; pip install -r requirements.txt


FROM python:3.10-slim AS runtime

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PORT=7860

WORKDIR /app

# Runtime deps (OpenMP)
RUN apt-get update \
    ; apt-get install -y --no-install-recommends libgomp1 ca-certificates \
    ; rm -rf /var/lib/apt/lists/*

# Copy installed python packages from builder
COPY --from=builder /usr/local /usr/local

# Copy app and model files
COPY app.py ./
COPY *.gguf ./

EXPOSE 7860

# HuggingFace expects the app to listen on 0.0.0.0:7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--proxy-headers", "--forwarded-allow-ips", "*"]