File size: 961 Bytes
b7e4633
 
 
 
 
 
 
 
 
 
6cd46ec
 
b7e4633
 
6cd46ec
b7e4633
 
6cd46ec
b7e4633
 
6cd46ec
b7e4633
 
 
 
 
 
b94ef5c
 
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
27
28
29
# 使用官方Python 3.9 slim镜像
FROM python:3.9-slim

# 设置工作目录
WORKDIR /app

# --- 准备工作:安装git ---
RUN apt-get update && apt-get install -y --no-install-recommends git

# --- 关键步骤:使用PAT克隆私有仓库 ---
# 从Hugging Face Secrets中获取GitHub用户名和PAT
# 注意:URL路径中的 'leoncool23' 是硬编码的,必须是您的真实用户名
RUN --mount=type=secret,id=GH_USERNAME \
    --mount=type=secret,id=GH_TOKEN \
    git clone https://$(cat /run/secrets/GH_USERNAME):$(cat /run/secrets/GH_TOKEN)@github.com/leoncool23/ducg_web_app.git .

# --- 设置Python环境 ---
# 安装Python依赖
RUN pip install --no-cache-dir -r requirements.txt

# 安装Gunicorn用于生产环境
RUN pip install gunicorn

# --- 运行应用 ---
# 暴露端口 (Hugging Face Spaces通常使用7860)
EXPOSE 7860

# 启动应用的命令 (已修正IP地址中的空格)
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]