From 1aa249bf6c3138352b0ae1998099a4454cade544 Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Fri, 16 Mar 2018 19:54:45 +0100 Subject: [PATCH] Update Dockerfile, install Chrome and Chromedriver 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 --- Dockerfile | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 37c328ee..1efb5430 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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