From 0ba8bc0b9ebef94cf0c88acfacd933c5dbabb0d6 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Mon, 31 Dec 2018 20:31:32 -0500 Subject: [PATCH] Dockerfile: Update and streamline steps Does effectively the same things as before, but now in a simpler/faster way. Some of the changes take inspiration from @btyy77c's dockerAlpine branch: https://github.com/btyy77c/refugerestrooms/blob/dockerAlpine/Dockerfile The PhantomJS install is based on @nkovacs' phantomjs image from Docker Hub: https://github.com/nkovacs/selenium-standalone-phantomjs/blob/c5f6bba218472270/Dockerfile --- Dockerfile | 56 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index ec19a223..9d6e3064 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,40 @@ FROM ruby:2.5.3-slim -ENV PHANTOM_JS=2.1.1 # Add basic binaries RUN apt-get update \ - && apt-get install -y bzip2 curl gnupg wget - -# Add the apt repository for yarn -RUN curl -sS http://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ - echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list - -# Add the apt-repository for the latest node.js -RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - - -RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs -RUN apt-get install build-essential chrpath libssl-dev libxft-dev -y && \ - apt-get install libfreetype6 libfreetype6-dev -y && \ - apt-get install libfontconfig1 libfontconfig1-dev -y && \ - cd ~ && \ - export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64" && \ - wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/$PHANTOM_JS.tar.bz2 && \ - tar xvjf $PHANTOM_JS.tar.bz2 && \ - mv $PHANTOM_JS /usr/local/share && \ - ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin && \ - apt-get install -y yarn - -# Clean up the apt cache -RUN rm -rf /var/lib/apt/lists/* + && apt-get install -y curl g++ gcc libfontconfig libpq-dev make patch xz-utils \ + # Clean up the apt cache + && rm -rf /var/lib/apt/lists/* +# Download, extract and install PhantomJS from archive hosted at bitbucket +RUN curl -L https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O \ + && tar -xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 && rm phantomjs-2.1.1-linux-x86_64.tar.bz2 \ + && mv /phantomjs-2.1.1-linux-x86_64 /usr/local/phantomjs-2.1.1-linux-x86_64 \ + && ln -s /usr/local/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs + +# Specify a version of Node.js to download and install +ENV NODEJS_VERSION=v10.15.3 + +# Download and extract Node.js from archive supplied by nodejs.org +RUN curl -L https://nodejs.org/dist/$NODEJS_VERSION/node-$NODEJS_VERSION-linux-x64.tar.xz -o nodejs.tar.xz \ + && tar xf nodejs.tar.xz \ + # Clean up the Node.js archive + && rm nodejs.tar.xz + +# Add Node.js binaries to PATH (includes Node and NPM, will include Yarn) +ENV PATH="/node-$NODEJS_VERSION-linux-x64/bin/:${PATH}" + +# Install Yarn +RUN npm install -g yarn + +# Make the "/refugerestrooms" folder, run all subsequent commands in that folder RUN mkdir /refugerestrooms WORKDIR /refugerestrooms -COPY Gemfile /refugerestrooms/Gemfile -COPY Gemfile.lock /refugerestrooms/Gemfile.lock +# Install Ruby gems with Bundler +COPY Gemfile Gemfile.lock /refugerestrooms/ RUN bundle install +# Install Node.js packages with Yarn COPY package.json yarn.lock /refugerestrooms/ -RUN yarn --pure-lockfile +RUN yarn install --frozen-lockfile