Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +16 -12
Dockerfile
CHANGED
|
@@ -1,25 +1,29 @@
|
|
| 1 |
-
#
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
| 8 |
COPY requirements.txt requirements.txt
|
| 9 |
|
| 10 |
-
#
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt --default-timeout=100
|
| 12 |
|
| 13 |
-
#
|
| 14 |
COPY . .
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
CMD curl -f http://localhost:8080/healthz || exit 1
|
| 20 |
|
| 21 |
-
#
|
| 22 |
EXPOSE 8080
|
| 23 |
|
| 24 |
-
#
|
| 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"]
|