1 | FROM ubuntu:latest@sha256:4e4bc990609ed865e07afc8427c30ffdddca5153fd4e82c20d8f0783a291e241
|
2 |
|
3 |
|
4 | # Contributors
|
5 | LABEL author="Vincent Voyer <vincent@zeroload.net>"
|
6 | LABEL maintainers="Serban Ghita <serbanghita@gmail.com>, David Catalan <catalan.david@gmail.com>"
|
7 |
|
8 |
|
9 | # Env variables
|
10 | ENV LC_ALL=C
|
11 | ENV DISPLAY=:99
|
12 | ENV SELENIUM_CONSOLE_URL=http://localhost:4444/wd/hub
|
13 | ENV SCREEN_GEOMETRY=1024x768x16
|
14 |
|
15 |
|
16 | # Expose Selenium web console port
|
17 | EXPOSE 4444
|
18 |
|
19 |
|
20 | # Update packages
|
21 | RUN apt-get -qqy update
|
22 |
|
23 |
|
24 | # Install commons
|
25 | RUN apt-get -qqy install \
|
26 | apt-transport-https \
|
27 | ca-certificates \
|
28 | curl \
|
29 | jq \
|
30 | software-properties-common \
|
31 | sudo \
|
32 | openjdk-8-jre-headless \
|
33 | wget \
|
34 | xvfb \
|
35 | xfonts-100dpi \
|
36 | xfonts-75dpi \
|
37 | xfonts-scalable \
|
38 | xfonts-cyrillic
|
39 |
|
40 |
|
41 | # Install Browser from vendor source
|
42 | # Strategies copied from official Selenium Docker images (https://github.com/SeleniumHQ/docker-selenium)
|
43 |
|
44 | ## Install latest Firefox
|
45 | ARG FIREFOX_VERSION=latest
|
46 | RUN FIREFOX_DOWNLOAD_URL=$(if [ $FIREFOX_VERSION = "latest" ] || [ $FIREFOX_VERSION = "nightly-latest" ] || [ $FIREFOX_VERSION = "devedition-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) \
|
47 | && apt-get -qqy --no-install-recommends install firefox \
|
48 | && rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
|
49 | && wget --no-verbose -O /tmp/firefox.tar.bz2 $FIREFOX_DOWNLOAD_URL \
|
50 | && apt-get -y purge firefox \
|
51 | && rm -rf /opt/firefox \
|
52 | && tar -C /opt -xjf /tmp/firefox.tar.bz2 \
|
53 | && rm /tmp/firefox.tar.bz2 \
|
54 | && mv /opt/firefox /opt/firefox-$FIREFOX_VERSION \
|
55 | && ln -fs /opt/firefox-$FIREFOX_VERSION/firefox /usr/bin/firefox
|
56 |
|
57 | ## Install latest Google Chrome
|
58 | ARG CHROME_VERSION="google-chrome-stable"
|
59 | RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
60 | && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
|
61 | && apt-get update -qqy \
|
62 | && apt-get -qqy install \
|
63 | ${CHROME_VERSION:-google-chrome-stable} \
|
64 | && rm /etc/apt/sources.list.d/google-chrome.list \
|
65 | && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
|
66 |
|
67 | ## Chrome Launch Script Wrapper (forces no-sandbox so no need to use --privileged parameter)
|
68 | COPY ./scripts/wrap_chrome_binary /opt/bin/wrap_chrome_binary
|
69 | RUN /opt/bin/wrap_chrome_binary
|
70 |
|
71 |
|
72 | # Install Node.js LTS
|
73 | RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
|
74 | RUN apt-get -qqy install -y nodejs
|
75 |
|
76 | # Add non-root user
|
77 | RUN useradd seluser \
|
78 | --shell /bin/bash \
|
79 | --create-home \
|
80 | && usermod -a -G sudo seluser \
|
81 | && echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers \
|
82 | && echo 'seluser:secret' | chpasswd
|
83 |
|
84 |
|
85 | # Install selenium-standalone
|
86 | ARG DEBUG
|
87 | RUN npm install -g selenium-standalone
|
88 | RUN selenium-standalone install
|
89 |
|
90 |
|
91 | ADD ./scripts/ /home/seluser/scripts
|
92 |
|
93 |
|
94 | # Add Tini for graceful shutdown
|
95 | ENV TINI_VERSION v0.18.0
|
96 | ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
|
97 | RUN chmod +x /tini
|
98 | ENTRYPOINT ["/tini", "--"]
|
99 |
|
100 |
|
101 | # Force using non root user to execute the image
|
102 | USER seluser
|
103 |
|
104 |
|
105 | # Display Selenium environment
|
106 | RUN . /home/seluser/scripts/utils.sh && print_selenium_env
|
107 |
|
108 |
|
109 | # Selenium server healthcheck
|
110 | HEALTHCHECK --start-period=5s --interval=3s --retries=8 \
|
111 | CMD curl -qsf "$SELENIUM_CONSOLE_URL/status" | jq -r '.value.ready' | grep "true" || exit 1
|
112 |
|
113 |
|
114 | # Run our start script under Tini
|
115 | CMD ["/home/seluser/scripts/start.sh"]
|