Skip to content

Commit

Permalink
Adding GitPod Config (#10855)
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol authored Jul 12, 2022
1 parent 7b1c646 commit dcb27c1
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
image:
file: ./scripts/gitpod/.gitpod.Dockerfile

tasks:
- name: Supervisor (VNC and noVNC)
command: /usr/bin/supervisord --configuration /etc/supervisord.conf &
- name: Set cache path and warm it up
init: |
echo "build --repository_cache=/workspace/.cache/bazel-repo" >> /workspace/selenium/.bazelrc.local
echo "test --repository_cache=/workspace/.cache/bazel-repo" >> /workspace/selenium/.bazelrc.local
echo "build --disk_cache=/workspace/.cache/bazel-disk" >> /workspace/selenium/.bazelrc.local
echo "test --disk_cache=/workspace/.cache/bazel-disk" >> /workspace/selenium/.bazelrc.local
echo "build --jobs=10" >> /workspace/selenium/.bazelrc.local
echo "test --jobs=10" >> /workspace/selenium/.bazelrc.local
bazel build grid
ports:
- name: VNC
description: Port where VNC server is listening
port: 5900
onOpen: ignore
- name: XVFB
description: Port where XVFB server is listening
port: 6099
onOpen: ignore
- name: noVNC
description: Port where the noVNC view is available
port: 7900
onOpen: notify
- name: Build and test ports
description: Other ports opened while building or testing
port: 8000-65535
onOpen: ignore

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ skipped silently if you are not building on Windows.

## Building

### Contribute with GitPod

GitPod provides a ready to use environment to develop.

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/SeleniumHQ/selenium)

To configure and use your local machine, keep reading.

### Bazel

[Bazel](https://bazel.build/) was built by the fine folks at Google. Bazel manages dependency
Expand Down
2 changes: 1 addition & 1 deletion scripts/dev-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN apt-get update -qqy && \
apt-get -qy install google-chrome-stable firefox && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*

RUN curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.10.1/bazelisk-linux-amd64 -o /usr/bin/bazelisk && \
RUN curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.12.0/bazelisk-linux-amd64 -o /usr/bin/bazelisk && \
chmod 755 /usr/bin/bazelisk && \
ln -sf /usr/bin/bazelisk /usr/bin/bazel

Expand Down
104 changes: 104 additions & 0 deletions scripts/gitpod/.gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Used to create a development image for working on Selenium

# You can find the new timestamped tags here: https://hub.docker.com/r/gitpod/workspace-full/tags
FROM gitpod/workspace-full:2022-06-20-19-54-55

USER root

#RUN apt-get update -qqy && apt-get install -y wget curl gnupg2

# So we can install browsers and browser drivers later
RUN wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
RUN mkdir -p /home/gitpod/selenium /var/run/supervisor /var/log/supervisor && \
chmod -R 777 /var/run/supervisor /var/log/supervisor

ENV DEBIAN_FRONTEND=noninteractive

# Things needed by bazel and to run tests

RUN apt-get update -qqy && \
apt-get -qy install python-is-python3 \
dotnet-sdk-5.0 \
supervisor \
x11vnc \
fluxbox \
xvfb && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*

# Browsers

RUN apt-get update -qqy && \
apt-get -qy install google-chrome-stable firefox && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*

# Browser Drivers

RUN 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}") \
&& 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 /home/gitpod/selenium/chromedriver \
&& unzip /tmp/chromedriver_linux64.zip -d /home/gitpod/selenium \
&& rm /tmp/chromedriver_linux64.zip \
&& mv /home/gitpod/selenium/chromedriver /home/gitpod/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& chmod 755 /home/gitpod/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& sudo ln -fs /home/gitpod/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver

RUN GK_VERSION="0.31.0" \
&& echo "Using GeckoDriver version: "$GK_VERSION \
&& wget --no-verbose -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v$GK_VERSION/geckodriver-v$GK_VERSION-linux64.tar.gz \
&& rm -rf /home/gitpod/selenium/geckodriver \
&& tar -C /home/gitpod/selenium -zxf /tmp/geckodriver.tar.gz \
&& rm /tmp/geckodriver.tar.gz \
&& mv /home/gitpod/selenium/geckodriver /home/gitpod/selenium/geckodriver-$GK_VERSION \
&& chmod 755 /home/gitpod/selenium/geckodriver-$GK_VERSION \
&& ln -fs /home/gitpod/selenium/geckodriver-$GK_VERSION /usr/bin/geckodriver

# noVNC exposes VNC through a web page
ENV NOVNC_TAG="1.3.0" \
WEBSOCKIFY_TAG="0.10.0"

