From b7ce8d67145e5bef73d2847c05a183da1023dbfa Mon Sep 17 00:00:00 2001 From: Gleb Novikov Date: Sun, 27 Sep 2020 16:39:32 +0300 Subject: [PATCH] Added Dockerfile, docker-compose and fixed init_chromedriver --- docker-compose.yml | 11 +++++++++++ docker/Dockerfile | 32 ++++++++++++++++++++++++++++++++ loconotion/notionparser.py | 2 ++ 3 files changed, 45 insertions(+) create mode 100644 docker-compose.yml create mode 100644 docker/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..349f90a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3" + +services: + loconotion: + build: + context: . + dockerfile: docker/Dockerfile + image: loconotion:latest + volumes: + - ${LOCONOTION_LOCAL_DIST:-/tmp/}:/app/loconotion/dist + restart: always \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..1f7ecaa --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,32 @@ +FROM python:3.8 + +# ChromeDriver installation from https://gist.github.com/varyonic/dea40abcf3dd891d204ef235c6e8dd79 +# We need wget to set up the PPA and xvfb to have a virtual screen and unzip to install the Chromedriver +RUN apt-get update +RUN apt-get install -y libgconf-2-4 wget xvfb unzip +# Set up the Chrome PPA +RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - +RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list +# Update the package list and install chrome +RUN apt-get update -y +RUN apt-get install -y google-chrome-stable + +# RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb +# RUN dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install +# Set up Chromedriver Environment variables +ENV CHROMEDRIVER_VERSION 85.0.4183.38 +ENV CHROMEDRIVER_DIR /chromedriver +RUN mkdir $CHROMEDRIVER_DIR +# Download and install Chromedriver +RUN wget -q --continue -P $CHROMEDRIVER_DIR "https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip" +RUN unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR +# Put Chromedriver into the PATH +ENV PATH $CHROMEDRIVER_DIR:$PATH + +RUN mkdir -p /app/loconotion/ +WORKDIR /app/loconotion/ +COPY requirements.txt . +RUN pip install -r requirements.txt + +COPY . . +ENTRYPOINT [ "python", "loconotion", "--chromedriver", "/chromedriver/chromedriver"] diff --git a/loconotion/notionparser.py b/loconotion/notionparser.py index 1e35d28..40e2119 100644 --- a/loconotion/notionparser.py +++ b/loconotion/notionparser.py @@ -228,6 +228,8 @@ class Parser: if not self.args.get("non_headless", False): chrome_options.add_argument("--headless") chrome_options.add_argument("window-size=1920,1080") + chrome_options.add_argument('--no-sandbox') + chrome_options.add_argument('--disable-dev-shm-usage') chrome_options.add_argument("--log-level=3") chrome_options.add_argument("--silent") chrome_options.add_argument("--disable-logging")