Skip to content

Commit

Permalink
Update Dockerfile, install Chrome and Chromedriver
Browse files Browse the repository at this point in the history
as wraith now supports headless chrome, it can be installed in the
docker container - also update nodejs to version 8 and use the ruby
version specified by the repository's .ruby-version file
  • Loading branch information
m90 committed Mar 16, 2018
1 parent 7adfb1b commit f4eea6f
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
FROM ruby:2.1.2
FROM ruby:2.4.1

# some of ruby's build scripts are written in ruby
# we purge this later to make sure our final image uses what we just built
RUN apt-get update
RUN echo "export phantomjs=/usr/bin/phantomjs" > .bashrc
RUN apt-get install -y libfreetype6 libfontconfig1 nodejs npm libnss3-dev libgconf-2-4
RUN ln -s /usr/bin/nodejs /usr/bin/node
RUN npm install npm
RUN npm install -g phantomjs@2.1.7 casperjs@1.1.1
WORKDIR /wraith

RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install -y libfreetype6 libfontconfig1 nodejs libnss3-dev libgconf-2-4 \
&& rm -rf /var/lib/apt/lists/*

# make sure npm does not need sudo: https://docs.npmjs.com/getting-started/fixing-npm-permissions
RUN mkdir /wraith/.npm-global
ENV NPM_CONFIG_PREFIX=/wraith/.npm-global
ENV PATH=/wraith/.npm-global/bin:$PATH

# install with --unsafe-perm because of https://github.com/Medium/phantomjs/issues/707
RUN npm install -g phantomjs-prebuilt casperjs --unsafe-perm
RUN gem install wraith --no-rdoc --no-ri
RUN gem install aws-sdk --no-rdoc --no-ri

# install chrome and chromedriver (unzip is needed for installing chromedriver)
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list \
&& apt-get update \
&& apt-get install -y google-chrome-stable unzip \
&& rm -rf /var/lib/apt/lists/* \
&& sed -i 's|HERE/chrome"|HERE/chrome" --disable-setuid-sandbox --no-sandbox|g' \
"/opt/google/chrome/google-chrome" \
&& google-chrome --version

RUN export CHROMEDRIVER_RELEASE=$(curl --location --fail --retry 3 http://chromedriver.storage.googleapis.com/LATEST_RELEASE) \
&& curl --silent --show-error --location --fail --retry 3 --output /tmp/chromedriver_linux64.zip "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_RELEASE/chromedriver_linux64.zip" \
&& cd /tmp \
&& unzip chromedriver_linux64.zip \
&& rm -rf chromedriver_linux64.zip \
&& mv chromedriver /usr/local/bin/chromedriver \
&& chmod +x /usr/local/bin/chromedriver \
&& chromedriver --version

# Make sure decent fonts are installed. Thanks to http://www.dailylinuxnews.com/blog/2014/09/things-to-do-after-installing-debian-jessie/
RUN echo "deb http://ftp.us.debian.org/debian jessie main contrib non-free" | tee -a /etc/apt/sources.list
RUN echo "deb http://security.debian.org/ jessie/updates contrib non-free" | tee -a /etc/apt/sources.list
Expand Down

0 comments on commit f4eea6f

Please sign in to comment.