1234567891011121314151617181920212223242526272829303132333435363738 |
- FROM mcr.microsoft.com/playwright:v1.37.0-jammy
- # mcr.microsoft.com/playwright/python:v1.52.0
- # 设置非交互式环境变量和时区
- ENV DEBIAN_FRONTEND=noninteractive
- ENV TZ=Etc/UTC
- WORKDIR /app
- # 安装 Python 3.9 和 pip(修复时区阻塞问题)
- RUN sed -i 's|http://.*archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list && \
- sed -i 's|http://.*security.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list && \
- apt-get update && \
- apt-get install -y software-properties-common tzdata python3 python3-pip ttf-wqy-microhei && \
- ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
- dpkg-reconfigure --frontend noninteractive tzdata && \
- add-apt-repository -y ppa:deadsnakes/ppa && \
- pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
- pip3 config set global.trusted-host pypi.tuna.tsinghua.edu.cn
- # 安装 Playwright Python 库和浏览器驱动
- RUN python3 -m pip install playwright && \
- python3 -m playwright install
- RUN pip install aiohttp toml pydantic fastapi sqlalchemy python-multipart uvicorn
- # 安装 Xvfb 和窗口管理器(支持有头模式)
- RUN apt-get install -y xvfb fluxbox && \
- rm -rf /var/lib/apt/lists/*
- # 设置环境变量
- ENV DISPLAY=:99
- COPY ./app /app
- # 启动脚本
- COPY entrypoint.sh /entrypoint.sh
- RUN chmod +x /entrypoint.sh
- ENTRYPOINT ["/entrypoint.sh"]
|