Skip to content

Commit dcb27c1

Browse files
authored
Adding GitPod Config (SeleniumHQ#10855)
1 parent 7b1c646 commit dcb27c1

8 files changed

+243
-1
lines changed

.gitpod.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
image:
2+
file: ./scripts/gitpod/.gitpod.Dockerfile
3+
4+
tasks:
5+
- name: Supervisor (VNC and noVNC)
6+
command: /usr/bin/supervisord --configuration /etc/supervisord.conf &
7+
- name: Set cache path and warm it up
8+
init: |
9+
echo "build --repository_cache=/workspace/.cache/bazel-repo" >> /workspace/selenium/.bazelrc.local
10+
echo "test --repository_cache=/workspace/.cache/bazel-repo" >> /workspace/selenium/.bazelrc.local
11+
echo "build --disk_cache=/workspace/.cache/bazel-disk" >> /workspace/selenium/.bazelrc.local
12+
echo "test --disk_cache=/workspace/.cache/bazel-disk" >> /workspace/selenium/.bazelrc.local
13+
echo "build --jobs=10" >> /workspace/selenium/.bazelrc.local
14+
echo "test --jobs=10" >> /workspace/selenium/.bazelrc.local
15+
bazel build grid
16+
17+
ports:
18+
- name: VNC
19+
description: Port where VNC server is listening
20+
port: 5900
21+
onOpen: ignore
22+
- name: XVFB
23+
description: Port where XVFB server is listening
24+
port: 6099
25+
onOpen: ignore
26+
- name: noVNC
27+
description: Port where the noVNC view is available
28+
port: 7900
29+
onOpen: notify
30+
- name: Build and test ports
31+
description: Other ports opened while building or testing
32+
port: 8000-65535
33+
onOpen: ignore
34+

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ skipped silently if you are not building on Windows.
7878

7979
## Building
8080

81+
### Contribute with GitPod
82+
83+
GitPod provides a ready to use environment to develop.
84+
85+
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/SeleniumHQ/selenium)
86+
87+
To configure and use your local machine, keep reading.
88+
8189
### Bazel
8290

