Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit a9624ff

Browse files
committed
Include and improve host-scripts inside the docker image
1 parent e345441 commit a9624ff

File tree

5 files changed

+91
-36
lines changed

5 files changed

+91
-36
lines changed

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Note sha256 digests are generated after pushing the image to the registry theref
44

55
Note image ids also change after scm-source.json has being updated which triggers a cyclic problem so value TBD will be set here and updated in the [release][] page by navigating into any release tag.
66

7-
## 2.47.1b (2015-08-03)
7+
## 2.47.1c (2015-08-03)
88
+ Upgrade chromedriver from 2.16 to 2.17 (Leo Gallucci)
99
+ Upgrade chrome unstable from 45 to 46.0.2467.2
10-
+ Include host-scripts inside the docker iamge
10+
+ Include and improve host-scripts inside the docker image
1111
+ Reorganize packages installation order
1212
+ Image tag details:
1313
+ Selenium: v2.47.1 (411b314)
@@ -24,8 +24,8 @@ Note image ids also change after scm-source.json has being updated which trigger
2424
+ Built with: Docker version 1.7.1, build 786b29d
2525
+ FROM ubuntu:wily-20150708
2626
+ Python: 2.7.10
27-
+ Image ID: eb7175aa47fac34f1f29ffc372cd9e6f52d3a3fe6218f2f760cef7e5047705a0
28-
+ Digest: sha256:ca7b8c9d1a8df59974b3dcb81499339cd3f46b5cda1934ba14c3b5f95c1ecba2
27+
+ Image ID: TBD
28+
+ Digest: sha256:TBD
2929

3030
## 2.47.1a (2015-07-30)
3131
+ Upgrade selenium from 2.46.0 to 2.47.1 (Leo Gallucci)

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Note SeleniumHQ/docker-selenium project is more useful for building selenium gri
1919
In general: add `sudo` only if needed in your environment and `--privileged` if you really need it.
2020

2121
sudo docker run --privileged -p 4444:24444 -p 5920:25900 \
22-
-e VNC_PASSWORD=hola elgalu/selenium:2.47.1b
22+
-e VNC_PASSWORD=hola elgalu/selenium:2.47.1c
2323

2424
### Non-privileged
2525
### Run
@@ -31,7 +31,7 @@ If your setup is correct, privileged mode and sudo should not be necessary:
3131
-e SCREEN_WIDTH=1920 -e SCREEN_HEIGHT=1080 \
3232
-e VNC_PASSWORD=hola \
3333
-e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" \
34-
elgalu/selenium:2.47.1b
34+
elgalu/selenium:2.47.1c
3535

3636
Make sure `docker run` finishes with **selenium all done and ready for testing** else you won't be able to start your tests. To perform this check programatically please use this command where `ch` is the name of the container:
3737

@@ -96,7 +96,7 @@ You can lunch a grid only container via environment variables:
9696

9797
docker run --rm --name=hub -p 4444:24444 -p 5930:25900 -p 2223:22222 \
9898
-p=6081:26080 -e CHROME=false -e FIREFOX=false \
99-
elgalu/selenium:2.47.1b
99+
elgalu/selenium:2.47.1c
100100

101101
The important part above is `-e CHROME=false -e FIREFOX=false` which tells the docker image not run run default chorme and firefox nodes turning the container into a grid-only one.
102102

@@ -112,7 +112,7 @@ You can lunch a node only container via environment variables:
112112
-p 25550:25550 -p 25551:25551 \
113113
-e GRID=false -e CHROME=true -e FIREFOX=true \
114114
-v $(pwd)/videos:/videos \
115-
elgalu/selenium:2.47.1b
115+
elgalu/selenium:2.47.1c
116116

117117
The important part above is `-e GRID=false` which tells the container to be a node-only node, this this case with 2 browsers `-e CHROME=true -e FIREFOX=true` but could be just 1.
118118

@@ -137,9 +137,9 @@ There are also additional steps you can take to ensure you're using the correct
137137

138138
You can simply verify that image id is indeed the correct one.
139139

140-
# e.g. full image id for tag 2.47.1b
141-
export IMGID=eb7175aa47fac34f1f29ffc372cd9e6f52d3a3fe6218f2f760cef7e5047705a0
142-
if docker inspect -f='{{.Id}}' elgalu/selenium:2.47.1b |grep ${IMGID} &> /dev/null; then
140+
# e.g. full image id for tag 2.47.1c
141+
export IMGID=TBD
142+
if docker inspect -f='{{.Id}}' elgalu/selenium:2.47.1c |grep ${IMGID} &> /dev/null; then
143143
echo "Image ID tested ok"
144144
else
145145
echo "Image ID doesn't match"
@@ -149,8 +149,8 @@ You can simply verify that image id is indeed the correct one.
149149

