Skip to content
This repository was archived by the owner on Jan 7, 2019. It is now read-only.

Commit 6aa372e

Browse files
1 parent daa3b77 commit 6aa372e

File tree

4 files changed

+152
-1
lines changed

4 files changed

+152
-1
lines changed

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ services:
1818
- ./pure-ftpd:/etc/pure-ftpd/passwd
1919

2020
selenium:
21-
image: selenium/standalone-firefox-debug:3.9.1
21+
build:
22+
context: selenium
2223
ports:
2324
- "5900:5900"
2425
volumes:

selenium/Dockerfile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Build
2+
FROM selenium/node-base:3.9.1
3+
4+
USER root
5+
6+
# VNC
7+
RUN apt-get update -qqy \
8+
&& apt-get -qqy install \
9+
x11vnc \
10+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
11+
12+
# Locale settings
13+
ENV LANGUAGE en_US.UTF-8
14+
ENV LANG en_US.UTF-8
15+
RUN locale-gen en_US.UTF-8 \
16+
&& dpkg-reconfigure --frontend noninteractive locales \
17+
&& apt-get update -qqy \
18+
&& apt-get -qqy --no-install-recommends install \
19+
language-pack-en \
20+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
21+
22+
# Fonts
23+
RUN apt-get update -qqy \
24+
&& apt-get -qqy --no-install-recommends install \
25+
fonts-ipafont-gothic \
26+
xfonts-100dpi \
27+
xfonts-75dpi \
28+
xfonts-cyrillic \
29+
xfonts-scalable \
30+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
31+
32+
# fluxbox
33+
# A fast, lightweight and responsive window manager
34+
RUN apt-get update -qqy \
35+
&& apt-get -qqy install \
36+
fluxbox \
37+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
38+
39+
# Generating the VNC password as seluser
40+
# So the service can be started with seluser
41+
USER seluser
42+
RUN mkdir -p ~/.vnc \
43+
&& x11vnc -storepasswd password ~/.vnc/passwd
44+
45+
# Scripts to run Selenium Node
46+
COPY entry_point.sh /opt/bin/entry_point.sh
47+
48+
EXPOSE 5900
49+
50+
# Firefox
51+
USER root
52+
RUN apt-get update -qqy \
53+
&& apt-get -qqy --no-install-recommends install firefox \
54+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
55+
&& wget -qO- "https://download.mozilla.org/?product=firefox-devedition-latest-ssl&os=linux64&lang=en-US" | tar -C /opt -xj \
56+
&& mv /opt/firefox /opt/firefox-devedition \
57+
&& ln -fs /opt/firefox-devedition/firefox /usr/bin/firefox
58+
59+
# GeckoDriver
60+
RUN apt-get update -qqy \
61+
&& apt-get -qqy --no-install-recommends install \
62+
jq \
63+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
64+
&& GK_VERSION=$(wget -qO- "https://api.github.com/repos/mozilla/geckodriver/releases/latest" | jq --raw-output .tag_name | tr --delete v) \
65+
&& apt-get purge -qqy jq \
66+
&& wget -qO- https://github.com/mozilla/geckodriver/releases/download/v$GK_VERSION/geckodriver-v$GK_VERSION-linux64.tar.gz | tar -C /opt -zx \
67+
&& mv /opt/geckodriver /opt/geckodriver-$GK_VERSION \
68+
&& chmod 755 /opt/geckodriver-$GK_VERSION \
69+
&& ln -fs /opt/geckodriver-$GK_VERSION /usr/bin/geckodriver
70+
71+
USER seluser
72+
73+
COPY generate_config.sh /opt/bin/generate_config.sh
74+
75+
# Generating a default config during build time
76+
RUN /opt/bin/generate_config.sh > /opt/selenium/config.json

selenium/entry_point.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
source /opt/bin/functions.sh
4+
5+
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"
6+
7+
function shutdown {
8+
kill -s SIGTERM $NODE_PID
9+
wait $NODE_PID
10+
}
11+
12+
if [ ! -z "$SE_OPTS" ]; then
13+
echo "appending selenium options: ${SE_OPTS}"
14+
fi
15+
16+
rm -f /tmp/.X*lock
17+
18+
SERVERNUM=$(get_server_num)
19+
20+
DISPLAY=$DISPLAY \
21+
xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
22+
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
23+
${SE_OPTS} &
24+
NODE_PID=$!
25+
26+
trap shutdown SIGTERM SIGINT
27+
for i in $(seq 1 10)
28+
do
29+
xdpyinfo -display $DISPLAY >/dev/null 2>&1
30+
if [ $? -eq 0 ]; then
31+
break
32+
fi
33+
echo Waiting xvfb...
34+
sleep 0.5
35+
done
36+
37+
fluxbox -display $DISPLAY &
38+
39+
x11vnc -forever -usepw -shared -rfbport 5900 -display $DISPLAY &
40+
41+
wait $NODE_PID

selenium/generate_config.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
FIREFOX_VERSION="$(firefox --version | cut -d " " -f 3)"
4+
DRIVER_LOGLEVEL="${DRIVER_LOGLEVEL:-info}"
5+
6+
cat <<EOF
7+
{
8+
"capabilities": [
9+
{
10+
"version": "$FIREFOX_VERSION",
11+
"browserName": "firefox",
12+
"maxInstances": $NODE_MAX_INSTANCES,
13+
"seleniumProtocol": "WebDriver",
14+
"applicationName": "$NODE_APPLICATION_NAME",
15+
"moz:firefoxOptions":
16+
{
17+
"log":
18+
{
19+
"level": "$DRIVER_LOGLEVEL"
20+
}
21+
}
22+
}
23+
],
24+
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
25+
"maxSession": $NODE_MAX_SESSION,
26+
"port": $NODE_PORT,
27+
"register": true,
28+
"registerCycle": $NODE_REGISTER_CYCLE,
29+
"nodePolling": $NODE_POLLING,
30+
"unregisterIfStillDownAfter": $NODE_UNREGISTER_IF_STILL_DOWN_AFTER,
31+
"downPollingLimit": $NODE_DOWN_POLLING_LIMIT
32+
}
33+
EOF

0 commit comments

Comments
 (0)