selenium_keyan/selenium/Dockerfile

69 lines
1.6 KiB
Docker
Raw Permalink Normal View History

# --------------------------
# 基础镜像
# --------------------------
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /app
# --------------------------
# 1. 在线安装系统依赖
# --------------------------
RUN apt-get update && apt-get install -y \
xvfb \
gdebi-core \
python3 python3-pip \
curl wget unzip \
fonts-liberation \
libappindicator3-1 \
libasound2 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdbus-1-3 \
libgdk-pixbuf2.0-0 \
libnspr4 \
libnss3 \
libx11-xcb1 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
libgbm1 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
ca-certificates \
libvulkan1 \
xdg-utils \
&& rm -rf /var/lib/apt/lists/*
# --------------------------
# 2. 复制 Chrome 和 Chromedriver (离线)
# --------------------------
COPY chrome/google-chrome-stable_140.0.7339.185-1_amd64.deb /tmp/chrome/
COPY chrome/chromedriver /usr/local/bin/chromedriver
RUN chmod +x /usr/local/bin/chromedriver
# 安装 Chrome
RUN gdebi -n /tmp/chrome/google-chrome-stable_140.0.7339.185-1_amd64.deb \
&& rm -rf /tmp/chrome
# --------------------------
# 3. 在线安装 Python 依赖
# --------------------------
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
# --------------------------
# 4. 复制项目代码
# --------------------------
COPY . .
# --------------------------
# 5. Flask 端口 & 入口
# --------------------------
EXPOSE 5000
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD ["/entrypoint.sh"]