TransPlugin / Dockerfile
angre369's picture
fix: Pre-download Helsinki-NLP/opus-mt-en-zh model in Dockerfile
12879e9
raw
history blame
599 Bytes
# 使用官方Python镜像作为基础
FROM python:3.9-slim
# 设置工作目录
WORKDIR /app
# 复制依赖文件并安装
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY . .
# 预下载模型以避免运行时权限问题
RUN python -c "from transformers import AutoTokenizer, AutoModelForSeq2SeqLM; AutoTokenizer.from_pretrained('Helsinki-NLP/opus-mt-en-zh'); AutoModelForSeq2SeqLM.from_pretrained('Helsinki-NLP/opus-mt-en-zh')"
# 暴露端口
EXPOSE 7860
# 启动应用
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]