From 3d63eb4e96c08b2ea7c98c849134557f933a3aef Mon Sep 17 00:00:00 2001 From: fuzhongyun <15339891972@163.com> Date: Tue, 31 Mar 2026 09:04:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E9=95=9C=E5=83=8F=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 628ddf6..0f6f673 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,22 @@ -FROM mcr.microsoft.com/playwright/python:v1.58.0-jammy +FROM python:3.11-slim WORKDIR /app +# 设置环境变量,防止 Python 写 .pyc 文件,并强制无缓冲输出 +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 + COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt + +# 1. 安装 Python 依赖 +# 2. 仅安装 Chromium 浏览器 +# 3. 仅安装 Chromium 所需的系统级依赖 +# 4. 清理 apt 缓存,极致压缩镜像体积 +RUN pip install --no-cache-dir -r requirements.txt \ + && playwright install chromium \ + && playwright install-deps chromium \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /root/.cache/pip COPY main.py .