Skip to content

Commit 717b8cb

Browse files
committed
Brand New Dockerfile
1 parent b382d58 commit 717b8cb

File tree

1 file changed

+54
-57
lines changed

1 file changed

+54
-57
lines changed

Dockerfile

Lines changed: 54 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,29 @@
11
# SeleniumBase Docker Image
22
FROM ubuntu:14.04
33

4+
#=======================================
45
# Install Python and Basic Python Tools
6+
#=======================================
57
RUN apt-get update && apt-get install -y python python-pip python-setuptools python-dev python-distribute
68

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 \
2613
sudo \
2714
unzip \
2815
wget \
2916
curl \
3017
vim \
3118
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
3827

3928
#==============================
4029
# Locale and encoding settings
@@ -44,19 +33,16 @@ ENV LANG ${LANGUAGE}
4433
RUN locale-gen ${LANGUAGE} \
4534
&& dpkg-reconfigure --frontend noninteractive locales
4635

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
6046

6147
#================
6248
# Install Chrome
@@ -67,22 +53,25 @@ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key
6753
&& apt-get install -y google-chrome-stable \
6854
&& rm -rf /var/lib/apt/lists/*
6955

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\nexec /opt/google/chrome/google-chrome.real --disable-setuid-sandbox \"\$@\"" > /opt/google/chrome/google-chrome && \
61+
chmod 755 /opt/google/chrome/google-chrome
7962

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
8675

8776
#===================
8877
# Install PhantomJS
@@ -93,6 +82,15 @@ RUN ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local
9382
RUN ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
9483
RUN ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
9584

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+
9694
#=====================
9795
# Set up SeleniumBase
9896
#=====================
@@ -103,13 +101,12 @@ COPY examples /SeleniumBase/examples/
103101
RUN cd /SeleniumBase && ls && sudo pip install -r docker_requirements.txt
104102
RUN cd /SeleniumBase && ls && sudo python docker_setup.py install
105103

106-
#=========================================
107-
# Create entrypoint and grab example test
108-
#=========================================
104+
#==========================================
105+
# Create entrypoint and grab example tests
106+
#==========================================
109107
COPY docker/docker-entrypoint.sh /
110108
COPY docker/run_docker_test_in_firefox.sh /
111109
COPY docker/run_docker_test_in_chrome.sh /
112-
COPY docker/run_docker_test_in_phantomjs.sh /
113110
COPY docker/docker_config.cfg /SeleniumBase/examples/
114111
ENTRYPOINT ["/docker-entrypoint.sh"]
115112
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)