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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -12
Dockerfile CHANGED
@@ -1,25 +1,29 @@
1
- # 1. 使用一个官方的、轻量级的Python 3.10镜像作为基础
2
  FROM python:3.10-slim
3
 
4
- # 2. 在容器内设置一个工作目录
 
 
 
 
 
5
  WORKDIR /app
6
 
7
- # 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"]
 
1
+ # 使用官方的、轻量级的Python 3.10镜像作为基础
2
  FROM python:3.10-slim
3
 
4
+ # 安装必要的系统工具
5
+ RUN apt-get update && apt-get install -y \
6
+ curl \
7
+ && rm -rf /var/lib/apt/lists/*
8
+
9
+ # 在容器内设置一个工作目录
10
  WORKDIR /app
11
 
12
+ # 复制依赖文件到工作目录
13
  COPY requirements.txt requirements.txt
14
 
15
+ # 安装所有依赖项
16
  RUN pip install --no-cache-dir -r requirements.txt --default-timeout=100
17
 
18
+ # 将项目中的所有文件复制到工作目录
19
  COPY . .
20
 
21
+ # 设置健康检查
22
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 \
23
+ CMD curl -f http://localhost:8080/healthz || exit 1
 
24
 
25
+ # 向Docker声明容器将在哪个端口上监听连接
26
  EXPOSE 8080
27
 
28
+ # 定义容器启动时要执行的命令
29
+ CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--workers", "1", "--timeout", "120", "--log-level", "info", "app:app"]