From 29674ba68b8df8931af6d3066e47a7b7da59b6bf Mon Sep 17 00:00:00 2001 From: renzhiyuan <465386466@qq.com> Date: Tue, 5 Aug 2025 10:51:02 +0800 Subject: [PATCH] 1 --- Dockerfile | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0376b02..0ed3cac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,15 @@ -# 使用官方 Python 基础镜像 FROM python:3.11-slim -# 设置工作目录 WORKDIR /app -# 安装系统依赖(如果需要) -#RUN apt-get update && apt-get install -y \ -# build-essential \ -# && rm -rf /var/lib/apt/lists/* +# 复制 requirements.txt 并优先安装依赖(利用 Docker 层缓存) +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ -# 复制项目文件 -COPY . /app +# 复制整个项目 +COPY . . -# 安装 Python 依赖 -RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple - -# 暴露端口 EXPOSE 5000 -# 启动命令(使用 Gunicorn 替代 Flask 开发服务器) -CMD ["waitress-serve", "--host=0.0.0.0", "--port=5000", "app:app"] +# 确保模块名和 Flask 实例名正确(默认是 app:app) +CMD ["waitress-serve", "--host=0.0.0.0", "--port=5000", "app:app"] \ No newline at end of file