64 lines
1.3 KiB
Plaintext
64 lines
1.3 KiB
Plaintext
# 指定目标平台
|
|
# syntax=docker/dockerfile:1
|
|
FROM python:3.12-slim
|
|
|
|
# 设置工作目录
|
|
WORKDIR /app
|
|
|
|
# 安装系统依赖
|
|
RUN apt-get update && apt-get install -y \
|
|
wget \
|
|
gnupg \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 安装Playwright的依赖
|
|
RUN apt-get update && apt-get install -y \
|
|
libnss3 \
|
|
libnspr4 \
|
|
libatk1.0-0 \
|
|
libatk-bridge2.0-0 \
|
|
libcups2 \
|
|
libdrm2 \
|
|
libdbus-1-3 \
|
|
libxkbcommon0 \
|
|
libxcomposite1 \
|
|
libxdamage1 \
|
|
libxfixes3 \
|
|
libxrandr2 \
|
|
libgbm1 \
|
|
libasound2 \
|
|
libpango-1.0-0 \
|
|
libpangocairo-1.0-0 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 配置pip源
|
|
RUN mkdir -p /root/.pip && \
|
|
echo "[global]" > /root/.pip/pip.conf && \
|
|
echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> /root/.pip/pip.conf && \
|
|
echo "trusted-host = pypi.tuna.tsinghua.edu.cn" >> /root/.pip/pip.conf
|
|
|
|
# 更新pip
|
|
RUN python -m pip install --upgrade pip
|
|
|
|
COPY requirements.txt .
|
|
|
|
# 安装Python依赖
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# 预先安装 Playwright 的系统依赖
|
|
RUN apt-get update && apt-get install -y \
|
|
xvfb \
|
|
libopengl0 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 安装Playwright浏览器
|
|
RUN playwright install chromium
|
|
RUN playwright install-deps
|
|
|
|
# 暴露端口
|
|
EXPOSE 8000
|
|
|
|
|
|
|
|
# 启动命令
|
|
CMD ["bash"] |