Commit 5a03f0b6 authored by Barkin Simsek's avatar Barkin Simsek 🐢
Browse files

Add custom Docker Selenium container for Brave Browser

parent 7a3993b8
......@@ -125,6 +125,24 @@ services:
timeout: 30s
retries: 5
brave-browser-container:
image: captchamonitor-brave-browser-container:latest
build:
context: ./standalone-brave-browser
dockerfile: Dockerfile
networks:
- captchamonitor_network
volumes:
- shared_tmp_volume:/tmp
shm_size: '2gb'
environment:
SE_OPTS: "-port 4447"
healthcheck:
test: ["CMD-SHELL", "/opt/bin/check-grid.sh --host 0.0.0.0 --port 4447"]
interval: 15s
timeout: 30s
retries: 5
networks:
captchamonitor_network:
driver: bridge
......
# Based on Selenium Docker Node
FROM selenium/node-base:latest
USER root
#============================================
# Brave Browser
#============================================
# can specify versions by BRAVE_VERSION;
# e.g. google-chrome-stable=53.0.2785.101-1
# google-chrome-beta=53.0.2785.92-1
# google-chrome-unstable=54.0.2840.14-1
# latest (equivalent to google-chrome-stable)
# google-chrome-beta (pull latest beta)
#============================================
ARG BRAVE_VERSION="brave-browser"
RUN apt install apt-transport-https curl \
&& curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main"|sudo tee /etc/apt/sources.list.d/brave-browser-release.list \
&& apt update -qqy \
&& apt install ${BRAVE_VERSION} -qqy \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
&& ln -fs /usr/bin/brave-browser /usr/bin/google-chrome \
&& ln -fs /usr/bin/brave-browser-stable /usr/bin/google-chrome-stable
# Brave Launch Script Wrapper
COPY wrap_chrome_binary /opt/bin/wrap_chrome_binary
RUN /opt/bin/wrap_chrome_binary
USER 1200
#============================================
# Chrome webdriver
#============================================
# can specify versions by CHROME_DRIVER_VERSION
# Latest released version will be used by default
#============================================
ARG CHROME_DRIVER_VERSION
RUN if [ -z "$CHROME_DRIVER_VERSION" ]; \
then CHROME_MAJOR_VERSION=$(google-chrome --version | sed -E "s/.* ([0-9]+)(\.[0-9]+){3}.*/\1/") \
&& CHROME_DRIVER_VERSION=$(wget --no-verbose -O - "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION}"); \
fi \
&& echo "Using chromedriver version: "$CHROME_DRIVER_VERSION \
&& wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \
&& rm -rf /opt/selenium/chromedriver \
&& unzip /tmp/chromedriver_linux64.zip -d /opt/selenium \
&& rm /tmp/chromedriver_linux64.zip \
&& mv /opt/selenium/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& chmod 755 /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& sudo ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver
COPY generate_config /opt/bin/generate_config
# Generating a default config during build time
RUN /opt/bin/generate_config > /opt/selenium/config.json
###############################################
# FROM selenium/node-chrome:3.141.59-20210607 #
###############################################
USER 1200
# Scripts to run Selenium Standalone
COPY start-selenium-standalone.sh /opt/bin/start-selenium-standalone.sh
# Supervisor configuration file
COPY selenium.conf /etc/supervisor/conf.d/
EXPOSE 4444
\ No newline at end of file
#!/bin/bash
CHROME_VERSION=$(/usr/bin/google-chrome --version | awk '{ print $3 }')
cat <<_EOF
{
"capabilities": [
{
"version": "$CHROME_VERSION",
"browserName": "chrome",
"maxInstances": $NODE_MAX_INSTANCES,
"seleniumProtocol": "WebDriver",
"applicationName": "$NODE_APPLICATION_NAME"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": $NODE_MAX_SESSION,
"host": "$NODE_HOST",
"port": $NODE_PORT,
"register": true,
"registerCycle": $NODE_REGISTER_CYCLE,
"nodePolling": $NODE_POLLING,
"unregisterIfStillDownAfter": $NODE_UNREGISTER_IF_STILL_DOWN_AFTER,
"downPollingLimit": $NODE_DOWN_POLLING_LIMIT,
"debug": $GRID_DEBUG
}
_EOF
; Documentation of this file format -> http://supervisord.org/configuration.html
; Priority 0 - xvfb, 5 - fluxbox (debug images), 10 - x11vnc (debug images), 15 - selenium-node
[program:xvfb]
priority=0
command=/opt/bin/start-xvfb.sh
autostart=true
autorestart=false
startsecs=0
startretries=0
;Logs
redirect_stderr=false
stdout_logfile=/var/log/supervisor/xvfb-stdout.log
stderr_logfile=/var/log/supervisor/xvfb-stderr.log
stdout_logfile_maxbytes=50MB
stderr_logfile_maxbytes=50MB
stdout_logfile_backups=5
stderr_logfile_backups=5
stdout_capture_maxbytes=50MB
stderr_capture_maxbytes=50MB
[program:selenium-standalone]
priority=15
command=/opt/bin/start-selenium-standalone.sh
autostart=true
autorestart=false
startsecs=0
startretries=0
;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs"
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
#!/usr/bin/env bash
#
# IMPORTANT: Change this file only in directory Standalone!
java ${JAVA_OPTS} -cp ${JAVA_CLASSPATH:-"/opt/selenium/*:."} org.openqa.grid.selenium.GridLauncherV3 \
${SE_OPTS}
\ No newline at end of file
#!/bin/bash
WRAPPER_PATH=$(readlink -f /usr/bin/google-chrome)
BASE_PATH="$WRAPPER_PATH-base"
mv "$WRAPPER_PATH" "$BASE_PATH"
cat > "$WRAPPER_PATH" <<_EOF
#!/bin/bash
# Note: exec -a below is a bashism.
exec -a "\$0" "$BASE_PATH" --no-sandbox "\$@"
_EOF
chmod +x "$WRAPPER_PATH"
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment