Cross-Encoder / Dockerfile
fiewolf1000's picture
Update Dockerfile
b010be7 verified
raw
history blame
880 Bytes
# 基础镜像(Python 3.10 稳定版)
FROM python:3.10-slim
# 设置工作目录
WORKDIR /app
# 安装系统依赖(编译 PyTorch 所需)
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
# 创建可写的 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
# 安装 Python 依赖
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY . .
# 暴露端口(与 app.py 中一致)
EXPOSE 7860
# 启动服务
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]