File size: 643 Bytes
daeedba | 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 | # 使用官方轻量级 Python 镜像
FROM python:3.10-slim
# 设置工作目录
WORKDIR /code
# 安装系统依赖(如果 Pillow 处理某些特殊格式需要)
RUN apt-get update && apt-get install -y \
libmagic1 \
&& rm -rf /var/lib/apt/lists/*
# 先复制依赖文件并安装,利用 Docker 缓存
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 复制项目代码
COPY . .
# 设置权限(Hugging Face 要求)
RUN chmod -R 777 /code
# 暴露端口(Hugging Face 强制要求端口为 7860)
EXPOSE 7860
# 启动命令
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |