From 3321a56f8c88eb59c60a715a94ce206bb4dd41da Mon Sep 17 00:00:00 2001 From: Yuri Bochkarev Date: Sun, 20 Feb 2022 13:48:05 +0100 Subject: [PATCH] tests: first step to setting up integration tests in docker again --- INTEGRATION.md | 43 +++++++++++++++++++++++++++++++++++++++++++ jess.Dockerfile | 41 +++++++++++++++++++++++++++++++++++++++++ startup.sh | 12 ++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 INTEGRATION.md create mode 100644 jess.Dockerfile create mode 100755 startup.sh diff --git a/INTEGRATION.md b/INTEGRATION.md new file mode 100644 index 0000000..f3a9fb6 --- /dev/null +++ b/INTEGRATION.md @@ -0,0 +1,43 @@ + +```bash +# Testing command in docker: +# pip install -e . +# ~/.local/bin/bt install +# chromium-browser --load-extension=/brotab/brotab/extension/chrome --headless --use-gl=swiftshader --disable-software-rasterizer --disable-dev-shm-usage --no-sandbox --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 https://www.chromestatus.com/ +# xvfb-chromium --no-sandbox --load-extension=/brotab/brotab/extension/chrome --use-gl=swiftshader --disable-software-rasterizer --disable-dev-shm-usage --no-sandbox --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 https://www.chromestatus.com/ + +# chromium --disable-gpu --remote-debugging-address=0.0.0.0 --remote-debugging-port=19222 https://ipinfo.io/json +# chromium --no-sandbox --disable-gpu --remote-debugging-address=0.0.0.0 --remote-debugging-port=19222 https://ipinfo.io/json +# docker run -v "$(pwd):/brotab" -p 19222:9222 -it --rm --cpuset-cpus 0 --memory 512mb -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY -v /dev/shm:/dev/shm --security-opt seccomp=$(pwd)/chrome.json brotab-integration chromium --disable-gpu --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 https://ipinfo.io/json +# docker run -v "$(pwd):/brotab" -p 19222:9222 -it --rm --cpuset-cpus 0 --memory 512mb -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY -v /dev/shm:/dev/shm brotab-integration chromium --no-sandbox --disable-gpu --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 https://ipinfo.io/json + +# jess +# docker run -it --rm --net host --cpuset-cpus 0 --memory 512mb -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY -v /dev/shm:/dev/shm --security-opt seccomp=$(pwd)/chrome.json --name chromium brotab-integration +# working option: +# docker run -it --rm --net host --cpuset-cpus 0 --memory 512mb -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY -v /dev/shm:/dev/shm --security-opt seccomp=$(pwd)/chrome.json brotab-integration --remote-debugging-address=0.0.0.0 --remote-debugging-port=19222 --disable-gpu https://ipinfo.io/json + +# Run docker: +# docker run -v "$(pwd):/brotab" -p 19222:9222 -p 14625:4625 -it --rm --cpuset-cpus 0 --memory 512mb -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY -v /dev/shm:/dev/shm brotab-integration + +# Inside: +# pip install -e . +# bt install --tests +# chromium --no-sandbox --disable-gpu --remote-debugging-address=0.0.0.0 --remote-debugging-port=19222 --load-extension=/brotab/brotab/extension/chrome file:/// + +# chromium --no-sandbox --disable-gpu --remote-debugging-address=0.0.0.0 --remote-debugging-port=19222 --load-extension=/brotab/brotab/extension/chrome https://ipinfo.io/json + +# socat TCP4-LISTEN:8000,fork,reuseaddr,bind=172.17.0.2 TCP4:127.0.0.1:8000 + +# python3 -m http.server --bind :: +# python3 -m http.server --bind 172.17.0.2 + +# -v $HOME/Downloads:/home/chromium/Downloads \ +# -v $HOME/.config/chromium/:/data \ # if you want to save state +# --security-opt seccomp=$HOME/chrome.json \ +# --device /dev/snd \ # so we have sound + +# Remote: +# http://0.0.0.0:19222/devtools/inspector.html?ws=localhost:19222/devtools/page/AEDF6B9CB4D1DD63E26826BBA3EC50B5 + + +``` diff --git a/jess.Dockerfile b/jess.Dockerfile new file mode 100644 index 0000000..01a84d5 --- /dev/null +++ b/jess.Dockerfile @@ -0,0 +1,41 @@ +# Adjusted based on: https://github.com/jessfraz/dockerfiles/blob/master/chromium/Dockerfile + +FROM debian:bullseye-slim +LABEL maintainer "Jessie Frazelle " + +RUN apt-get update && apt-get install -y \ + chromium \ + chromium-l10n \ + fonts-liberation \ + fonts-roboto \ + hicolor-icon-theme \ + libcanberra-gtk-module \ + libexif-dev \ + libgl1-mesa-dri \ + libgl1-mesa-glx \ + libpangox-1.0-0 \ + libv4l-0 \ + fonts-symbola \ + python3 python3-pip \ + socat curl net-tools \ + --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* \ + && mkdir -p /etc/chromium.d/ \ + && /bin/echo -e 'export GOOGLE_API_KEY="AIzaSyCkfPOPZXDKNn8hhgu3JrA62wIgC93d44k"\nexport GOOGLE_DEFAULT_CLIENT_ID="811574891467.apps.googleusercontent.com"\nexport GOOGLE_DEFAULT_CLIENT_SECRET="kdloedMFGdGla2P1zacGjAQh"' > /etc/chromium.d/googleapikeys + +# Add chromium user +# RUN groupadd -r chromium && useradd -m -r -g chromium -G audio,video chromium \ +# && mkdir -p /home/chromium/Downloads && chown -R chromium:chromium /home/chromium \ +# && mkdir /brotab && chown -R chromium:chromium /brotab +# # Run as non privileged user +# USER chromium + +COPY requirements/base.txt /tmp/base.txt +RUN pip3 install -r /tmp/base.txt + +COPY startup.sh /bin/startup.sh +WORKDIR /brotab +ENTRYPOINT [ "/bin/startup.sh" ] +#ENTRYPOINT [ "/bin/bash" ] +# ENTRYPOINT [ "/usr/bin/chromium" ] +# CMD [ "--user-data-dir=/data" ] diff --git a/startup.sh b/startup.sh new file mode 100755 index 0000000..a79fe39 --- /dev/null +++ b/startup.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +IF_PUBLIC=172.17.0.2 +IF_PRIVATE=127.0.0.1 + +socat TCP4-LISTEN:9222,fork,reuseaddr,bind=$IF_PUBLIC TCP4:$IF_PRIVATE:9222 & +socat TCP4-LISTEN:4625,fork,reuseaddr,bind=$IF_PUBLIC TCP4:$IF_PRIVATE:4625 & + +cd /brotab \ + && pip install -e . \ + && bt install --tests \ + && chromium --no-sandbox --disable-gpu --remote-debugging-address=$IF_PRIVATE --remote-debugging-port=9222 --load-extension=/brotab/brotab/extension/chrome file:///