150150
Given docker.io currently allows to push the same tag image twice this represent a security concern but since docker >= 1.6.2 is possible to fetch the digest sha256 instead of the tag so you can be sure you're using the exact same docker image every time:
151151

152-
# e.g. sha256 for tag 2.47.1b
153-
export SHA=ca7b8c9d1a8df59974b3dcb81499339cd3f46b5cda1934ba14c3b5f95c1ecba2
152+
# e.g. sha256 for tag 2.47.1c
153+
export SHA=TBD
154154
docker pull elgalu/selenium@sha256:${SHA}
155155

156156
You can find all digests sha256 and image ids per tag in the [CHANGELOG](./CHANGELOG.md) so as of now you just need to trust the sha256 in the CHANGELOG. Bullet proof is to fork this project and build the images yourself if security is a big concern.
@@ -169,7 +169,7 @@ Host machine, terminal 2:
169169
docker run --rm --name=ch -p=4470:24444 \
170170
-e SCREEN_WIDTH -e SCREEN_HEIGHT -e XE_DISP_NUM \
171171
-v /tmp/.X11-unix/X${XE_DISP_NUM}:/tmp/.X11-unix/X${XE_DISP_NUM} \
172-
elgalu/selenium:2.47.1b
172+
elgalu/selenium:2.47.1c
173173

174174
Now when you run your tests instead of connecting. If docker run fails try `xhost +`
175175

@@ -191,7 +191,7 @@ ANYPORT=0
191191
REMOTE_DOCKER_SRV=localhost
192192
CONTAINER=$(docker run -d -p=0.0.0.0:${ANYPORT}:22222 -p=0.0.0.0:${ANYPORT}:24444 \
193193
-p=0.0.0.0:${ANYPORT}:25900 -e SCREEN_HEIGHT=1110 -e VNC_PASSWORD=hola \
194-
-e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" elgalu/selenium:2.47.1b
194+
-e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" elgalu/selenium:2.47.1c
195195
196196
# -- Option 2.docker run- Running docker on remote docker server like in the cloud
197197
# Useful if the docker server is running in the cloud. Establish free local ports
@@ -201,7 +201,7 @@ ssh ${REMOTE_DOCKER_SRV} #get into the remote docker provider somehow
201201
# it acts as a jump host so my public key is already on that server
202202
CONTAINER=$(docker run -d -p=0.0.0.0:${ANYPORT}:22222 -e SCREEN_HEIGHT=1110 \
203203
-e VNC_PASSWORD=hola -e SSH_AUTH_KEYS="$(cat ~/.ssh/authorized_keys)" \
204-
elgalu/selenium:2.47.1b
204+
elgalu/selenium:2.47.1c
205205
206206
# -- Common: Wait for the container to start
207207
./host-scripts/wait-docker-selenium.sh ch 7s
@@ -272,7 +272,7 @@ If you git clone this repo locally, i.e. cd into where the Dockerfile is, you ca
272272
273273
If you prefer to download the final built image from docker you can pull it, personally I always prefer to build them manually except for the base images like Ubuntu 14.04.2:
274274
275-
docker pull elgalu/selenium:2.47.1b
275+
docker pull elgalu/selenium:2.47.1c
276276
277277
#### 2. Use this image
278278

READMELeo.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
## Build
22

3-
time (docker build -t="elgalu/selenium:2.47.1b" . ;echo $?;beep)
4-
docker run --rm -ti -m 2000M --cpu-quota=90000 --name=ch -p=4470:24444 -p=5920:25900 -p=2222:22222 -p=6080:26080 -p=29001:29001 -e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" -v $(pwd)/videos:/videos -e DISABLE_ROLLBACK=true -e VIDEO=true -e VIDEO_FILE_NAME=hola -e MEM_JAVA="1024m" -e WAIT_TIMEOUT="20s" elgalu/selenium:2.47.1b
3+
time (docker build -t="elgalu/selenium:2.47.1c" . ;echo $?;beep)
4+
docker run --rm -ti -m 2000M --cpu-quota=90000 --name=ch -p=4470:24444 -p=5920:25900 -p=2222:22222 -p=6080:26080 -p=29001:29001 -e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" -v $(pwd)/videos:/videos -e DISABLE_ROLLBACK=true -e VIDEO=true -e VIDEO_FILE_NAME=hola -e MEM_JAVA="1024m" -e WAIT_TIMEOUT="20s" elgalu/selenium:2.47.1c
55

66
See logs
77

88
docker exec -ti ch bash -c "ls -lah /var/log/sele/"
99

1010
Testing in ssh [email protected]
1111

12-
docker run --rm --name=ch -p=4470:24444 -p=5920:25900 -p=2222:22222 -e SSH_AUTH_KEYS="$(cat ~/.ssh/authorized_keys)" -e VNC_PASSWORD=Hola3 os-registry.stups.zalan.do/tip/selenium:2.47.1b
12+
docker run --rm --name=ch -p=4470:24444 -p=5920:25900 -p=2222:22222 -e SSH_AUTH_KEYS="$(cat ~/.ssh/authorized_keys)" -e VNC_PASSWORD=Hola3 os-registry.stups.zalan.do/tip/selenium:2.47.1c
1313

1414
## Transfer used browser source artifacts to keep them in the cloud
1515

@@ -32,18 +32,18 @@ List firefox versions via docker exe
3232

3333
## To update image id and digest
3434

35-
docker inspect -f='{{.Id}}' elgalu/selenium:2.47.1b
35+
docker inspect -f='{{.Id}}' elgalu/selenium:2.47.1c
3636
docker images --digests
3737

3838
## Run with shared dir
3939

4040
docker run --rm --name=ch -p=127.0.0.1:4460:24444 -p=127.0.0.1:5910:25900 \
41-
-v /e2e/uploads:/e2e/uploads elgalu/selenium:2.47.1b
41+
-v /e2e/uploads:/e2e/uploads elgalu/selenium:2.47.1c
4242
docker run --rm --name=ch -p=4460:24444 -p=5910:25900 \
43-
-v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):$(which docker) elgalu/selenium:2.47.1b
43+
-v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):$(which docker) elgalu/selenium:2.47.1c
4444

