Cross-Encoder / Dockerfile
fiewolf1000's picture
Update Dockerfile
c72d473 verified
raw
history blame contribute delete
846 Bytes
# 基础镜像
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"]