Skip to content

Commit acee8a1

Browse files
authored
Merge pull request #373 from marten-cz/phantomjs
Phantomjs node
2 parents eeca5f1 + 0e478e3 commit acee8a1

File tree

11 files changed

+204
-4
lines changed

11 files changed

+204
-4
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ before_install:
1212
- docker build -t test:local ./Test
1313

1414
script:
15-
- make test
15+
- VERSION="$TRAVIS_BRANCH" make test
1616

1717
# only push up tags
1818
after_success:

Makefile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ MAJOR := $(word 1,$(subst ., ,$(VERSION)))
66
MINOR := $(word 2,$(subst ., ,$(VERSION)))
77
MAJOR_MINOR_PATCH := $(word 1,$(subst -, ,$(VERSION)))
88

9-
all: hub chrome firefox chrome_debug firefox_debug standalone_chrome standalone_firefox standalone_chrome_debug standalone_firefox_debug
9+
all: hub chrome firefox phantomjs chrome_debug firefox_debug standalone_chrome standalone_firefox standalone_chrome_debug standalone_firefox_debug
1010

1111
generate_all: \
1212
generate_hub \
1313
generate_nodebase \
1414
generate_chrome \
1515
generate_firefox \
16+
generate_phantomjs \
1617
generate_chrome_debug \
1718
generate_firefox_debug \
1819
generate_standalone_firefox \
@@ -87,12 +88,19 @@ generate_firefox_debug:
8788
firefox_debug: generate_firefox_debug firefox
8889
cd ./NodeFirefoxDebug && docker build $(BUILD_ARGS) -t $(NAME)/node-firefox-debug:$(VERSION) .
8990

