Created
March 19, 2024 13:46
-
-
Save sleepless-se/37dfbdca4bf8c65e7f322f0c9e804d2f to your computer and use it in GitHub Desktop.
Selenium Python Docker Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.12 | |
# Install Chrome and Selenium dependencies | |
RUN apt-get update && apt-get install -y \ | |
wget \ | |
unzip \ | |
libglib2.0-0 \ | |
libnss3 \ | |
libgconf-2-4 \ | |
libfontconfig1 \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install Chrome | |
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - | |
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list | |
RUN apt-get update && apt-get install -y google-chrome-stable | |
# Install ChromeDriver | |
RUN wget -O chrome.json https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json && \ | |
LINUX_STABLE_URL=$(grep -oP '"url":".*?(?=")' chrome.json | grep 'linux64' | head -n 1 | cut -d'"' -f4) && \ | |
wget -O chrome.zip $LINUX_STABLE_URL && \ | |
unzip chrome.zip && \ | |
rm chrome.zip chrome.json | |
RUN pip install selenium | |
COPY main.py /main.py | |
CMD ["python", "/main.py"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment