Skip to content

Commit

Permalink
tests: first step to setting up integration tests in docker again
Browse files Browse the repository at this point in the history
  • Loading branch information
balta2ar committed Feb 20, 2022
1 parent 3ae2492 commit 3321a56
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
43 changes: 43 additions & 0 deletions INTEGRATION.md
Original file line number Diff line number Diff line change
@@ -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


```
41 changes: 41 additions & 0 deletions jess.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Adjusted based on: https://github.com/jessfraz/dockerfiles/blob/master/chromium/Dockerfile

FROM debian:bullseye-slim
LABEL maintainer "Jessie Frazelle <[email protected]>"

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" ]
12 changes: 12 additions & 0 deletions startup.sh
Original file line number Diff line number Diff line change
@@ -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:///

0 comments on commit 3321a56

Please sign in to comment.