91+
generate_phantomjs:
92+
cd ./NodePhantomJS && ./generate.sh $(VERSION)
93+
94+
phantomjs: nodebase generate_phantomjs
95+
cd ./NodePhantomJS && docker build $(BUILD_ARGS) -t $(NAME)/node-phantomjs:$(VERSION) .
96+
9097
tag_latest:
9198
docker tag $(NAME)/base:$(VERSION) $(NAME)/base:latest
9299
docker tag $(NAME)/hub:$(VERSION) $(NAME)/hub:latest
93100
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:latest
94101
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:latest
95102
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:latest
103+
docker tag $(NAME)/node-phantomjs:$(VERSION) $(NAME)/node-phantoms:latest
96104
docker tag $(NAME)/node-chrome-debug:$(VERSION) $(NAME)/node-chrome-debug:latest
97105
docker tag $(NAME)/node-firefox-debug:$(VERSION) $(NAME)/node-firefox-debug:latest
98106
docker tag $(NAME)/standalone-chrome:$(VERSION) $(NAME)/standalone-chrome:latest
@@ -106,6 +114,7 @@ release_latest:
106114
docker push $(NAME)/node-base:latest
107115
docker push $(NAME)/node-chrome:latest
108116
docker push $(NAME)/node-firefox:latest
117+
docker push $(NAME)/node-phantomjs:latest
109118
docker push $(NAME)/node-chrome-debug:latest
110119
docker push $(NAME)/node-firefox-debug:latest
111120
docker push $(NAME)/standalone-chrome:latest
@@ -119,6 +128,7 @@ tag_major_minor:
119128
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:$(MAJOR)
120129
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:$(MAJOR)
121130
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:$(MAJOR)
131+
docker tag $(NAME)/node-phantomjs:$(VERSION) $(NAME)/node-phantomjs:$(MAJOR)
122132
docker tag $(NAME)/node-chrome-debug:$(VERSION) $(NAME)/node-chrome-debug:$(MAJOR)
123133
docker tag $(NAME)/node-firefox-debug:$(VERSION) $(NAME)/node-firefox-debug:$(MAJOR)
124134
docker tag $(NAME)/standalone-chrome:$(VERSION) $(NAME)/standalone-chrome:$(MAJOR)
@@ -130,6 +140,7 @@ tag_major_minor:
130140
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:$(MAJOR).$(MINOR)
131141
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:$(MAJOR).$(MINOR)
132142
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:$(MAJOR).$(MINOR)
143+
docker tag $(NAME)/node-phantomjs:$(VERSION) $(NAME)/node-phantomjs:$(MAJOR).$(MINOR)
133144
docker tag $(NAME)/node-chrome-debug:$(VERSION) $(NAME)/node-chrome-debug:$(MAJOR).$(MINOR)
134145
docker tag $(NAME)/node-firefox-debug:$(VERSION) $(NAME)/node-firefox-debug:$(MAJOR).$(MINOR)
135146
docker tag $(NAME)/standalone-chrome:$(VERSION) $(NAME)/standalone-chrome:$(MAJOR).$(MINOR)
@@ -141,6 +152,7 @@ tag_major_minor:
141152
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:$(MAJOR_MINOR_PATCH)
142153
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:$(MAJOR_MINOR_PATCH)
143154
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:$(MAJOR_MINOR_PATCH)
155+
docker tag $(NAME)/node-phantomjs:$(VERSION) $(NAME)/node-phantomjs:$(MAJOR_MINOR_PATCH)
144156
docker tag $(NAME)/node-chrome-debug:$(VERSION) $(NAME)/node-chrome-debug:$(MAJOR_MINOR_PATCH)
145157
docker tag $(NAME)/node-firefox-debug:$(VERSION) $(NAME)/node-firefox-debug:$(MAJOR_MINOR_PATCH)
146158
docker tag $(NAME)/standalone-chrome:$(VERSION) $(NAME)/standalone-chrome:$(MAJOR_MINOR_PATCH)
@@ -154,6 +166,7 @@ release: tag_major_minor
154166
@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
155167
@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
156168
@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
169+
@if ! docker images $(NAME)/node-phantomjs | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME)/node-phantomjs version $(VERSION) is not yet built. Please run 'make build'"; false; fi
157170
@if ! docker images $(NAME)/node-chrome-debug | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME)/node-chrome-debug version $(VERSION) is not yet built. Please run 'make build'"; false; fi
158171
@if ! docker images $(NAME)/node-firefox-debug | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME)/node-firefox-debug version $(VERSION) is not yet built. Please run 'make build'"; false; fi
159172
@if ! docker images $(NAME)/standalone-chrome | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME)/standalone-chrome version $(VERSION) is not yet built. Please run 'make build'"; false; fi
@@ -165,6 +178,7 @@ release: tag_major_minor
165178
docker push $(NAME)/node-base:$(VERSION)
166179
docker push $(NAME)/node-chrome:$(VERSION)
167180
docker push $(NAME)/node-firefox:$(VERSION)
181+
docker push $(NAME)/node-phantomjs:$(VERSION)
168182
docker push $(NAME)/node-chrome-debug:$(VERSION)
169183
docker push $(NAME)/node-firefox-debug:$(VERSION)
170184
docker push $(NAME)/standalone-chrome:$(VERSION)
@@ -177,6 +191,7 @@ release: tag_major_minor
177191
docker push $(NAME)/node-base:$(MAJOR)
178192
docker push $(NAME)/node-chrome:$(MAJOR)
179193
docker push $(NAME)/node-firefox:$(MAJOR)
194+
docker push $(NAME)/node-phantomjs:$(MAJOR)
180195
docker push $(NAME)/node-chrome-debug:$(MAJOR)
181196
docker push $(NAME)/node-firefox-debug:$(MAJOR)
182197
docker push $(NAME)/standalone-chrome:$(MAJOR)
@@ -189,6 +204,7 @@ release: tag_major_minor
189204
docker push $(NAME)/node-base:$(MAJOR).$(MINOR)
190205
docker push $(NAME)/node-chrome:$(MAJOR).$(MINOR)
191206
docker push $(NAME)/node-firefox:$(MAJOR).$(MINOR)
207+
docker push $(NAME)/node-phantomjs:$(MAJOR).$(MINOR)
192208
docker push $(NAME)/node-chrome-debug:$(MAJOR).$(MINOR)
193209
docker push $(NAME)/node-firefox-debug:$(MAJOR).$(MINOR)
194210
docker push $(NAME)/standalone-chrome:$(MAJOR).$(MINOR)
@@ -201,6 +217,7 @@ release: tag_major_minor
201217
docker push $(NAME)/node-base:$(MAJOR_MINOR_PATCH)
202218
docker push $(NAME)/node-chrome:$(MAJOR_MINOR_PATCH)
203219
docker push $(NAME)/node-firefox:$(MAJOR_MINOR_PATCH)
220+
docker push $(NAME)/node-phantomjs:$(MAJOR_MINOR_PATCH)
204221
docker push $(NAME)/node-chrome-debug:$(MAJOR_MINOR_PATCH)
205222
docker push $(NAME)/node-firefox-debug:$(MAJOR_MINOR_PATCH)
206223
docker push $(NAME)/standalone-chrome:$(MAJOR_MINOR_PATCH)
@@ -224,11 +241,13 @@ test:
224241
ci \
225242
firefox \
226243
firefox_debug \
244+
phantomjs \
227245
generate_all \
228246
generate_hub \
229247
generate_nodebase \
230248
generate_chrome \
231249
generate_firefox \
250+
generate_phantomjs \
232251
generate_chrome_debug \
233252
generate_firefox_debug \
234253
generate_standalone_chrome \

