-
Notifications
You must be signed in to change notification settings - Fork 191
/
Dockerfile
90 lines (77 loc) · 3.9 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Pull ubuntu 22.04 base image
FROM ubuntu:22.04
LABEL maintainer="Qxf2 Services"
ENV DISPLAY=:20
# Essential tools and xvfb
RUN apt-get update && apt-get install -y \
software-properties-common \
unzip \
wget \
bzip2 \
xvfb \
x11vnc \
fluxbox \
xterm
# Install Google Chrome and dependencies
RUN wget -qO /tmp/google.pub https://dl-ssl.google.com/linux/linux_signing_key.pub \
&& apt-key add /tmp/google.pub \
&& rm /tmp/google.pub \
&& echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' > /etc/apt/sources.list.d/google.list \
&& mkdir -p /usr/share/desktop-directories \
&& apt-get -y update \
&& apt-get install -y google-chrome-stable \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Disable the SUID sandbox so that Chrome can launch without being in a privileged container
RUN dpkg-divert --add --rename --divert /opt/google/chrome/google-chrome.real /opt/google/chrome/google-chrome \
&& printf "#!/bin/bash\nexec /opt/google/chrome/google-chrome.real --no-sandbox --disable-setuid-sandbox \"\$@\"" > /opt/google/chrome/google-chrome \
&& chmod 755 /opt/google/chrome/google-chrome
# Install Chrome Driver (latest version)
RUN CHROME_VER=$(google-chrome --version | grep -oP "Google Chrome \K[\d.]+") \
&& echo "Chrome version: $CHROME_VER" \
&& wget --no-verbose -O /tmp/chromedriver-linux64.zip "https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VER}/linux64/chromedriver-linux64.zip" \
&& rm -rf /opt/selenium/chromedriver \
&& mkdir -p /opt/selenium \
&& unzip /tmp/chromedriver-linux64.zip -d /opt/selenium \
&& rm /tmp/chromedriver-linux64.zip \
&& mv /opt/selenium/chromedriver-linux64/chromedriver /usr/bin/chromedriver \
&& chmod 755 /usr/bin/chromedriver
ARG FIREFOX_VERSION=latest
RUN FIREFOX_DOWNLOAD_URL="$(if [ "$FIREFOX_VERSION" = "latest" ]; then echo "https://download.mozilla.org/?product=firefox-"$FIREFOX_VERSION"-ssl&os=linux64&lang=en-US"; else echo "https://download-installer.cdn.mozilla.net/pub/firefox/releases/"$FIREFOX_VERSION"/linux-x86_64/en-US/firefox-"$FIREFOX_VERSION".tar.bz2"; fi)" \
&& echo "Firefox download URL: $FIREFOX_DOWNLOAD_URL" \
&& apt-get -qqy update \
&& apt-get -qqy --no-install-recommends install firefox \
&& apt-get -y install libdbus-glib-1-2 \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
&& wget --no-verbose -O /tmp/firefox.tar.bz2 "$FIREFOX_DOWNLOAD_URL" \
&& apt-get -y purge firefox \
&& rm -rf /opt/firefox \
&& tar -C /opt -xjf /tmp/firefox.tar.bz2 \
&& rm /tmp/firefox.tar.bz2 \
&& mv /opt/firefox /opt/firefox-"$FIREFOX_VERSION" \
&& ln -fs /opt/firefox-"$FIREFOX_VERSION"/firefox /usr/bin/firefox \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Download and install the latest Geckodriver binary
RUN GECKODRIVER_VERSION=$(wget -qO- 'https://api.github.com/repos/mozilla/geckodriver/releases/latest' | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') \
&& 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" \
&& tar -xzf /tmp/geckodriver.tar.gz -C /tmp \
&& mv /tmp/geckodriver /usr/bin/geckodriver \
&& rm /tmp/geckodriver.tar.gz
# Python 3.10 and Python Pip
RUN apt-get update && apt-get install -y \
python3.10 \
python3-setuptools=59.6.0-1.2ubuntu0.22.04.1 \
python3-pip=22.0.2+dfsg-1ubuntu0.4 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Creating a new directory
RUN mkdir /shell_script
# Copying shell script to directory
COPY entrypoint.sh /shell_script
# Setting the working directory
WORKDIR /shell_script
# Setting the entry point
ENTRYPOINT ["/bin/bash", "/shell_script/entrypoint.sh"]
# Setting the default command to be run in the container
CMD ["sh", "-c", "Xvfb :20 -screen 0 1366x768x16 & x11vnc -passwd password -display :20 -N -forever"]