leonsimon23 commited on
Commit
4f97b34
·
verified ·
1 Parent(s): e9f54cb

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +2 -7
Dockerfile CHANGED
@@ -1,5 +1,3 @@
1
- # Dockerfile
2
-
3
  # 1. 使用一个官方的、轻量级的Python 3.10镜像作为基础
4
  FROM python:3.10-slim
5
 
@@ -10,21 +8,18 @@ WORKDIR /app
10
  COPY requirements.txt requirements.txt
11
 
12
  # 4. 安装所有依赖项
13
- # --no-cache-dir 选项可以减小最终镜像的大小
14
- # --default-timeout=100 增加超时时间,防止网络慢导致安装失败
15
  RUN pip install --no-cache-dir -r requirements.txt --default-timeout=100
16
 
17
  # 5. 将项目中的所有文件复制到工作目录
18
  COPY . .
19
 
20
  # 6. 设置健康检查,告诉Hugging Face如何确认应用是否正常运行
21
- # 它会尝试访问应用的根路径,如果30秒内没有响应,则认为失败
22
  HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
23
- CMD curl -f http://localhost:8080/ || exit 1
24
 
25
  # 7. 向Docker声明容器将在哪个端口上监听连接
26
  EXPOSE 8080
27
 
28
  # 8. 定义容器启动时要执行的命令
29
- # 使用gunicorn作为生产级WSGI服务器,增加 --timeout 避免请求处理时间过长被中断
30
  CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--workers", "1", "--timeout", "120", "app:app"]
 
 
 
1
  # 1. 使用一个官方的、轻量级的Python 3.10镜像作为基础
2
  FROM python:3.10-slim
3
 
 
8
  COPY requirements.txt requirements.txt
9
 
10
  # 4. 安装所有依赖项
 
 
11
  RUN pip install --no-cache-dir -r requirements.txt --default-timeout=100
12
 
13
  # 5. 将项目中的所有文件复制到工作目录
14
  COPY . .
15
 
16
  # 6. 设置健康检查,告诉Hugging Face如何确认应用是否正常运行
17
+ # 修改:将检查的URL从 / 改为 /healthz
18
  HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
19
+ CMD curl -f http://localhost:8080/healthz || exit 1
20
 
21
  # 7. 向Docker声明容器将在哪个端口上监听连接
22
  EXPOSE 8080
23
 
24
  # 8. 定义容器启动时要执行的命令
 
25
  CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--workers", "1", "--timeout", "120", "app:app"]