Spaces:
Sleeping
Sleeping
File size: 846 Bytes
ae7a9bf 849bc37 ae7a9bf 849bc37 ae7a9bf b010be7 ae7a9bf b255bd0 ae7a9bf b255bd0 ae7a9bf 849bc37 ae7a9bf 849bc37 c72d473 |
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 37 38 39 40 41 |
# 基础镜像
FROM python:3.10-slim
WORKDIR /app
# 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# 升级 pip
RUN pip install --no-cache-dir --upgrade pip
# 【关键修改】创建缓存目录并设置 777 权限(所有用户可读写)
RUN mkdir -p /tmp/huggingface_cache && chmod -R 777 /tmp/huggingface_cache
ENV TRANSFORMERS_CACHE=/tmp/huggingface_cache \
HUGGINGFACE_HUB_CACHE=/tmp/huggingface_cache \
# 额外添加缓存路径变量,确保所有库都使用该目录
HF_HOME=/tmp/huggingface_cache
# 安装依赖
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 复制代码
COPY . .
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|