4545

46-
docker run --rm --name=ff -p=127.0.0.1:4461:24444 -p=127.0.0.1:5911:25900 -v /e2e/uploads:/e2e/uploads elgalu/selenium:2.47.1b
46+
docker run --rm --name=ff -p=127.0.0.1:4461:24444 -p=127.0.0.1:5911:25900 -v /e2e/uploads:/e2e/uploads elgalu/selenium:2.47.1c
4747

4848
## Run without shared dir and bind ports to all network interfaces
4949

@@ -66,11 +66,11 @@ List firefox versions via docker exe
6666
## Run without dir and bind to all interfaces
6767
Note anything after the image will be taken as arguments for the cmd/entrypoint
6868

69-
docker run --rm --name=ch -p=0.0.0.0:8813:8484 -p=0.0.0.0:2222:2222 -p=0.0.0.0:4470:24444 -p=0.0.0.0:5920:25900 -e SCREEN_WIDTH=1800 -e SCREEN_HEIGHT=1110 -e VNC_PASSWORD=hola -e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" elgalu/selenium:2.47.1b
69+
docker run --rm --name=ch -p=0.0.0.0:8813:8484 -p=0.0.0.0:2222:2222 -p=0.0.0.0:4470:24444 -p=0.0.0.0:5920:25900 -e SCREEN_WIDTH=1800 -e SCREEN_HEIGHT=1110 -e VNC_PASSWORD=hola -e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" elgalu/selenium:2.47.1c
7070

71-
docker run --rm --name=ch -p=4470:24444 -p=5920:25900 -e VNC_PASSWORD=hola elgalu/selenium:2.47.1b
72-
docker run --rm --name=ch -p=4470:24444 -p=5920:25900 -e VNC_PASSWORD=hola docker.io/elgalu/selenium:2.47.1b
73-
docker run --rm --name=ch -p=0.0.0.0:4470:24444 -p=0.0.0.0:5920:25900 --add-host myserver.dev:172.17.42.1 elgalu/selenium:2.47.1b
71+
docker run --rm --name=ch -p=4470:24444 -p=5920:25900 -e VNC_PASSWORD=hola elgalu/selenium:2.47.1c
72+
docker run --rm --name=ch -p=4470:24444 -p=5920:25900 -e VNC_PASSWORD=hola docker.io/elgalu/selenium:2.47.1c
73+
docker run --rm --name=ch -p=0.0.0.0:4470:24444 -p=0.0.0.0:5920:25900 --add-host myserver.dev:172.17.42.1 elgalu/selenium:2.47.1c
7474

7575
However adding a custom host IP to server-selenium.local (e.g. bsele ssh config) is more work:
7676

