edusocial's picture
Update Dockerfile
c5a0c66 verified
Raw
History Blame Contribute Delete
927 Bytes
FROM python:3.10-slim
WORKDIR /app
# 安装系统依赖
RUN apt-get update && apt-get install -y git wget ffmpeg && rm -rf /var/lib/apt/lists/*
# 安装 PyTorch CPU 版本
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
# 安装依赖
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 安装 huggingface_hub 用来下载模型
RUN pip install --no-cache-dir huggingface_hub
# ✅ 下载 e5-small 模型而不是 BGE-M3
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download('intfloat/e5-small', local_dir='/app/model')"
# 环境变量:指定模型路径
ENV MODEL_PATH=/app/model
ENV DEVICE=cpu
ENV TRANSFORMERS_CACHE=/app/hf_cache
ENV HF_HOME=/app/hf_cache
RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
COPY app app
EXPOSE 8000
CMD uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860}