leonsimon23 commited on
Commit
bdfd3b6
·
verified ·
1 Parent(s): 5789888

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -9
Dockerfile CHANGED
@@ -9,19 +9,21 @@ RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /
9
  # 2. 升级pip
10
  RUN pip install --upgrade pip
11
 
12
- # 3. 使用secret挂载方式安全地克隆您的私有仓库
13
- # 您需要在Hugging Face Space的 "Settings" -> "Secrets" 中添加名为GITHUB_TOKEN的secret
14
- # 请将下面的URL替换为您自己的私有仓库URL
15
  RUN --mount=type=secret,id=GITHUB_TOKEN,required=true \
16
- git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@github.com/leoncool23/difybackend.git .
 
17
 
18
  # 4. 安装Python依赖
19
- # 假设requirements.txt在您仓库的根目录
20
  RUN pip install --no-cache-dir -r requirements.txt
21
 
22
- # 5. 暴露端口
 
 
 
 
 
23
  EXPOSE 7860
24
 
25
- # 6. 启动命令
26
- # Gunicorn会运行app.py文件中的app实例
27
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
 
9
  # 2. 升级pip
10
  RUN pip install --upgrade pip
11
 
12
+ # 3. 使用secret挂载方式安全地克隆私有仓库
 
 
13
  RUN --mount=type=secret,id=GITHUB_TOKEN,required=true \
14
+ git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@github.com/leoncool23/difybackend.git . \
15
+ && chmod -R 777 /app
16
 
17
  # 4. 安装Python依赖
 
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
+ # 5. 设置环境变量
21
+ ENV FLASK_APP=app.py
22
+ ENV FLASK_ENV=production
23
+ ENV PORT=7860
24
+
25
+ # 6. 暴露端口
26
  EXPOSE 7860
27
 
28
+ # 7. 启动命令
29
+ CMD ["gunicorn", "--workers", "4", "--bind", "0.0.0.0:7860", "app:app"]