NodePhantomJS/Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2+
# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED.
3+
# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE
4+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5+
FROM selenium/node-base:3.0.1-fermium
6+
MAINTAINER Selenium <[email protected]>
7+
8+
USER root
9+
10+
#==============
11+
# PhantomJS
12+
#==============
13+
RUN apt-get update -y
14+
RUN apt-get install bzip2 libfreetype6 libfontconfig1 -y
15+
RUN wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
16+
RUN tar -xvjf phantomjs-1.9.8-linux-x86_64.tar.bz2 && rm phantomjs-1.9.8-linux-x86_64.tar.bz2
17+
RUN mv /phantomjs-1.9.8-linux-x86_64 /usr/local/phantomjs-1.9.8-linux-x86_64
18+
RUN ln -s /usr/local/phantomjs-1.9.8-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
19+
20+
#==============================
21+
# Scripts to run Selenium Node
22+
#==============================
23+
COPY entry_point.sh /opt/bin/entry_point.sh
24+
RUN chmod +x /opt/bin/entry_point.sh
25+
26+
#============================
27+
# Some configuration options
28+
#============================
29+
ENV SCREEN_WIDTH 1360
30+
ENV SCREEN_HEIGHT 1020
31+
ENV SCREEN_DEPTH 24
32+
ENV DISPLAY :99.0
33+
34+
USER seluser
35+
36+
CMD ["/opt/bin/entry_point.sh"]

NodePhantomJS/Dockerfile.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
MAINTAINER Selenium <[email protected]>
2+
3+
USER root
4+
5+
#==============
6+
# PhantomJS
7+
#==============
8+
RUN apt-get update -y
9+
RUN apt-get install bzip2 libfreetype6 libfontconfig1 -y
10+
RUN wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
11+
RUN tar -xvjf phantomjs-1.9.8-linux-x86_64.tar.bz2 && rm phantomjs-1.9.8-linux-x86_64.tar.bz2
12+
RUN mv /phantomjs-1.9.8-linux-x86_64 /usr/local/phantomjs-1.9.8-linux-x86_64
13+
RUN ln -s /usr/local/phantomjs-1.9.8-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
14+
15+
#==============================
16+
# Scripts to run Selenium Node
17+
#==============================
18+
COPY entry_point.sh /opt/bin/entry_point.sh
19+
RUN chmod +x /opt/bin/entry_point.sh
20+
21+
#============================
22+
# Some configuration options
23+
#============================
24+
ENV SCREEN_WIDTH 1360
25+
ENV SCREEN_HEIGHT 1020
26+
ENV SCREEN_DEPTH 24
27+
ENV DISPLAY :99.0
28+
29+
USER seluser
30+
31+
CMD ["/opt/bin/entry_point.sh"]

NodePhantomJS/README-short.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Selenium Node configured to run PhantomJS.

