Skip to content

Commit 7ab4a72

Browse files
committed
Adding a docker image for the router
1 parent a3149a3 commit 7ab4a72

File tree

8 files changed

+160
-3
lines changed

8 files changed

+160
-3
lines changed

Hub/selenium-grid-hub.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; Documentation of this file format -> http://supervisord.org/configuration.html
22

3-
[program:selenium-hub]
3+
[program:selenium-grid-hub]
44

55
priority=0
66
command=/opt/bin/start-selenium-grid-hub.sh

Makefile

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ MAJOR := $(word 1,$(subst ., ,$(VERSION)))
88
MINOR := $(word 2,$(subst ., ,$(VERSION)))
99
MAJOR_MINOR_PATCH := $(word 1,$(subst -, ,$(VERSION)))
1010

11-
all: hub distributor chrome firefox opera standalone_chrome standalone_firefox standalone_opera
11+
all: hub distributor router chrome firefox opera standalone_chrome standalone_firefox standalone_opera
1212

1313
generate_all: \
1414
generate_hub \
1515
generate_distributor \
16+
generate_router \
1617
generate_node_base \
1718
generate_chrome \
1819
generate_firefox \
@@ -38,7 +39,13 @@ generate_distributor:
3839
cd ./Distributor && ./generate.sh $(VERSION) $(NAMESPACE) $(AUTHORS)
3940

4041
distributor: base generate_distributor
41-
cd ./Hub && docker build $(BUILD_ARGS) -t $(NAME)/distributor:$(VERSION) .
42+
cd ./Distributor && docker build $(BUILD_ARGS) -t $(NAME)/distributor:$(VERSION) .
43+
44+
generate_router:
45+
cd ./Router && ./generate.sh $(VERSION) $(NAMESPACE) $(AUTHORS)
46+
47+
router: base generate_router
48+
cd ./Router && docker build $(BUILD_ARGS) -t $(NAME)/router:$(VERSION) .
4249

