From 9c6a9497a4163a35774ec5d4e9d28630a033760b Mon Sep 17 00:00:00 2001 From: Agustin Alexander Date: Wed, 23 Oct 2019 19:13:44 -0300 Subject: [PATCH 1/7] fixed client Dockerfile to work with Firefox and Geckodriver --- services/instapy/Dockerfile | 46 ++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/services/instapy/Dockerfile b/services/instapy/Dockerfile index 17d88a0c..8e3d300f 100644 --- a/services/instapy/Dockerfile +++ b/services/instapy/Dockerfile @@ -1,23 +1,33 @@ -FROM python:3-alpine +FROM python:3.7-slim-buster WORKDIR /usr/instapy COPY . . -RUN apk add --update --no-cache --virtual .build-dependencies \ - python3-dev \ - gcc \ - musl-dev \ - g++ \ - libffi-dev \ - libressl-dev \ - && pip3 install -r requirements.txt \ - && pip3 uninstall -y instapy-chromedriver \ - && apk del .build-dependencies - -RUN apk --update --no-cache add \ - chromium \ - chromium-chromedriver - -ENV CHROMEDRIVER_PATH=/usr/bin/chromedriver -CMD ["python3", "-u", "start.py"] + +RUN apt-get update && apt-get install -y \ + wget gcc g++ \ + fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 \ + libnspr4 libnss3 lsb-release xdg-utils libxss1 libdbus-glib-1-2 \ + curl unzip \ + 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]+'` && \ + 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 && \ + 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 + +RUN pip3 install -r requirements.txt; + +CMD ["python3", "-u", "start.py"] \ No newline at end of file From c3c45f77c2d5d9ce9ff576064c03c2db9bea585f Mon Sep 17 00:00:00 2001 From: Agustin Alexander Date: Wed, 23 Oct 2019 19:15:12 -0300 Subject: [PATCH 2/7] removed chrome driver environment variable from source code --- services/instapy/bot.py | 1 - services/instapy/start.py | 4 ---- 2 files changed, 5 deletions(-) diff --git a/services/instapy/bot.py b/services/instapy/bot.py index 0435f49d..36f1f128 100644 --- a/services/instapy/bot.py +++ b/services/instapy/bot.py @@ -16,7 +16,6 @@ ident = getenv('IDENT') config_endpoint = getenv('CONFIG') socket_endpoint = getenv('SOCKET') -chromedriver_path = getenv('CHROMEDRIVER_PATH', None) if not namespace or not token: sys.exit(0) diff --git a/services/instapy/start.py b/services/instapy/start.py index 97e9b543..f8677fcf 100644 --- a/services/instapy/start.py +++ b/services/instapy/start.py @@ -19,7 +19,6 @@ CONFIG_ENDPOINT = os.getenv('CONFIG_ENDPOINT', 'https://config.instapy.io') SOCKET_ENDPOINT = os.getenv('SOCKET_ENDPOINT', 'wss://socket.instapy.io') IDENT = os.getenv('IDENT') -CHROMEDRIVER_PATH = os.getenv('CHROMEDRIVER_PATH', None) if not IDENT: print('IDENT not provided') @@ -132,7 +131,6 @@ def start(ws, data): global IDENT global NAMESPACE global SETTING - global CHROMEDRIVER_PATH ienv = os.environ.copy() ienv['TOKEN'] = TOKEN @@ -143,8 +141,6 @@ def start(ws, data): ienv['SOCKET'] = SOCKET_ENDPOINT ienv['CONFIG'] = CONFIG_ENDPOINT ienv['IDENT'] = IDENT - if CHROMEDRIVER_PATH: - ienv['CHROMEDRIVER_PATH'] = CHROMEDRIVER_PATH if platform.system() == 'Windows': PROCESS = subprocess.Popen( From f1869e6b57661b0ae1d005dac58ec80dcb6ef0b8 Mon Sep 17 00:00:00 2001 From: Agustin Alexander Date: Wed, 23 Oct 2019 23:32:33 -0300 Subject: [PATCH 3/7] Freezed apt and pip and removed unnecessary packages IMG Size from 900 to 700 --- services/instapy/Dockerfile | 33 +++++++++---------------------- services/instapy/requirements.txt | 8 ++++---- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/services/instapy/Dockerfile b/services/instapy/Dockerfile index 8e3d300f..a2d123fd 100644 --- a/services/instapy/Dockerfile +++ b/services/instapy/Dockerfile @@ -4,30 +4,15 @@ WORKDIR /usr/instapy COPY . . - -RUN apt-get update && apt-get install -y \ - wget gcc g++ \ - fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 \ - libnspr4 libnss3 lsb-release xdg-utils libxss1 libdbus-glib-1-2 \ - curl unzip \ - 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]+'` && \ - 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 && \ - 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 +RUN sed -i "s#deb http://deb.debian.org/debian buster main#deb http://deb.debian.org/debian buster main contrib non-free#g" /etc/apt/sources.list \ + && apt-get update && apt-get install -y --no-install-recommends \ + wget=1.20.1-1.1 gcc=4:8.3.0-1 g++=4:8.3.0-1 \ + firefox-esr=60.8.0esr-1~deb10u1 firefoxdriver\ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* RUN pip3 install -r requirements.txt; -CMD ["python3", "-u", "start.py"] \ No newline at end of file +CMD ["python3", "-u", "start.py"] + + diff --git a/services/instapy/requirements.txt b/services/instapy/requirements.txt index 31fbccec..30820a57 100644 --- a/services/instapy/requirements.txt +++ b/services/instapy/requirements.txt @@ -1,4 +1,4 @@ -instapy -websocket-client -requests -python-dotenv \ No newline at end of file +instapy==0.6.4 +websocket-client==0.56.0 +requests==2.22.0 +python-dotenv==0.10.3 \ No newline at end of file From 52b8a9fec1fa4eae4ff2ec93f31cdee89b186847 Mon Sep 17 00:00:00 2001 From: Agustin Alexander Date: Wed, 23 Oct 2019 23:37:06 -0300 Subject: [PATCH 4/7] pinned firefoxdriver --- services/instapy/Dockerfile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/services/instapy/Dockerfile b/services/instapy/Dockerfile index a2d123fd..ca263bcf 100644 --- a/services/instapy/Dockerfile +++ b/services/instapy/Dockerfile @@ -4,12 +4,23 @@ WORKDIR /usr/instapy COPY . . + RUN sed -i "s#deb http://deb.debian.org/debian buster main#deb http://deb.debian.org/debian buster main contrib non-free#g" /etc/apt/sources.list \ && apt-get update && apt-get install -y --no-install-recommends \ wget=1.20.1-1.1 gcc=4:8.3.0-1 g++=4:8.3.0-1 \ - firefox-esr=60.8.0esr-1~deb10u1 firefoxdriver\ + firefox-esr=60.8.0esr-1~deb10u1 firefoxdriver=3.14.1-1\ && apt-get clean \ && rm -rf /var/lib/apt/lists/* + + +# install geckodriver and firefox + +#RUN GECKODRIVER_VERSION=v0.23.0 && \ +# 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 pip3 install -r requirements.txt; From d06b114e5e3727b727877dd887ae0afb577c548f Mon Sep 17 00:00:00 2001 From: Felix Breuer Date: Thu, 24 Oct 2019 23:09:57 +0200 Subject: [PATCH 5/7] Update Dockerfile --- services/instapy/Dockerfile | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/services/instapy/Dockerfile b/services/instapy/Dockerfile index ca263bcf..18d37a36 100644 --- a/services/instapy/Dockerfile +++ b/services/instapy/Dockerfile @@ -4,26 +4,13 @@ WORKDIR /usr/instapy COPY . . - RUN sed -i "s#deb http://deb.debian.org/debian buster main#deb http://deb.debian.org/debian buster main contrib non-free#g" /etc/apt/sources.list \ && apt-get update && apt-get install -y --no-install-recommends \ - wget=1.20.1-1.1 gcc=4:8.3.0-1 g++=4:8.3.0-1 \ + wget=1.20.1-1.1 gcc=4:8.3.0-1 g++=4:8.3.0-1 \ firefox-esr=60.8.0esr-1~deb10u1 firefoxdriver=3.14.1-1\ && apt-get clean \ && rm -rf /var/lib/apt/lists/* - - -# install geckodriver and firefox - -#RUN GECKODRIVER_VERSION=v0.23.0 && \ -# 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 pip3 install -r requirements.txt; CMD ["python3", "-u", "start.py"] - - From d30f042bde194369cf1f7deb6b9c342f5c592067 Mon Sep 17 00:00:00 2001 From: Felix Breuer Date: Thu, 24 Oct 2019 23:10:36 +0200 Subject: [PATCH 6/7] Update requirements.txt --- services/instapy/requirements.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/instapy/requirements.txt b/services/instapy/requirements.txt index 30820a57..4ce7c53a 100644 --- a/services/instapy/requirements.txt +++ b/services/instapy/requirements.txt @@ -1,4 +1,4 @@ -instapy==0.6.4 -websocket-client==0.56.0 -requests==2.22.0 -python-dotenv==0.10.3 \ No newline at end of file +instapy +websocket-client +requests +python-dotenv From 4c872713eece70658090c50a794809ea8fb1e381 Mon Sep 17 00:00:00 2001 From: Felix Breuer Date: Thu, 24 Oct 2019 23:10:56 +0200 Subject: [PATCH 7/7] Update requirements.txt