From 7d8701242af0fb97f95370f34f0561d32e4bdddc Mon Sep 17 00:00:00 2001 From: dimmg Date: Mon, 29 Nov 2021 12:55:53 +0200 Subject: [PATCH] reduce size of the build image --- Dockerfile | 63 +++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index b39ed0e..21be548 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,54 +1,59 @@ FROM ubuntu:focal ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install --no-install-recommends -y \ +RUN echo "===> Installing system dependencies..." && \ + BUILD_DEPS="curl unzip wget" && \ + apt-get update && apt-get install --no-install-recommends -y \ python3 python3-pip \ fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 \ libnspr4 libnss3 lsb-release xdg-utils libxss1 libdbus-glib-1-2 libgbm1 \ - curl unzip wget \ - xvfb - - -# install geckodriver and firefox - -RUN GECKODRIVER_VERSION=`curl https://github.com/mozilla/geckodriver/releases/latest | grep -Po 'v[0-9]+.[0-9]+.[0-9]+'` && \ + $BUILD_DEPS \ + xvfb && \ + \ + \ + echo "===> Installing geckodriver and firefox..." && \ + GECKODRIVER_VERSION=`curl https://github.com/mozilla/geckodriver/releases/latest | grep -Po 'v[0-9]+.[0-9]+.[0-9]+'` && \ wget https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz && \ tar -zxf geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz -C /usr/local/bin && \ chmod +x /usr/local/bin/geckodriver && \ - rm geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz - -RUN FIREFOX_SETUP=firefox-setup.tar.bz2 && \ + rm geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz && \ + \ + FIREFOX_SETUP=firefox-setup.tar.bz2 && \ apt-get purge firefox && \ wget -O $FIREFOX_SETUP "https://download.mozilla.org/?product=firefox-latest&os=linux64" && \ tar xjf $FIREFOX_SETUP -C /opt/ && \ ln -s /opt/firefox/firefox /usr/bin/firefox && \ - rm $FIREFOX_SETUP - - -# install chromedriver and google-chrome - -RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \ + rm $FIREFOX_SETUP && \ + \ + \ + echo "===> Installing chromedriver and google-chrome..." && \ + CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \ wget https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \ unzip chromedriver_linux64.zip -d /usr/bin && \ chmod +x /usr/bin/chromedriver && \ - rm chromedriver_linux64.zip - -RUN CHROME_SETUP=google-chrome.deb && \ + rm chromedriver_linux64.zip && \ + \ + CHROME_SETUP=google-chrome.deb && \ wget -O $CHROME_SETUP "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb" && \ dpkg -i $CHROME_SETUP && \ apt-get install -y -f && \ - rm $CHROME_SETUP - - -# install phantomjs - -RUN wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 && \ + rm $CHROME_SETUP && \ + \ + \ + echo "===> Installing phantomjs..." && \ + wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 && \ tar -jxf phantomjs-2.1.1-linux-x86_64.tar.bz2 && \ cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs && \ - rm phantomjs-2.1.1-linux-x86_64.tar.bz2 - + rm phantomjs-2.1.1-linux-x86_64.tar.bz2 && \ + \ + \ + echo "===> Installing python dependencies..." && \ + pip3 install selenium==3.141.0 pyvirtualdisplay==2.2 && \ + \ + \ + echo "===> Remove build dependencies..." && \ + apt-get remove -y $BUILD_DEPS && rm -rf /var/lib/apt/lists/* -RUN pip3 install selenium==3.141.0 pyvirtualdisplay==2.2 ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8