From 0551c92227287aaa32d3a559635dde8f7ea9b5a1 Mon Sep 17 00:00:00 2001 From: Emilien Devos <4016501+unixfox@users.noreply.github.com> Date: Sun, 21 Jul 2024 17:47:18 +0200 Subject: [PATCH] dirty patch for retrying more time nodriver + remove some dependencies --- Dockerfile | 10 +++------- docker/scripts/startup.sh | 20 ++++++-------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index ae58b1f..c3e581c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,6 @@ FROM python:3.12-alpine # Install dependencies RUN apk add --no-cache \ xvfb \ - x11vnc \ - fluxbox \ nss \ freetype \ freetype-dev \ @@ -14,16 +12,14 @@ RUN apk add --no-cache \ chromium \ chromium-chromedriver -# Install x11vnc -RUN mkdir ~/.vnc -RUN x11vnc -storepasswd 1234 ~/.vnc/passwd - WORKDIR /usr/app/src COPY index.py requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt COPY docker/scripts/startup.sh ./ - + +RUN sed -i 's/await self.sleep(0.5)/await self.sleep(2)/' /usr/local/lib/python3.12/site-packages/nodriver/core/browser.py + # Run CMD [ "./startup.sh"] \ No newline at end of file diff --git a/docker/scripts/startup.sh b/docker/scripts/startup.sh index abfd6c0..c9b5996 100755 --- a/docker/scripts/startup.sh +++ b/docker/scripts/startup.sh @@ -2,21 +2,13 @@ echo "[INFO] internally launching GUI (X11 environment)" -rm -f /tmp/.X0-lock +XVFB_WHD=${XVFB_WHD:-1280x720x16} -# Run Xvfb on display 0. -Xvfb :0 -screen 0 1280x720x16 &>/dev/null & +echo "[INFO] starting Xvfb" +Xvfb :99 -ac -screen 0 $XVFB_WHD -nolisten tcp & +sleep 2 -# Run fluxbox windows manager on display 0. -fluxbox -display :0 &>/dev/null & - -# Run x11vnc on display 0 -x11vnc -display :0 -forever -usepw &>/dev/null & - -# Add delay -sleep 5 - -echo "[INFO] launching the python script" +echo "[INFO] launching chromium instance" # Run python script on display 0 -DISPLAY=:0 python index.py +DISPLAY=:99 python index.py