From 6fc4438a13e4912f4ab89c4a1c407eaf8416210d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=9D=B0=20Jie=20Zhao=20=EF=BC=88=E9=9B=84?= =?UTF-8?q?=E7=8B=AE=E6=B1=BD=E8=BD=A6=E7=A7=91=E6=8A=80=EF=BC=89?= <00061074@chery.local> Date: Mon, 3 Nov 2025 13:19:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 54a794b..ce77396 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,8 +25,10 @@ RUN apt-get update && apt-get install -y \ COPY requirements.txt . # 安装Python依赖(排除GUI相关依赖,Docker中不需要) -RUN pip install --no-cache-dir -r requirements.txt && \ - pip install --no-cache-dir gunicorn +RUN pip install --no-cache-dir --upgrade pip && \ + pip install --no-cache-dir -r requirements.txt && \ + pip install --no-cache-dir gunicorn && \ + which gunicorn || echo "Gunicorn installed via python -m" # 复制应用代码 COPY . . @@ -47,4 +49,5 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ # 使用gunicorn启动应用(生产环境) # 注意:默认配置使用2个worker,适合1GB+内存的机器 # 如果机器内存较小(512MB-1GB),建议修改为 "--workers", "1" -CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "2", "--timeout", "120", "--access-logfile", "-", "--error-logfile", "-", "web_app:app"] +# 使用 python -m gunicorn 确保可以找到 gunicorn +CMD ["python", "-m", "gunicorn", "--bind", "0.0.0.0:5000", "--workers", "2", "--timeout", "120", "--access-logfile", "-", "--error-logfile", "-", "web_app:app"]