8391
[Bazel](https://bazel.build/) was built by the fine folks at Google. Bazel manages dependency

scripts/dev-image/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN apt-get update -qqy && \
2828
apt-get -qy install google-chrome-stable firefox && \
2929
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
3030

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

scripts/gitpod/.gitpod.Dockerfile

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Used to create a development image for working on Selenium
2+
3+
# You can find the new timestamped tags here: https://hub.docker.com/r/gitpod/workspace-full/tags
4+
FROM gitpod/workspace-full:2022-06-20-19-54-55
5+
6+
USER root
7+
8+
#RUN apt-get update -qqy && apt-get install -y wget curl gnupg2
9+
10+
# So we can install browsers and browser drivers later
11+
RUN wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
12+
&& dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb
13+
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
14+
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
15+
RUN mkdir -p /home/gitpod/selenium /var/run/supervisor /var/log/supervisor && \
16+
chmod -R 777 /var/run/supervisor /var/log/supervisor
17+
18+
ENV DEBIAN_FRONTEND=noninteractive
19+
20+
# Things needed by bazel and to run tests
21+
22+
RUN apt-get update -qqy && \
23+
apt-get -qy install python-is-python3 \
24+
dotnet-sdk-5.0 \
25+
supervisor \
26+
x11vnc \
27+
fluxbox \
28+
xvfb && \
29+
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
30+
31+
# Browsers
32+
33+
RUN apt-get update -qqy && \
34+
apt-get -qy install google-chrome-stable firefox && \
35+
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
36+
37+
# Browser Drivers
38+
39+
RUN CHROME_MAJOR_VERSION=$(google-chrome --version | sed -E "s/.* ([0-9]+)(\.[0-9]+){3}.*/\1/") \
40+
&& CHROME_DRIVER_VERSION=$(wget --no-verbose -O - "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION}") \
41+
&& echo "Using ChromeDriver version: "$CHROME_DRIVER_VERSION \
42+
&& wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \
43+
&& rm -rf /home/gitpod/selenium/chromedriver \
44+
&& unzip /tmp/chromedriver_linux64.zip -d /home/gitpod/selenium \
45+
&& rm /tmp/chromedriver_linux64.zip \
46+
&& mv /home/gitpod/selenium/chromedriver /home/gitpod/selenium/chromedriver-$CHROME_DRIVER_VERSION \
47+
&& chmod 755 /home/gitpod/selenium/chromedriver-$CHROME_DRIVER_VERSION \
48+
&& sudo ln -fs /home/gitpod/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver
49+
50+
RUN GK_VERSION="0.31.0" \
51+
&& echo "Using GeckoDriver version: "$GK_VERSION \
52+
&& 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 \
53+
&& rm -rf /home/gitpod/selenium/geckodriver \
54+
&& tar -C /home/gitpod/selenium -zxf /tmp/geckodriver.tar.gz \
55+
&& rm /tmp/geckodriver.tar.gz \
56+
&& mv /home/gitpod/selenium/geckodriver /home/gitpod/selenium/geckodriver-$GK_VERSION \
57+
&& chmod 755 /home/gitpod/selenium/geckodriver-$GK_VERSION \
58+
&& ln -fs /home/gitpod/selenium/geckodriver-$GK_VERSION /usr/bin/geckodriver
59+
60+
# noVNC exposes VNC through a web page
61+
ENV NOVNC_TAG="1.3.0" \
62+
WEBSOCKIFY_TAG="0.10.0"
63+
64+
RUN wget -nv -O /tmp/noVNC.zip "https://github.com/novnc/noVNC/archive/refs/tags/v${NOVNC_TAG}.zip" \
65+
&& unzip -x /tmp/noVNC.zip -d /tmp \
66+
&& mv /tmp/noVNC-${NOVNC_TAG} /home/gitpod/selenium/noVNC \
67+
&& cp /home/gitpod/selenium/noVNC/vnc.html /home/gitpod/selenium/noVNC/index.html \
68+
&& rm /tmp/noVNC.zip \
69+
&& wget -nv -O /tmp/websockify.zip "https://github.com/novnc/websockify/archive/refs/tags/v${WEBSOCKIFY_TAG}.zip" \
70+
&& unzip -x /tmp/websockify.zip -d /tmp \
71+
&& rm /tmp/websockify.zip \
72+
&& mv /tmp/websockify-${WEBSOCKIFY_TAG} /home/gitpod/selenium/noVNC/utils/websockify
73+
74+
# Bazel
75+
76+
RUN curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.12.0/bazelisk-linux-amd64 -o /usr/bin/bazelisk && \
77+
chmod 755 /usr/bin/bazelisk && \
78+
ln -sf /usr/bin/bazelisk /usr/bin/bazel
79+
80+
USER gitpod
81+
82+
# Supervisor
83+
#======================================
84+
# Add Supervisor configuration file
85+
#======================================
86+
COPY scripts/gitpod/supervisord.conf /etc
87+
88+
#==============================
89+
# Scripts to run XVFB, VNC, and noVNC
90+
#==============================
91+
COPY scripts/gitpod/start-xvfb.sh \
92+
scripts/gitpod/start-vnc.sh \
93+
scripts/gitpod/start-novnc.sh \
94+
/home/gitpod/selenium/
95+
96+
# To run browser tests
97+
ENV DISPLAY :99.0
98+
ENV DISPLAY_NUM 99
99+
ENV SCREEN_WIDTH 1360
100+
ENV SCREEN_HEIGHT 1020
101+
ENV SCREEN_DEPTH 24
102+
ENV SCREEN_DPI 96
103+
ENV VNC_PORT 5900
104+
ENV NO_VNC_PORT 7900

scripts/gitpod/start-novnc.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
/home/gitpod/selenium/noVNC/utils/novnc_proxy --listen ${NO_VNC_PORT} --vnc localhost:${VNC_PORT}

scripts/gitpod/start-vnc.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
#
3+
4+
for i in $(seq 1 10)
5+
do
6+
sleep 1
7+
xdpyinfo -display ${DISPLAY} >/dev/null 2>&1
8+
if [ $? -eq 0 ]; then
9+
break
10+
fi
11+
echo "Waiting for Xvfb..."
12+
done
13+
14+
x11vnc -forever -shared -rfbport ${VNC_PORT} -rfbportv6 ${VNC_PORT} -display ${DISPLAY}

scripts/gitpod/start-xvfb.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
export GEOMETRY="${SCREEN_WIDTH}""x""${SCREEN_HEIGHT}""x""${SCREEN_DEPTH}"
4+
5+
rm -f /tmp/.X*lock
6+
7+
# Command reference
8+
# http://manpages.ubuntu.com/manpages/focal/man1/xvfb-run.1.html
9+
# http://manpages.ubuntu.com/manpages/focal/man1/Xvfb.1.html
10+
# http://manpages.ubuntu.com/manpages/focal/man1/Xserver.1.html
11+
/usr/bin/xvfb-run --server-num=${DISPLAY_NUM} \
12+
--listen-tcp \
13+
--server-args="-screen 0 ${GEOMETRY} -fbdir /var/tmp -dpi ${SCREEN_DPI} -listen tcp -noreset -ac +extension RANDR" \
14+
/usr/bin/fluxbox -display ${DISPLAY}

scripts/gitpod/supervisord.conf

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
; Documentation of this file format -> http://supervisord.org/configuration.html
2+
3+
[supervisord]
4+
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
5+
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
6+
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
7+
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
8+
loglevel=info ; (log level;default info; others: debug,warn,trace)
9+
pidfile=/var/run/supervisor/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
10+
nodaemon=false ; (start in foreground if true;default false)
11+
minfds=1024 ; (min. avail startup file descriptors;default 1024)
12+
minprocs=200 ; (min. avail process descriptors;default 200)
13+
14+
; Priority 0 - xvfb & fluxbox, 5 - x11vnc, 10 - noVNC
15+
16+
[program:xvfb]
17+
priority=0
18+
command=/home/gitpod/selenium/start-xvfb.sh
19+
autostart=true
20+
autorestart=true
21+
22+
;Logs
23+
redirect_stderr=false
24+
stdout_logfile=/var/log/supervisor/xvfb-stdout.log
25+
stderr_logfile=/var/log/supervisor/xvfb-stderr.log
26+
stdout_logfile_maxbytes=50MB
27+
stderr_logfile_maxbytes=50MB
28+
stdout_logfile_backups=5
29+
stderr_logfile_backups=5
30+
stdout_capture_maxbytes=50MB
31+
stderr_capture_maxbytes=50MB
32+
33+
[program:vnc]
34+
priority=5
35+
command=/home/gitpod/selenium/start-vnc.sh
36+
autostart=true
37+
autorestart=true
38+
39+
;Logs
40+
redirect_stderr=false
41+
stdout_logfile=/var/log/supervisor/vnc-stdout.log
42+
stderr_logfile=/var/log/supervisor/vnc-stderr.log
43+
stdout_logfile_maxbytes=50MB
44+
stderr_logfile_maxbytes=50MB
45+
stdout_logfile_backups=5
46+
stderr_logfile_backups=5
47+
stdout_capture_maxbytes=50MB
48+
stderr_capture_maxbytes=50MB
49+
50+
[program:novnc]
51+
priority=10
52+
command=/home/gitpod/selenium/start-novnc.sh
53+
autostart=true
54+
autorestart=true
55+
56+
;Logs
57+
redirect_stderr=false
58+
stdout_logfile=/var/log/supervisor/novnc-stdout.log
59+
stderr_logfile=/var/log/supervisor/novnc-stderr.log
60+
stdout_logfile_maxbytes=50MB
61+
stderr_logfile_maxbytes=50MB
62+
stdout_logfile_backups=5
63+
stderr_logfile_backups=5
64+
stdout_capture_maxbytes=50MB
65+
stderr_capture_maxbytes=50MB

0 commit comments

Comments
 (0)