fix: 使用Playwright官方Docker镜像,避免国内下载Chromium失败
This commit is contained in:
20
Dockerfile
20
Dockerfile
@@ -1,29 +1,13 @@
|
|||||||
FROM python:3.11-slim
|
FROM mcr.microsoft.com/playwright/python:v1.52.0-noble
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# 国内镜像加速
|
|
||||||
RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
|
|
||||||
sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list 2>/dev/null || true
|
|
||||||
|
|
||||||
# 安装 Playwright 系统依赖
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
|
|
||||||
libxkbcommon0 libxcomposite1 libxdamage1 libxrandr2 libgbm1 \
|
|
||||||
libpango-1.0-0 libcairo2 libasound2 libxshmfence1 libx11-xcb1 \
|
|
||||||
fonts-noto-cjk && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
|
|
||||||
# pip 阿里云镜像 + Playwright 国内 CDN 镜像
|
|
||||||
ENV PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright
|
|
||||||
RUN pip install --no-cache-dir \
|
RUN pip install --no-cache-dir \
|
||||||
-i https://mirrors.aliyun.com/pypi/simple/ \
|
-i https://mirrors.aliyun.com/pypi/simple/ \
|
||||||
--trusted-host mirrors.aliyun.com \
|
--trusted-host mirrors.aliyun.com \
|
||||||
-r requirements.txt && \
|
-r requirements.txt
|
||||||
playwright install chromium
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
flask>=3.0
|
flask>=3.0
|
||||||
playwright>=1.40
|
playwright==1.52.0
|
||||||
playwright-stealth>=1.0
|
playwright-stealth>=1.0
|
||||||
pyyaml>=6.0
|
pyyaml>=6.0
|
||||||
ntplib>=0.4
|
ntplib>=0.4
|
||||||
|
|||||||
Reference in New Issue
Block a user