RUN wget -nv -O /tmp/noVNC.zip "https://github.com/novnc/noVNC/archive/refs/tags/v${NOVNC_TAG}.zip" \
&& unzip -x /tmp/noVNC.zip -d /tmp \
&& mv /tmp/noVNC-${NOVNC_TAG} /home/gitpod/selenium/noVNC \
&& cp /home/gitpod/selenium/noVNC/vnc.html /home/gitpod/selenium/noVNC/index.html \
&& rm /tmp/noVNC.zip \
&& wget -nv -O /tmp/websockify.zip "https://github.com/novnc/websockify/archive/refs/tags/v${WEBSOCKIFY_TAG}.zip" \
&& unzip -x /tmp/websockify.zip -d /tmp \
&& rm /tmp/websockify.zip \
&& mv /tmp/websockify-${WEBSOCKIFY_TAG} /home/gitpod/selenium/noVNC/utils/websockify

# Bazel

RUN curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.12.0/bazelisk-linux-amd64 -o /usr/bin/bazelisk && \
chmod 755 /usr/bin/bazelisk && \
ln -sf /usr/bin/bazelisk /usr/bin/bazel

USER gitpod

# Supervisor
#======================================
# Add Supervisor configuration file
#======================================
COPY scripts/gitpod/supervisord.conf /etc

#==============================
# Scripts to run XVFB, VNC, and noVNC
#==============================
COPY scripts/gitpod/start-xvfb.sh \
scripts/gitpod/start-vnc.sh \
scripts/gitpod/start-novnc.sh \
/home/gitpod/selenium/

# To run browser tests
ENV DISPLAY :99.0
ENV DISPLAY_NUM 99
ENV SCREEN_WIDTH 1360
ENV SCREEN_HEIGHT 1020
ENV SCREEN_DEPTH 24
ENV SCREEN_DPI 96
ENV VNC_PORT 5900
ENV NO_VNC_PORT 7900
3 changes: 3 additions & 0 deletions scripts/gitpod/start-novnc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

/home/gitpod/selenium/noVNC/utils/novnc_proxy --listen ${NO_VNC_PORT} --vnc localhost:${VNC_PORT}
14 changes: 14 additions & 0 deletions scripts/gitpod/start-vnc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
#

for i in $(seq 1 10)
do
sleep 1
xdpyinfo -display ${DISPLAY} >/dev/null 2>&1
if [ $? -eq 0 ]; then
break
fi
echo "Waiting for Xvfb..."
done

x11vnc -forever -shared -rfbport ${VNC_PORT} -rfbportv6 ${VNC_PORT} -display ${DISPLAY}
14 changes: 14 additions & 0 deletions scripts/gitpod/start-xvfb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

export GEOMETRY="${SCREEN_WIDTH}""x""${SCREEN_HEIGHT}""x""${SCREEN_DEPTH}"

rm -f /tmp/.X*lock

# Command reference
# http://manpages.ubuntu.com/manpages/focal/man1/xvfb-run.1.html
# http://manpages.ubuntu.com/manpages/focal/man1/Xvfb.1.html
# http://manpages.ubuntu.com/manpages/focal/man1/Xserver.1.html
/usr/bin/xvfb-run --server-num=${DISPLAY_NUM} \
--listen-tcp \
--server-args="-screen 0 ${GEOMETRY} -fbdir /var/tmp -dpi ${SCREEN_DPI} -listen tcp -noreset -ac +extension RANDR" \
/usr/bin/fluxbox -display ${DISPLAY}
65 changes: 65 additions & 0 deletions scripts/gitpod/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
; Documentation of this file format -> http://supervisord.org/configuration.html

[supervisord]
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/var/run/supervisor/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)

; Priority 0 - xvfb & fluxbox, 5 - x11vnc, 10 - noVNC

[program:xvfb]
priority=0
command=/home/gitpod/selenium/start-xvfb.sh
autostart=true
autorestart=true

;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:vnc]
priority=5
command=/home/gitpod/selenium/start-vnc.sh
autostart=true
autorestart=true

;Logs
redirect_stderr=false
stdout_logfile=/var/log/supervisor/vnc-stdout.log
stderr_logfile=/var/log/supervisor/vnc-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:novnc]
priority=10
command=/home/gitpod/selenium/start-novnc.sh
autostart=true
autorestart=true

;Logs
redirect_stderr=false
stdout_logfile=/var/log/supervisor/novnc-stdout.log
stderr_logfile=/var/log/supervisor/novnc-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

0 comments on commit dcb27c1

Please sign in to comment.