Skip to content

Commit 2b4a01d

Browse files
zsaladinryanking13
andauthored
Use selenium manager in dockerfile (pyodide#5787)
Co-authored-by: Gyeongjae Choi <[email protected]>
1 parent 77ff54d commit 2b4a01d

File tree

1 file changed

+57
-81
lines changed

1 file changed

+57
-81
lines changed

Dockerfile

Lines changed: 57 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,63 @@
1+
FROM ubuntu:25.04 AS selenium-manager-image
2+
RUN apt-get update \
3+
&& apt-get install -y --no-install-recommends \
4+
ca-certificates curl jq wget \
5+
&& rm -rf /var/lib/apt/lists/*
6+
7+
ARG SELENIUM_MANAGER_VERSION=latest
8+
RUN SELENIUM_MANAGER_VERSION_FULL=$(curl -s https://api.github.com/repos/SeleniumHQ/selenium_manager_artifacts/releases/${SELENIUM_MANAGER_VERSION} | jq -r .name) \
9+
&& wget --no-verbose https://github.com/SeleniumHQ/selenium_manager_artifacts/releases/download/${SELENIUM_MANAGER_VERSION_FULL}/selenium-manager-linux \
10+
&& chmod +x selenium-manager-linux \
11+
&& mv selenium-manager-linux /usr/local/bin/selenium-manager
12+
13+
ARG CHROME_VERSION="latest"
14+
ARG FIREFOX_VERSION="latest"
15+
16+
RUN if [ $FIREFOX_VERSION = "latest" ]; then SE_FIREFOX_VERSION="stable"; \
17+
else SE_FIREFOX_VERSION=${FIREFOX_VERSION}; \
18+
fi \
19+
&& export SE_FIREFOX_VERSION \
20+
&& SE_FIREFOX_OUTPUT=$(selenium-manager --browser firefox --driver gecko --output json) \
21+
&& SE_FIREFOX_BROWSER_PATH=$(echo ${SE_FIREFOX_OUTPUT} | jq -r '.result.browser_path') \
22+
&& SE_GECKO_DRIVER_PATH=$(echo ${SE_FIREFOX_OUTPUT} | jq -r '.result.driver_path') \
23+
&& mv $(dirname ${SE_FIREFOX_BROWSER_PATH}) /opt/firefox \
24+
&& mv $(dirname ${SE_GECKO_DRIVER_PATH}) /opt/geckodriver
25+
26+
RUN if [ $CHROME_VERSION = "latest" ]; then SE_CHROME_VERSION="stable"; \
27+
else SE_CHROME_VERSION=${CHROME_VERSION}; \
28+
fi \
29+
&& export SE_CHROME_VERSION \
30+
&& SE_CHROME_OUTPUT=$(selenium-manager --browser chrome --driver chrome --output json) \
31+
&& SE_CHROME_BROWSER_PATH=$(echo ${SE_CHROME_OUTPUT} | jq -r '.result.browser_path') \
32+
&& SE_CHROME_DRIVER_PATH=$(echo ${SE_CHROME_OUTPUT} | jq -r '.result.driver_path') \
33+
&& mv $(dirname ${SE_CHROME_BROWSER_PATH}) /opt/chrome \
34+
&& mv $(dirname ${SE_CHROME_DRIVER_PATH}) /opt/chromedriver
35+
36+
137
FROM node:20.11-bookworm-slim AS node-image
238
FROM python:3.13.2-slim-bookworm
339

4-
# Requirements for building packages
540
RUN apt-get update \
641
&& apt-get install -y --no-install-recommends \
42+
# Requirements for building packages \
743
bzip2 ccache f2c g++ gfortran git make \
844
patch pkg-config swig unzip wget xz-utils \
945
autoconf autotools-dev automake texinfo dejagnu \
1046
build-essential libltdl-dev \
1147
gnupg2 libdbus-glib-1-2 sudo sqlite3 \
1248
ninja-build jq cmake bison \
49+
# Dependencies of Chrome and Firefox \
50+
ca-certificates fonts-liberation libasound2 \
51+
libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 \
52+
libc6 libcairo2 libcups2 libcurl4 libdbus-1-3 \
53+
libexpat1 libgbm1 libglib2.0-0 libnspr4 libnss3 \
54+
libpango-1.0-0 libudev1 libvulkan1 libx11-6 \
55+
libxcb1 libxcomposite1 libxdamage1 libxext6 \
56+
libxfixes3 libxkbcommon0 libxrandr2 xdg-utils \
57+
libgtk-3-0 libx11-xcb1 \
58+
libtool autoconf \
1359
&& rm -rf /var/lib/apt/lists/*
1460

15-
# install autoconf 2.72, required by upstream libffi
16-
RUN wget https://mirrors.ocf.berkeley.edu/gnu/autoconf/autoconf-2.72.tar.xz \
17-
&& tar -xf autoconf-2.72.tar.xz \
18-
&& cd autoconf-2.72 \
19-
&& ./configure \
20-
&& make install \
21-
&& cp /usr/local/bin/autoconf /usr/bin/autoconf \
22-
&& cd .. \
23-
&& rm -rf autoconf-2.72*
24-
25-
# install libtool 2.5.4, required by ngspice for emscripten support
26-
RUN wget https://mirrors.ocf.berkeley.edu/gnu/libtool/libtool-2.5.4.tar.xz \
27-
&& tar -xf libtool-2.5.4.tar.xz \
28-
&& cd libtool-2.5.4 \
29-
&& ./configure \
30-
&& make install \
31-
&& cd .. \
32-
&& rm -rf libtool-2.5.4*
33-
3461
ADD requirements.txt /
3562

3663
WORKDIR /
@@ -66,69 +93,18 @@ RUN wget -q -O - https://sh.rustup.rs | \
6693
RUSTUP_HOME=/usr CARGO_HOME=/usr \
6794
sh -s -- -y --profile minimal --no-modify-path
6895

69-
# Get Chrome and Firefox (borrowed from https://github.com/SeleniumHQ/docker-selenium)
96+
COPY --from=selenium-manager-image /opt/firefox /opt/firefox
97+
COPY --from=selenium-manager-image /opt/geckodriver /opt/geckodriver
98+
COPY --from=selenium-manager-image /opt/chrome /opt/chrome
99+
COPY --from=selenium-manager-image /opt/chromedriver /opt/chromedriver
70100

71-
ARG CHROME_VERSION="latest"
72-
ARG FIREFOX_VERSION="latest"
73-
# Note: geckodriver version needs to be updated manually
74-
ARG GECKODRIVER_VERSION="0.34.0"
75-
76-
#============================================
77-
# Firefox & geckodriver
78-
#============================================
79-
# can specify Firefox version by FIREFOX_VERSION;
80-
# e.g. latest
81-
# 95
82-
# 96
83-
#
84-
# can specify Firefox geckodriver version by GECKODRIVER_VERSION;
85-
#============================================
86-
87-
RUN if [ $FIREFOX_VERSION = "latest" ] || [ $FIREFOX_VERSION = "nightly-latest" ] || [ $FIREFOX_VERSION = "devedition-latest" ] || [ $FIREFOX_VERSION = "esr-latest" ]; \
88-
then FIREFOX_DOWNLOAD_URL="https://download.mozilla.org/?product=firefox-$FIREFOX_VERSION-ssl&os=linux64&lang=en-US"; \
89-
else FIREFOX_VERSION_FULL="${FIREFOX_VERSION}.0" && FIREFOX_DOWNLOAD_URL="https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FIREFOX_VERSION_FULL/linux-x86_64/en-US/firefox-$FIREFOX_VERSION_FULL.tar.bz2"; \
90-
fi \
91-
&& wget --no-verbose -O /tmp/firefox.tar.xz "$FIREFOX_DOWNLOAD_URL" \
92-
&& tar -C /opt -xf /tmp/firefox.tar.xz \
93-
&& rm /tmp/firefox.tar.xz \
94-
&& mv /opt/firefox /opt/firefox-$FIREFOX_VERSION \
95-
&& ln -fs /opt/firefox-$FIREFOX_VERSION/firefox /usr/local/bin/firefox \
96-
&& wget --no-verbose -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v$GECKODRIVER_VERSION/geckodriver-v$GECKODRIVER_VERSION-linux64.tar.gz \
97-
&& rm -rf /opt/geckodriver \
98-
&& tar -C /opt -zxf /tmp/geckodriver.tar.gz \
99-
&& rm /tmp/geckodriver.tar.gz \
100-
&& mv /opt/geckodriver /opt/geckodriver-$GECKODRIVER_VERSION \
101-
&& chmod 755 /opt/geckodriver-$GECKODRIVER_VERSION \
102-
&& ln -fs /opt/geckodriver-$GECKODRIVER_VERSION /usr/local/bin/geckodriver \
101+
RUN ln -fs /opt/firefox/firefox /usr/local/bin/firefox \
102+
&& ln -fs /opt/geckodriver/geckodriver /usr/local/bin/geckodriver \
103+
&& ln -fs /opt/chrome/chrome /usr/local/bin/chrome \
104+
&& ln -fs /opt/chromedriver/chromedriver /usr/local/bin/chromedriver \
103105
&& echo "Using Firefox version: $(firefox --version)" \
104-
&& echo "Using GeckoDriver version: "$GECKODRIVER_VERSION
105-
106-
107-
#============================================
108-
# Google Chrome & Chrome webdriver
109-
#============================================
110-
# can specify Chrome version by CHROME_VERSION;
111-
# e.g. latest
112-
# 96
113-
# 97
114-
#============================================
115-
116-
RUN if [ $CHROME_VERSION = "latest" ]; \
117-
then CHROME_VERSION_FULL=$(wget --no-verbose -O - "https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_STABLE"); \
118-
else CHROME_VERSION_FULL=$(wget --no-verbose -O - "https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_${CHROME_VERSION}"); \
119-
fi \
120-
&& CHROME_DOWNLOAD_URL="https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb" \
121-
&& CHROMEDRIVER_DOWNLOAD_URL="https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION_FULL}/linux64/chromedriver-linux64.zip" \
122-
&& wget --no-verbose -O /tmp/google-chrome.deb ${CHROME_DOWNLOAD_URL} \
123-
&& apt-get update \
124-
&& apt install -qqy /tmp/google-chrome.deb \
125-
&& rm -f /tmp/google-chrome.deb \
126-
&& rm -rf /var/lib/apt/lists/* \
127-
&& wget --no-verbose -O /tmp/chromedriver-linux64.zip ${CHROMEDRIVER_DOWNLOAD_URL} \
128-
&& unzip /tmp/chromedriver-linux64.zip -d /opt/ \
129-
&& rm /tmp/chromedriver-linux64.zip \
130-
&& ln -fs /opt/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver \
131-
&& echo "Using Chrome version: $(google-chrome --version)" \
106+
&& echo "Using GeckoDriver version: $(geckodriver --version)" \
107+
&& echo "Using Chrome version: $(chrome --version)" \
132108
&& echo "Using Chrome Driver version: $(chromedriver --version)"
133109

134110
CMD ["/bin/sh"]

0 commit comments

Comments
 (0)