4350
generate_node_base:
4451
cd ./NodeBase && ./generate.sh $(VERSION) $(NAMESPACE) $(AUTHORS)
@@ -86,6 +93,7 @@ tag_latest:
8693
docker tag $(NAME)/base:$(VERSION) $(NAME)/base:latest
8794
docker tag $(NAME)/hub:$(VERSION) $(NAME)/hub:latest
8895
docker tag $(NAME)/distributor:$(VERSION) $(NAME)/distributor:latest
96+
docker tag $(NAME)/router:$(VERSION) $(NAME)/router:latest
8997
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:latest
9098
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:latest
9199
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:latest
@@ -98,6 +106,7 @@ release_latest:
98106
docker push $(NAME)/base:latest
99107
docker push $(NAME)/hub:latest
100108
docker push $(NAME)/distributor:latest
109+
docker push $(NAME)/router:latest
101110
docker push $(NAME)/node-base:latest
102111
docker push $(NAME)/node-chrome:latest
103112
docker push $(NAME)/node-firefox:latest
@@ -110,6 +119,7 @@ tag_major_minor:
110119
docker tag $(NAME)/base:$(VERSION) $(NAME)/base:$(MAJOR)
111120
docker tag $(NAME)/hub:$(VERSION) $(NAME)/hub:$(MAJOR)
112121
docker tag $(NAME)/distributor:$(VERSION) $(NAME)/distributor:$(MAJOR)
122+
docker tag $(NAME)/router:$(VERSION) $(NAME)/router:$(MAJOR)
113123
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:$(MAJOR)
114124
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:$(MAJOR)
115125
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:$(MAJOR)
@@ -120,6 +130,7 @@ tag_major_minor:
120130
docker tag $(NAME)/base:$(VERSION) $(NAME)/base:$(MAJOR).$(MINOR)
121131
docker tag $(NAME)/hub:$(VERSION) $(NAME)/hub:$(MAJOR).$(MINOR)
122132
docker tag $(NAME)/distributor:$(VERSION) $(NAME)/distributor:$(MAJOR).$(MINOR)
133+
docker tag $(NAME)/router:$(VERSION) $(NAME)/router:$(MAJOR).$(MINOR)
123134
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:$(MAJOR).$(MINOR)
124135
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:$(MAJOR).$(MINOR)
125136
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:$(MAJOR).$(MINOR)
@@ -130,6 +141,7 @@ tag_major_minor:
130141
docker tag $(NAME)/base:$(VERSION) $(NAME)/base:$(MAJOR_MINOR_PATCH)
131142
docker tag $(NAME)/hub:$(VERSION) $(NAME)/hub:$(MAJOR_MINOR_PATCH)
132143
docker tag $(NAME)/distributor:$(VERSION) $(NAME)/distributor:$(MAJOR_MINOR_PATCH)
144+
docker tag $(NAME)/router:$(VERSION) $(NAME)/router:$(MAJOR_MINOR_PATCH)
133145
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:$(MAJOR_MINOR_PATCH)
134146
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:$(MAJOR_MINOR_PATCH)
135147
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:$(MAJOR_MINOR_PATCH)
@@ -142,6 +154,7 @@ release: tag_major_minor
142154
@if ! docker images $(NAME)/base | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME)/base version $(VERSION) is not yet built. Please run 'make build'"; false; fi
143155
@if ! docker images $(NAME)/hub | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME)/hub version $(VERSION) is not yet built. Please run 'make build'"; false; fi
144156
@if ! docker images $(NAME)/distributor | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME)/distributor version $(VERSION) is not yet built. Please run 'make build'"; false; fi
157+
@if ! docker images $(NAME)/router | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME)/router version $(VERSION) is not yet built. Please run 'make build'"; false; fi
145158
@if ! docker images $(NAME)/node-base | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME)/node-base version $(VERSION) is not yet built. Please run 'make build'"; false; fi
146159
@if ! docker images $(NAME)/node-chrome | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME)/node-chrome version $(VERSION) is not yet built. Please run 'make build'"; false; fi
147160
@if ! docker images $(NAME)/node-firefox | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME)/node-firefox version $(VERSION) is not yet built. Please run 'make build'"; false; fi
@@ -152,6 +165,7 @@ release: tag_major_minor
152165
docker push $(NAME)/base:$(VERSION)
153166
docker push $(NAME)/hub:$(VERSION)
154167
docker push $(NAME)/distributor:$(VERSION)
168+
docker push $(NAME)/router:$(VERSION)
155169
docker push $(NAME)/node-base:$(VERSION)
156170
docker push $(NAME)/node-chrome:$(VERSION)
157171
docker push $(NAME)/node-firefox:$(VERSION)
@@ -162,6 +176,7 @@ release: tag_major_minor
162176
docker push $(NAME)/base:$(MAJOR)
163177
docker push $(NAME)/hub:$(MAJOR)
164178
docker push $(NAME)/distributor:$(MAJOR)
179+
docker push $(NAME)/router:$(MAJOR)
165180
docker push $(NAME)/node-base:$(MAJOR)
166181
docker push $(NAME)/node-chrome:$(MAJOR)
167182
docker push $(NAME)/node-firefox:$(MAJOR)
@@ -172,6 +187,7 @@ release: tag_major_minor
172187
docker push $(NAME)/base:$(MAJOR).$(MINOR)
173188
docker push $(NAME)/hub:$(MAJOR).$(MINOR)
174189
docker push $(NAME)/distributor:$(MAJOR).$(MINOR)
190+
docker push $(NAME)/router:$(MAJOR).$(MINOR)
175191
docker push $(NAME)/node-base:$(MAJOR).$(MINOR)
176192
docker push $(NAME)/node-chrome:$(MAJOR).$(MINOR)
177193
docker push $(NAME)/node-firefox:$(MAJOR).$(MINOR)
@@ -182,6 +198,7 @@ release: tag_major_minor
182198
docker push $(NAME)/base:$(MAJOR_MINOR_PATCH)
183199
docker push $(NAME)/hub:$(MAJOR_MINOR_PATCH)
184200
docker push $(NAME)/distributor:$(MAJOR_MINOR_PATCH)
201+
docker push $(NAME)/router:$(MAJOR_MINOR_PATCH)
185202
docker push $(NAME)/node-base:$(MAJOR_MINOR_PATCH)
186203
docker push $(NAME)/node-chrome:$(MAJOR_MINOR_PATCH)
187204
docker push $(NAME)/node-firefox:$(MAJOR_MINOR_PATCH)
@@ -227,6 +244,7 @@ test_opera_standalone:
227244
generate_all \
228245
generate_hub \
229246
generate_distributor \
247+
generate_router \
230248
generate_node_base \
231249
generate_chrome \
232250
generate_firefox \
@@ -236,6 +254,7 @@ test_opera_standalone:
236254
generate_standalone_opera \
237255
hub \
238256
distributor \
257+
router \
239258
node_base \
240259
release \
241260
standalone_chrome \

