File size: 920 Bytes
0c7dc6f
a21d59d
f64c14c
b723355
 
 
f64c14c
b723355
 
a21d59d
 
 
 
 
f64c14c
 
 
 
a21d59d
b723355
f64c14c
37e8f73
 
 
 
 
 
f64c14c
 
37e8f73
 
f64c14c
a21d59d
 
b723355
 
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
FROM python:3.11-slim-bullseye

# 1. 安装基础工具
USER root
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    && rm -rf /var/lib/apt/lists/*

RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app

# 2. 升级 pip
RUN pip install --no-cache-dir --upgrade pip

# 3. 分两步安装,确保 llama-cpp-python 命中预编译库
COPY --chown=user ./requirements.txt requirements.txt

# 先安装除了 llama 以外的依赖(减少编译冲突风险)
RUN pip install --no-cache-dir \
    torch \
    transformers \
    gradio \
    accelerate \
    --extra-index-url https://download.pytorch.org/whl/cpu

# 关键:从 abetlen 的 CPU 专用源安装 llama-cpp-python
RUN pip install --no-cache-dir \
    llama-cpp-python \
    --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu

COPY --chown=user . /app

CMD ["python", "app.py"]