1
1
# SeleniumBase Docker Image
2
2
FROM ubuntu:14.04
3
3
4
+ # =======================================
4
5
# Install Python and Basic Python Tools
6
+ # =======================================
5
7
RUN apt-get update && apt-get install -y python python-pip python-setuptools python-dev python-distribute
6
8
7
- # ========================
8
- # Miscellaneous packages
9
- # Includes minimal runtime used for executing selenium with firefox
10
- # ========================
11
- ENV BUILD_DEPS '\
12
- build-essential \
13
- libmysqlclient-dev \
14
- libpython-dev \
15
- libyaml-dev \
16
- libxml2-dev \
17
- libxslt1-dev \
18
- libxslt-dev \
19
- zlib1g-dev \
20
- '
21
-
22
- RUN apt-get update -qqy \
23
- && apt-get -qy --no-install-recommends install \
24
- locales \
25
- language-pack-en \
9
+ # =================================
10
+ # Install Bash Command Line Tools
11
+ # =================================
12
+ RUN apt-get -qy --no-install-recommends install \
26
13
sudo \
27
14
unzip \
28
15
wget \
29
16
curl \
30
17
vim \
31
18
xvfb \
32
- libaio1 \
33
- libxml2 \
34
- libxslt1.1 \
35
- mysql-client \
36
- ${BUILD_DEPS} \
37
- && rm -rf /var/lib/apt/lists/*
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # ========================================
22
+ # Add normal user with passwordless sudo
23
+ # ========================================
24
+ RUN sudo useradd seluser --shell /bin/bash --create-home \
25
+ && sudo usermod -a -G sudo seluser \
26
+ && echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers
38
27
39
28
# ==============================
40
29
# Locale and encoding settings
@@ -44,19 +33,16 @@ ENV LANG ${LANGUAGE}
44
33
RUN locale-gen ${LANGUAGE} \
45
34
&& dpkg-reconfigure --frontend noninteractive locales
46
35
47
- # ====================
48
- # Firefox Latest ESR
49
- # ====================
50
- RUN apt-get update -qqy \
51
- && apt-get -qy --no-install-recommends install \
52
- $(apt-cache depends firefox | grep Depends | sed "s/.*ends:\ //" | tr '\n ' ' ' ) \
53
- && rm -rf /var/lib/apt/lists/* \
54
- && cd /tmp \
55
- && wget --no-check-certificate -O firefox-esr.tar.bz2 \
56
- 'https://download.mozilla.org/?product=firefox-esr-latest&os=linux64&lang=en-US' \
57
- && tar -xjf firefox-esr.tar.bz2 -C /opt/ \
58
- && ln -s /opt/firefox/firefox /usr/bin/firefox \
59
- && rm -f /tmp/firefox-esr.tar.bz2
36
+ # ======================
37
+ # Install Chromedriver
38
+ # ======================
39
+ RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
40
+ mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \
41
+ curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
42
+ unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \
43
+ rm /tmp/chromedriver_linux64.zip && \
44
+ chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver && \
45
+ ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver
60
46
61
47
# ================
62
48
# Install Chrome
@@ -67,22 +53,25 @@ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key
67
53
&& apt-get install -y google-chrome-stable \
68
54
&& rm -rf /var/lib/apt/lists/*
69
55
70
- # ===================
71
- # Timezone settings
72
- # ===================
73
- # Full list at http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
74
- # e.g. "US/Pacific" for Los Angeles, California, USA
75
- ENV TZ "America/New_York"
76
- # Apply TimeZone
77
- RUN echo $TZ | tee /etc/timezone \
78
- && dpkg-reconfigure --frontend noninteractive tzdata
56
+ # ==================
57
+ # Configure Chrome
58
+ # ==================
59
+ RUN dpkg-divert --add --rename --divert /opt/google/chrome/google-chrome.real /opt/google/chrome/google-chrome && \
60
+ echo "#!/bin/bash\n exec /opt/google/chrome/google-chrome.real --disable-setuid-sandbox \"\$ @\" " > /opt/google/chrome/google-chrome && \
61
+ chmod 755 /opt/google/chrome/google-chrome
79
62
80
- # ========================================
81
- # Add normal user with passwordless sudo
82
- # ========================================
83
- RUN sudo useradd seluser --shell /bin/bash --create-home \
84
- && sudo usermod -a -G sudo seluser \
85
- && echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers
63
+ # =================
64
+ # Install Firefox
65
+ # =================
66
+ RUN apt-get -qy --no-install-recommends install \
67
+ $(apt-cache depends firefox | grep Depends | sed "s/.*ends:\ //" | tr '\n ' ' ' ) \
68
+ && rm -rf /var/lib/apt/lists/* \
69
+ && cd /tmp \
70
+ && wget --no-check-certificate -O firefox-esr.tar.bz2 \
71
+ 'https://download.mozilla.org/?product=firefox-esr-latest&os=linux64&lang=en-US' \
72
+ && tar -xjf firefox-esr.tar.bz2 -C /opt/ \
73
+ && ln -s /opt/firefox/firefox /usr/bin/firefox \
74
+ && rm -f /tmp/firefox-esr.tar.bz2
86
75
87
76
# ===================
88
77
# Install PhantomJS
@@ -93,6 +82,15 @@ RUN ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local
93
82
RUN ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
94
83
RUN ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
95
84
85
+ # ===========================
86
+ # Configure Virtual Display
87
+ # ===========================
88
+ RUN set -e
89
+ RUN echo "Starting X virtual framebuffer (Xvfb) in background..."
90
+ RUN Xvfb -ac :99 -screen 0 1280x1024x16 > /dev/null 2>&1 &
91
+ RUN export DISPLAY=:99
92
+ RUN exec "$@"
93
+
96
94
# =====================
97
95
# Set up SeleniumBase
98
96
# =====================
@@ -103,13 +101,12 @@ COPY examples /SeleniumBase/examples/
103
101
RUN cd /SeleniumBase && ls && sudo pip install -r docker_requirements.txt
104
102
RUN cd /SeleniumBase && ls && sudo python docker_setup.py install
105
103
106
- # =========================================
107
- # Create entrypoint and grab example test
108
- # =========================================
104
+ # ==========================================
105
+ # Create entrypoint and grab example tests
106
+ # ==========================================
109
107
COPY docker/docker-entrypoint.sh /
110
108
COPY docker/run_docker_test_in_firefox.sh /
111
109
COPY docker/run_docker_test_in_chrome.sh /
112
- COPY docker/run_docker_test_in_phantomjs.sh /
113
110
COPY docker/docker_config.cfg /SeleniumBase/examples/
114
111
ENTRYPOINT ["/docker-entrypoint.sh" ]
115
112
CMD ["/bin/bash" ]
0 commit comments