Cross-Encoder / Dockerfile
fiewolf1000's picture
Update Dockerfile
b255bd0 verified
raw
history blame
811 Bytes
# 1. 基础镜像
FROM python:3.10-slim
# 2. 设置工作目录
WORKDIR /app
# 3. 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# 4. 【新增】创建可写的 Hugging Face 缓存目录,并设置环境变量
RUN mkdir -p /tmp/huggingface_cache && chmod 777 /tmp/huggingface_cache
ENV TRANSFORMERS_CACHE=/tmp/huggingface_cache \
HUGGINGFACE_HUB_CACHE=/tmp/huggingface_cache
# 5. 安装 Python 依赖(使用修改后的 requirements.txt)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 6. 复制应用代码
COPY . .
# 7. 暴露端口(与 app.py 一致)
EXPOSE 7860
# 8. 启动服务
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]