From 45c7852856ec3c48afda012b3fc579840058e4b8 Mon Sep 17 00:00:00 2001 From: dong Date: Fri, 22 Nov 2024 22:05:23 +0800 Subject: [PATCH] Create Dockerfile --- Dockerfile | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1ee8c98 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM python:latest + +# Set the Chrome version +ENV CHROME_VERSION 131.0.6778.85 +ENV CHROMEDRIVER_VERSION ${CHROME_VERSION} + +# Install required tools and libraries +RUN apt-get -yqq update && \ + apt-get -yqq install --no-install-recommends \ + curl unzip gnupg wget libglib2.0-0 libx11-6 libnss3 \ + libgdk-pixbuf2.0-0 libx11-xcb1 libxcomposite1 libxrandr2 \ + libasound2 libatk-bridge2.0-0 libatk1.0-0 libcups2 libdrm2 \ + fonts-liberation libappindicator3-1 libnspr4 libnss3 libxss1 \ + libgbm1 && \ + rm -rf /var/lib/apt/lists/* + +# Install Chrome WebDriver +RUN mkdir -p /opt/chromedriver-${CHROMEDRIVER_VERSION} && \ + curl -sS -o /tmp/chromedriver_linux64.zip https://storage.googleapis.com/chrome-for-testing-public/${CHROMEDRIVER_VERSION}/linux64/chromedriver-linux64.zip && \ + unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-${CHROMEDRIVER_VERSION} && \ + rm /tmp/chromedriver_linux64.zip && \ + chmod +x /opt/chromedriver-${CHROMEDRIVER_VERSION}/chromedriver-linux64/chromedriver && \ + ln -fs /opt/chromedriver-${CHROMEDRIVER_VERSION}/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver + +# Install Google Chrome version 131.0.6778.85 +RUN curl -sS -o /tmp/chrome-linux64.zip https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chrome-linux64.zip && \ + unzip -qq /tmp/chrome-linux64.zip -d /opt/google-chrome-${CHROME_VERSION} && \ + rm /tmp/chrome-linux64.zip && \ + ln -fs /opt/google-chrome-${CHROME_VERSION}/chrome-linux64/chrome /usr/local/bin/google-chrome-stable + +# Set pip to use Tsinghua University mirror +RUN mkdir -p /etc/pip.conf && \ + echo "[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple" > /etc/pip.conf + +# Set working directory +WORKDIR /app +COPY app /app + +# Install Python dependencies +RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt && pip install --no-cache-dir selenium + +# Set container to idle on start (or modify to start your application) +CMD ["tail", "-f", "/dev/null"]