@@ -79,32 +79,32 @@ However adding a custom host IP to server-selenium.local (e.g. bsele ssh config)
7979

8080
vncv localhost:5920 -Scaling=60% &
8181

82-
docker run --rm --name=ff -p=0.0.0.0:4471:24444 -p=0.0.0.0:5921:25900 elgalu/selenium:2.47.1b
82+
docker run --rm --name=ff -p=0.0.0.0:4471:24444 -p=0.0.0.0:5921:25900 elgalu/selenium:2.47.1c
8383

8484
Automatic builds not working for me right now, maybe there is an issue with docker registry v1 vs v2
8585
https://registry.hub.docker.com/u/elgalu/docker-selenium/builds_history/31621/
8686

8787
## Push version
8888

8989
docker login
90-
docker push docker.io/elgalu/selenium:2.47.1b ;echo $?;beep
91-
docker tag elgalu/selenium:2.47.1b elgalu/selenium:latest
90+
docker push docker.io/elgalu/selenium:2.47.1c ;echo $?;beep
91+
docker tag elgalu/selenium:2.47.1c elgalu/selenium:latest
9292
docker push docker.io/elgalu/selenium:latest
9393

9494
Not working maybe because it has automated builds enabled but then it fails in the cloud but works locally
9595
https://registry.hub.docker.com/u/elgalu/selenium/tags/manage/
9696

97-
docker push elgalu/selenium:2.47.1b
98-
docker push elgalu/docker-selenium:2.47.1b
99-
docker push docker.io/elgalu/docker-selenium:2.47.1b
97+
docker push elgalu/selenium:2.47.1c
98+
docker push elgalu/docker-selenium:2.47.1c
99+
docker push docker.io/elgalu/docker-selenium:2.47.1c
100100

101101
## Pulling
102102

103-
docker pull registry.hub.docker.com/elgalu/selenium:2.47.1b
103+
docker pull registry.hub.docker.com/elgalu/selenium:2.47.1c
104104

105105
## Pull
106106

107-
docker run -d --name=max -p=0.0.0.0:4411:24444 -p=0.0.0.0:5911:25900 elgalu/selenium:2.47.1b
107+
docker run -d --name=max -p=0.0.0.0:4411:24444 -p=0.0.0.0:5911:25900 elgalu/selenium:2.47.1c
108108

109109
How to connect through vnc (need a vnc client)
110110

xterm/bin/timeout-wait-xterm.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
# Exit immediately if a command exits with a non-zero status
4+
set -e
5+
6+
# echo fn that outputs to stderr http://stackoverflow.com/a/2990533/511069
7+
echoerr() {
8+
cat <<< "$@" 1>&2;
9+
}
10+
11+
# print error and exit
12+
die () {
13+
echoerr "ERROR: $1"
14+
# if $2 is defined AND NOT EMPTY, use $2; otherwise, set to "3"
15+
errnum=${2-3}
16+
exit $errnum
17+
}
18+
19+
# if $1 is defined AND NOT EMPTY, use $1; otherwise, set to "7s"
20+
WAIT_TIMEOUT=${1-7s}
21+
LOOP_SCRIPT_PATH="/bin-utils/wait-xterm.sh"
22+
23+
if [ ! -f "${LOOP_SCRIPT_PATH}" ]; then
24+
die "Need '${LOOP_SCRIPT_PATH}' to exist!"
25+
fi
26+
27+
# Avoid waiting forever using the `timeout` command
28+
if timeout --foreground ${WAIT_TIMEOUT} \
29+
${LOOP_SCRIPT_PATH}; then
30+
echo ""
31+
grep 'password' /var/log/sele/vnc-stdout.log || true
32+
grep 'IP:' /var/log/sele/xterm-stdout.log || die "Failed to grep IP:"
33+
else
34+
bash -c 'tail /var/log/sele/*' || true
35+
echo "" && echo "" && echo "==> errors <=="
36+
bash -c '/bin-utils/selenium-grep.sh' || true
37+
38+
die "
39+
Your docker-selenium didn't start properly.
40+
Start it next time with -e DISABLE_ROLLBACK=true
41+
"
42+
fi

xterm/bin/wait-xterm.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
# Exit immediately if a command exits with a non-zero status
4+
set -e
5+
6+
echo "Waiting for docker-selenium to finish starting..."
7+
while ! grep 'all done and ready for testing' \
8+
/var/log/sele/xterm-stdout.log > /dev/null 2>&1; do
9+
echo -n '.'
10+
sleep 0.2;
11+
done
12+
13+
echo "Done wait-xterm.sh"

0 commit comments

Comments
 (0)