File size: 849 Bytes
6bbce7e facda5a 6bbce7e 95df245 6ae7c13 6bbce7e 387c4fa 19c7563 387c4fa 19c7563 | 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 | FROM python:3.11-slim
WORKDIR /app
# 安装构建依赖
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
wget \
&& rm -rf /var/lib/apt/lists/*
# 安装 llama-cpp-python(带 server)和 huggingface_hub
RUN pip install --no-cache-dir \
--extra-index-url https://huggingface.co/James040/llama-cpp-python-wheels/simple/ \
llama-cpp-python[server]==0.3.9 \
huggingface_hub \
transformers \
sentencepiece
# 下载模型(build 阶段缓存,避免每次冷启动重新拉)
RUN python -c "\
from huggingface_hub import hf_hub_download; \
hf_hub_download(\
repo_id='bartowski/Qwen2.5-3B-Instruct-GGUF', \
filename='Qwen2.5-3B-Instruct-Q4_K_M.gguf', \
local_dir='/app/models'\
)"
# 复制 FastAPI 应用
COPY main.py /app/main.py
EXPOSE 7860
CMD ["python", "/app/main.py"] |