File size: 987 Bytes
d85712e
 
 
 
 
 
 
5681148
d85712e
5681148
 
d85712e
5681148
d85712e
 
 
 
5681148
 
 
 
d85712e
 
 
 
 
 
 
 
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
FROM python:3.11-slim-bookworm

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    HF_HOME=/data/hf \
    MODEL_DIR=/data/models \
    PORT=7860

# No build-essential/cmake: using pre-built llama-cpp-python CPU wheels.
# Only install a wheel; fail fast rather than compiling on a 2-vCPU Space.
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgomp1 ca-certificates \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY requirements.txt ./
RUN python -m pip install --upgrade pip \
    && python -m pip install --only-binary=llama-cpp-python \
        --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu \
        -r requirements.txt

COPY app.py index.html ./
RUN useradd -m -u 1000 user \
    && mkdir -p /data/models /data/hf \
    && chown -R user:user /data /app
USER user
EXPOSE 7860
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--no-access-log"]