Skip to content

Commit 5e4504d

Browse files
committed
Adding a docker image for the sessions
1 parent 7ab4a72 commit 5e4504d

File tree

7 files changed

+158
-1
lines changed

7 files changed

+158
-1
lines changed

Makefile

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

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

1313
generate_all: \
1414
generate_hub \
1515
generate_distributor \
1616
generate_router \
17+
generate_sessions \
1718
generate_node_base \
1819
generate_chrome \
1920
generate_firefox \
@@ -47,6 +48,12 @@ generate_router:
4748
router: base generate_router
4849
cd ./Router && docker build $(BUILD_ARGS) -t $(NAME)/router:$(VERSION) .
4950

51+
generate_sessions:
52+
cd ./Sessions && ./generate.sh $(VERSION) $(NAMESPACE) $(AUTHORS)
53+
54+
sessions: base generate_sessions
55+
cd ./Sessions && docker build $(BUILD_ARGS) -t $(NAME)/sessions:$(VERSION) .
56+
5057
generate_node_base:
5158
cd ./NodeBase && ./generate.sh $(VERSION) $(NAMESPACE) $(AUTHORS)
5259

@@ -94,6 +101,7 @@ tag_latest:
94101
docker tag $(NAME)/hub:$(VERSION) $(NAME)/hub:latest
95102
docker tag $(NAME)/distributor:$(VERSION) $(NAME)/distributor:latest
96103
docker tag $(NAME)/router:$(VERSION) $(NAME)/router:latest
104+
docker tag $(NAME)/sessions:$(VERSION) $(NAME)/sessions:latest
97105
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:latest
98106
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:latest
99107
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:latest
@@ -107,6 +115,7 @@ release_latest:
107115
docker push $(NAME)/hub:latest
108116
docker push $(NAME)/distributor:latest
109117
docker push $(NAME)/router:latest
118+
docker push $(NAME)/sessions:latest
110119
docker push $(NAME)/node-base:latest
111120
docker push $(NAME)/node-chrome:latest
112121
docker push $(NAME)/node-firefox:latest
@@ -120,6 +129,7 @@ tag_major_minor:
120129
docker tag $(NAME)/hub:$(VERSION) $(NAME)/hub:$(MAJOR)
121130
docker tag $(NAME)/distributor:$(VERSION) $(NAME)/distributor:$(MAJOR)
122131
docker tag $(NAME)/router:$(VERSION) $(NAME)/router:$(MAJOR)
132+
docker tag $(NAME)/sessions:$(VERSION) $(NAME)/sessions:$(MAJOR)
123133
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:$(MAJOR)
124134
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:$(MAJOR)
125135
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:$(MAJOR)
@@ -131,6 +141,7 @@ tag_major_minor:
131141
docker tag $(NAME)/hub:$(VERSION) $(NAME)/hub:$(MAJOR).$(MINOR)
132142
docker tag $(NAME)/distributor:$(VERSION) $(NAME)/distributor:$(MAJOR).$(MINOR)
133143
docker tag $(NAME)/router:$(VERSION) $(NAME)/router:$(MAJOR).$(MINOR)
144+
docker tag $(NAME)/sessions:$(VERSION) $(NAME)/sessions:$(MAJOR).$(MINOR)
134145
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:$(MAJOR).$(MINOR)
135146
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:$(MAJOR).$(MINOR)
136147
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:$(MAJOR).$(MINOR)
@@ -142,6 +153,7 @@ tag_major_minor:
142153
docker tag $(NAME)/hub:$(VERSION) $(NAME)/hub:$(MAJOR_MINOR_PATCH)
143154
docker tag $(NAME)/distributor:$(VERSION) $(NAME)/distributor:$(MAJOR_MINOR_PATCH)
144155
docker tag $(NAME)/router:$(VERSION) $(NAME)/router:$(MAJOR_MINOR_PATCH)
156+
docker tag $(NAME)/sessions:$(VERSION) $(NAME)/sessions:$(MAJOR_MINOR_PATCH)
145157
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:$(MAJOR_MINOR_PATCH)
146158
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:$(MAJOR_MINOR_PATCH)
147159
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:$(MAJOR_MINOR_PATCH)
@@ -155,6 +167,7 @@ release: tag_major_minor
155167
@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
156168
@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
157169
@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
170+
@if ! docker images $(NAME)/sessions | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME)/sessions version $(VERSION) is not yet built. Please run 'make build'"; false; fi
158171
@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
159172
@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
160173
@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
@@ -166,6 +179,7 @@ release: tag_major_minor
166179
docker push $(NAME)/hub:$(VERSION)
167180
docker push $(NAME)/distributor:$(VERSION)
168181
docker push $(NAME)/router:$(VERSION)
182+
docker push $(NAME)/sessions:$(VERSION)
169183
docker push $(NAME)/node-base:$(VERSION)
170184
docker push $(NAME)/node-chrome:$(VERSION)
171185
docker push $(NAME)/node-firefox:$(VERSION)
@@ -177,6 +191,7 @@ release: tag_major_minor
177191
docker push $(NAME)/hub:$(MAJOR)
178192
docker push $(NAME)/distributor:$(MAJOR)
179193
docker push $(NAME)/router:$(MAJOR)
194+
docker push $(NAME)/sessions:$(MAJOR)
180195
docker push $(NAME)/node-base:$(MAJOR)
181196
docker push $(NAME)/node-chrome:$(MAJOR)
182197
docker push $(NAME)/node-firefox:$(MAJOR)
@@ -188,6 +203,7 @@ release: tag_major_minor
188203
docker push $(NAME)/hub:$(MAJOR).$(MINOR)
189204
docker push $(NAME)/distributor:$(MAJOR).$(MINOR)
190205
docker push $(NAME)/router:$(MAJOR).$(MINOR)
206+
docker push $(NAME)/sessions:$(MAJOR).$(MINOR)
191207
docker push $(NAME)/node-base:$(MAJOR).$(MINOR)
192208
docker push $(NAME)/node-chrome:$(MAJOR).$(MINOR)
193209
docker push $(NAME)/node-firefox:$(MAJOR).$(MINOR)
@@ -199,6 +215,7 @@ release: tag_major_minor
199215
docker push $(NAME)/hub:$(MAJOR_MINOR_PATCH)
200216
docker push $(NAME)/distributor:$(MAJOR_MINOR_PATCH)
201217
docker push $(NAME)/router:$(MAJOR_MINOR_PATCH)
218+
docker push $(NAME)/sessions:$(MAJOR_MINOR_PATCH)
202219
docker push $(NAME)/node-base:$(MAJOR_MINOR_PATCH)
203220
docker push $(NAME)/node-chrome:$(MAJOR_MINOR_PATCH)
204221
docker push $(NAME)/node-firefox:$(MAJOR_MINOR_PATCH)
@@ -245,6 +262,7 @@ test_opera_standalone:
245262
generate_hub \
246263
generate_distributor \
247264
generate_router \
265+
generate_sessions \
248266
generate_node_base \
249267
generate_chrome \
250268
generate_firefox \
@@ -255,6 +273,7 @@ test_opera_standalone:
255273
hub \
256274
distributor \
257275
router \
276+
sessions \
258277
node_base \
259278
release \
260279
standalone_chrome \

Sessions/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-sessions.sh \
41+
/opt/bin/
42+
43+
COPY selenium-grid-sessions.conf /etc/supervisor/conf.d/
44+
45+
RUN /opt/bin/generate_config > /opt/selenium/config.json

Sessions/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-sessions.sh \
34+
/opt/bin/
35+
36+
COPY selenium-grid-sessions.conf /etc/supervisor/conf.d/
37+
38+
RUN /opt/bin/generate_config > /opt/selenium/config.json

Sessions/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

Sessions/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
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-sessions]
4+
5+
priority=0
6+
command=/opt/bin/start-selenium-grid-sessions.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 Sessions..."
7+
8+
java -jar /opt/selenium/selenium-server.jar sessions

0 commit comments

Comments
 (0)