File size: 554 Bytes
d585c70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 使用一个轻量级的 Python 官方镜像
FROM python:3.10-slim

# 设置工作目录
WORKDIR /code

# 复制并安装最简化的依赖
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# 复制应用代码
COPY ./app.py /code/app.py

# 暴露 Hugging Face Spaces 期望的端口
EXPOSE 7860

# 启动 Uvicorn 服务器,并添加 --proxy-headers 标志来修复文档路径问题
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--proxy-headers"]