lh4b / Dockerfile
nagose's picture
Update Dockerfile
23812b7 verified
raw
history blame contribute delete
845 Bytes
FROM python:3.10-slim
WORKDIR /app
# 安装编译工具、OpenBLAS 和 pkg-config
RUN apt-get update && apt-get install -y \
git \
build-essential \
cmake \
libopenblas-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# 复制依赖文件
COPY requirements.txt .
# 升级 pip
RUN pip install --no-cache-dir --upgrade pip
# 设置编译参数启用 OpenBLAS 加速
ENV CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS"
# 从源码编译 llama-cpp-python(确保与系统 glibc 兼容)
RUN pip install --no-cache-dir llama-cpp-python --force-reinstall --no-binary=llama-cpp-python
# 安装其他 Python 依赖
RUN pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY app.py .
# 暴露端口
EXPOSE 7860
# 启动服务
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]