NodePhantomJS/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Selenium Grid Node - PhantomJS
2+
3+
Selenium Node configured to run PhantomJS.
4+
5+
## Dockerfile
6+
7+
[`selenium/node-phantomjs` Dockerfile](https://github.com/SeleniumHQ/docker-selenium/blob/master/NodePhantomJS/Dockerfile)
8+
9+
## How to use this image
10+
11+
First, you will need a Selenium Grid Hub that the Node will connect to.
12+
13+
```
14+
$ docker run -d -P --name selenium-hub selenium/hub
15+
```
16+
17+
Once the hub is up and running will want to launch nodes that can run tests. You can run as many nodes as you wish.
18+
19+
```
20+
$ docker run -d --link selenium-hub:hub selenium/node-phantomjs
21+
```
22+
23+
## What is Selenium?
24+
_Selenium automates browsers._ That's it! What you do with that power is entirely up to you. Primarily, it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well.
25+
26+
Selenium has the support of some of the largest browser vendors who have taken (or are taking) steps to make Selenium a native part of their browser. It is also the core technology in countless other browser automation tools, APIs and frameworks.
27+
28+
See the Selenium [site](http://docs.seleniumhq.org/) for documation on usage within your test code.
29+
30+
## License
31+
32+
View [license information](https://github.com/SeleniumHQ/docker-selenium/blob/master/LICENSE.md) for the software contained in this image.
33+
34+
## Getting Help
35+
36+
### User Group
37+
38+
The first place where people ask for help about Selenium is the [Official User Group](https://groups.google.com/forum/#!forum/selenium-users). Here, you'll find that most of the time, someone already found the problem you are facing right now, and usually reached the solution for which you are looking.
39+
40+
_Note: Please make sure to search the group before asking for something. Your question likely won't get answered if it was previously answered in another discussion!_
41+
42+
### Chat Room
43+
44+
The best place to ask for help is the user group (because they also keep the information accessible for others to read in the future). However, if you have a very important (or too simple) issue that needs a solution ASAP, you can always enter the IRC chat room. You might just find someone ready to help on `#selenium` at [Freenode](https://freenode.net/).
45+
46+
### Issues
47+
48+
If you have any problems with or questions about this image, please contact us through a [Github issue](https://github.com/SeleniumHQ/docker-selenium/issues). If you have any problems with or questions about Selenium, please contact us through Selenium's [Bug Tracker](https://code.google.com/p/selenium/issues/list).
49+
50+
## Contributing
51+
52+
There are many ways to [contribute](http://docs.seleniumhq.org/about/getting-involved.jsp) whether by answering user questions, additional docs, or pull request we look forward to hearing from you.
53+
54+
If you do supply a patch we will need you to [sign the CLA](https://spreadsheets.google.com/spreadsheet/viewform?hl=en_US&formkey=dFFjXzBzM1VwekFlOWFWMjFFRjJMRFE6MQ#gid=0). We are part of [SFC](http://www.sfconservancy.org/)

NodePhantomJS/entry_point.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
source /opt/bin/functions.sh
4+
5+
if [ -z "$HUB_PORT_4444_TCP_ADDR" ]; then
6+
echo Not linked with a running Hub container 1>&2
7+
exit 1
8+
fi
9+
10+
function shutdown {
11+
kill -s SIGTERM $NODE_PID
12+
wait $NODE_PID
13+
}
14+
15+
if [ -z "$IP" ]; then
16+
IP="$(hostname -i)"
17+
fi
18+
19+
20+
phantomjs --webdriver=$IP:4444 ${PHANTOMJS_OPTS} --webdriver-selenium-grid-hub=http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT
21+
22+
trap shutdown SIGTERM SIGINT
23+
wait $NODE_PID

NodePhantomJS/generate.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
VERSION=$1
3+
4+
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" > ./Dockerfile
5+
echo "# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED." >> ./Dockerfile
6+
echo "# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE" >> ./Dockerfile
7+
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> ./Dockerfile
8+
echo FROM selenium/node-base:$VERSION >> ./Dockerfile
9+
cat ./Dockerfile.txt >> ./Dockerfile

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Images included:
1313
- __selenium/node-base__: Base image for Selenium Grid Nodes which includes a virtual desktop environment and VNC support
1414
- __selenium/node-chrome__: Selenium node with Chrome installed, needs to be connected to a Selenium Grid Hub
1515
- __selenium/node-firefox__: Selenium node with Firefox installed, needs to be connected to a Selenium Grid Hub
16+
- __selenium/node-phantomjs__: Selenium node with PhantomJS installed, needs to be connected to a Selenium Grid Hub
1617
- __selenium/standalone-chrome__: Selenium standalone with Chrome installed
1718
- __selenium/standalone-firefox__: Selenium standalone with Firefox installed
1819
- __selenium/standalone-chrome-debug__: Selenium standalone with Chrome installed and runs a VNC server
@@ -69,6 +70,14 @@ You can pass `SE_OPTS` variable with additional commandline parameters for start
6970
$ docker run -d -p 4444:4444 -e SE_OPTS=-debug --name selenium-hub selenium/hub:3.0.1-germanium
7071
```
7172

73+
### PHANTOMJS_OPTS PhantomJS Configuration Options
74+
75+
``` bash
76+
$ docker run -d -e PHANTOMJS_OPTS="--ignore-ssl-errors=true" --link selenium-hub:hub selenium/node-phantomjs:3.0.1-fermium
77+
```
78+
79+
You can pass `SE_OPTS` variable with additional commandline parameters for starting a PhantomJS node.
80+
7281
## Building the images
7382

7483
Clone the repo and from the project directory root you can build everything by running:

Test/smoke-phantomjs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('./smoke-test')('phantomjs');

test.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22
DEBUG=''
3+
VERSION=${VERSION:-3.0.1-germanium}
34

45
if [ -n "$1" ] && [ $1 == 'debug' ]; then
56
DEBUG='-debug'
@@ -30,11 +31,18 @@ docker logs -f $HUB &
3031
sleep 2
3132

3233
echo 'Starting Selenium Chrome node...'
33-
NODE_CHROME=$(docker run -d --link $HUB_NAME:hub selenium/node-chrome$DEBUG:3.0.1-germanium)
34+
NODE_CHROME=$(docker run -d --link $HUB_NAME:hub selenium/node-chrome$DEBUG:${VERSION})
3435
echo 'Starting Selenium Firefox node...'
35-
NODE_FIREFOX=$(docker run -d --link $HUB_NAME:hub selenium/node-firefox$DEBUG:3.0.1-germanium)
36+
NODE_FIREFOX=$(docker run -d --link $HUB_NAME:hub selenium/node-firefox$DEBUG:${VERSION})
37+
if [ -z $DEBUG ]; then
38+
echo 'Starting Selenium PhantomJS node...'
39+
NODE_PHANTOMJS=$(docker run -d --link $HUB_NAME:hub selenium/node-phantomjs:${VERSION})
40+
fi
3641
docker logs -f $NODE_CHROME &
3742
docker logs -f $NODE_FIREFOX &
43+
if [ -z $DEBUG ]; then
44+
docker logs -f $NODE_PHANTOMJS &
45+
fi
3846
echo 'Waiting for nodes to register and come online...'
3947
sleep 2
4048

@@ -60,6 +68,9 @@ function test_node {
6068

6169
test_node chrome $DEBUG
6270
test_node firefox $DEBUG
71+
if [ -z $DEBUG ]; then
72+
test_node phantomjs $DEBUG
73+
fi
6374

6475
if [ ! "$CIRCLECI" == "true" ]; then
6576
echo Tearing down Selenium Chrome Node container
@@ -70,6 +81,12 @@ if [ ! "$CIRCLECI" == "true" ]; then
7081
docker stop $NODE_FIREFOX
7182
docker rm $NODE_FIREFOX
7283

84+
if [ -z $DEBUG ]; then
85+
echo Tearing down Selenium PhantomJS Node container
86+
docker stop $NODE_PHANTOMJS
87+
docker rm $NODE_PHANTOMJS
88+
fi
89+
7390
echo Tearing down Selenium Hub container
7491
docker stop $HUB
7592
docker rm $HUB

0 commit comments

Comments
 (0)