Router/Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2+
# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED.
3+
# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE
4+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5+
FROM selenium/base:4.0.0-alpha-5-20200326
6+
LABEL authors=SeleniumHQ
7+
8+
USER seluser
9+
10+
#========================
11+
# Selenium Configuration
12+
#========================
13+
14+
EXPOSE 4442
15+
EXPOSE 4443
16+
EXPOSE 4444
17+
18+
# As integer, maps to "maxSession"
19+
ENV GRID_MAX_SESSION 5
20+
# In milliseconds, maps to "newSessionWaitTimeout"
21+
ENV GRID_NEW_SESSION_WAIT_TIMEOUT -1
22+
# As a boolean, maps to "throwOnCapabilityNotPresent"
23+
ENV GRID_THROW_ON_CAPABILITY_NOT_PRESENT true
24+
# As an integer
25+
ENV GRID_JETTY_MAX_THREADS -1
26+
# In milliseconds, maps to "cleanUpCycle"
27+
ENV GRID_CLEAN_UP_CYCLE 5000
28+
# In seconds, maps to "browserTimeout"
29+
ENV GRID_BROWSER_TIMEOUT 0
30+
# In seconds, maps to "timeout"
31+
ENV GRID_TIMEOUT 1800
32+
# Debug
33+
ENV GRID_DEBUG false
34+
# As integer, maps to "port"
35+
ENV GRID_HUB_PORT 4444
36+
# As string, maps to "host"
37+
ENV GRID_HUB_HOST "0.0.0.0"
38+
39+
COPY generate_config \
40+
start-selenium-grid-router.sh \
41+
/opt/bin/
42+
43+
COPY selenium-grid-router.conf /etc/supervisor/conf.d/
44+
45+
RUN /opt/bin/generate_config > /opt/selenium/config.json

Router/Dockerfile.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
USER seluser
2+
3+
#========================
4+
# Selenium Configuration
5+
#========================
6+
7+
EXPOSE 4442
8+
EXPOSE 4443
9+
EXPOSE 4444
10+
11+
# As integer, maps to "maxSession"
12+
ENV GRID_MAX_SESSION 5
13+
# In milliseconds, maps to "newSessionWaitTimeout"
14+
ENV GRID_NEW_SESSION_WAIT_TIMEOUT -1
15+
# As a boolean, maps to "throwOnCapabilityNotPresent"
16+
ENV GRID_THROW_ON_CAPABILITY_NOT_PRESENT true
17+
# As an integer
18+
ENV GRID_JETTY_MAX_THREADS -1
19+
# In milliseconds, maps to "cleanUpCycle"
20+
ENV GRID_CLEAN_UP_CYCLE 5000
21+
# In seconds, maps to "browserTimeout"
22+
ENV GRID_BROWSER_TIMEOUT 0
23+
# In seconds, maps to "timeout"
24+
ENV GRID_TIMEOUT 1800
25+
# Debug
26+
ENV GRID_DEBUG false
27+
# As integer, maps to "port"
28+
ENV GRID_HUB_PORT 4444
29+
# As string, maps to "host"
30+
ENV GRID_HUB_HOST "0.0.0.0"
31+
32+
COPY generate_config \
33+
start-selenium-grid-router.sh \
34+
/opt/bin/
35+
36+
COPY selenium-grid-router.conf /etc/supervisor/conf.d/
37+
38+
RUN /opt/bin/generate_config > /opt/selenium/config.json

Router/generate.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
VERSION=$1
4+
NAMESPACE=$2
5+
AUTHORS=$3
6+
7+
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" > ./Dockerfile
8+
echo "# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED." >> ./Dockerfile
9+
echo "# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE" >> ./Dockerfile
10+
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> ./Dockerfile
11+
echo FROM ${NAMESPACE}/base:${VERSION} >> ./Dockerfile
12+
echo LABEL authors="$AUTHORS" >> ./Dockerfile
13+
echo "" >> ./Dockerfile
14+
cat ./Dockerfile.txt >> ./Dockerfile

Router/generate_config

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
cat <<_EOF
4+
{
5+
"host": "${GRID_HUB_HOST}",
6+
"port": ${GRID_HUB_PORT},
7+
"role": "hub",
8+
"maxSession": ${GRID_MAX_SESSION},
9+
"newSessionWaitTimeout": ${GRID_NEW_SESSION_WAIT_TIMEOUT},
10+
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
11+
"throwOnCapabilityNotPresent": ${GRID_THROW_ON_CAPABILITY_NOT_PRESENT},
12+
"jettyMaxThreads": ${GRID_JETTY_MAX_THREADS},
13+
"cleanUpCycle": ${GRID_CLEAN_UP_CYCLE},
14+
"browserTimeout": ${GRID_BROWSER_TIMEOUT},
15+
"timeout": ${GRID_TIMEOUT},
16+
"debug": ${GRID_DEBUG}
17+
}
18+
_EOF

Router/selenium-grid-router.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; Documentation of this file format -> http://supervisord.org/configuration.html
2+
3+
[program:selenium-grid-router]
4+
5+
priority=0
6+
command=/opt/bin/start-selenium-grid-router.sh
7+
autostart=true
8+
autorestart=false
9+
startsecs=0
10+
startretries=0
11+
12+
;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs"
13+
redirect_stderr=true
14+
stdout_logfile=/dev/stdout
15+
stdout_logfile_maxbytes=0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
# set -e: exit asap if a command exits with a non-zero status
4+
set -e
5+
6+
echo "Starting Selenium Grid Router..."
7+
8+
java -jar /opt/selenium/selenium-server.jar router

0 commit comments

Comments
 (0)