Skip to content

Commit

Permalink
Add PhantomJS node support
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-cz committed Feb 21, 2017
1 parent eeca5f1 commit f12d43a
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ MAJOR := $(word 1,$(subst ., ,$(VERSION)))
MINOR := $(word 2,$(subst ., ,$(VERSION)))
MAJOR_MINOR_PATCH := $(word 1,$(subst -, ,$(VERSION)))

all: hub chrome firefox chrome_debug firefox_debug standalone_chrome standalone_firefox standalone_chrome_debug standalone_firefox_debug
all: hub chrome firefox phantomjs chrome_debug firefox_debug standalone_chrome standalone_firefox standalone_chrome_debug standalone_firefox_debug

generate_all: \
generate_hub \
generate_nodebase \
generate_chrome \
generate_firefox \
generate_phantomjs \
generate_chrome_debug \
generate_firefox_debug \
generate_standalone_firefox \
Expand Down Expand Up @@ -87,12 +88,19 @@ generate_firefox_debug:
firefox_debug: generate_firefox_debug firefox
cd ./NodeFirefoxDebug && docker build $(BUILD_ARGS) -t $(NAME)/node-firefox-debug:$(VERSION) .

generate_phantomjs:
cd ./NodePhantomJS && ./generate.sh $(VERSION)

phantomjs: nodebase generate_phantomjs
cd ./NodePhantomJS && docker build $(BUILD_ARGS) -t $(NAME)/node-phantomjs:$(VERSION) .

tag_latest:
docker tag $(NAME)/base:$(VERSION) $(NAME)/base:latest
docker tag $(NAME)/hub:$(VERSION) $(NAME)/hub:latest
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:latest
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:latest
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:latest
docker tag $(NAME)/node-phantomjs:$(VERSION) $(NAME)/node-phantoms:latest
docker tag $(NAME)/node-chrome-debug:$(VERSION) $(NAME)/node-chrome-debug:latest
docker tag $(NAME)/node-firefox-debug:$(VERSION) $(NAME)/node-firefox-debug:latest
docker tag $(NAME)/standalone-chrome:$(VERSION) $(NAME)/standalone-chrome:latest
Expand All @@ -106,6 +114,7 @@ release_latest:
docker push $(NAME)/node-base:latest
docker push $(NAME)/node-chrome:latest
docker push $(NAME)/node-firefox:latest
docker push $(NAME)/node-phantomjs:latest
docker push $(NAME)/node-chrome-debug:latest
docker push $(NAME)/node-firefox-debug:latest
docker push $(NAME)/standalone-chrome:latest
Expand All @@ -119,6 +128,7 @@ tag_major_minor:
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:$(MAJOR)
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:$(MAJOR)
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:$(MAJOR)
docker tag $(NAME)/node-phantomjs:$(VERSION) $(NAME)/node-phantomjs:$(MAJOR)
docker tag $(NAME)/node-chrome-debug:$(VERSION) $(NAME)/node-chrome-debug:$(MAJOR)
docker tag $(NAME)/node-firefox-debug:$(VERSION) $(NAME)/node-firefox-debug:$(MAJOR)
docker tag $(NAME)/standalone-chrome:$(VERSION) $(NAME)/standalone-chrome:$(MAJOR)
Expand All @@ -130,6 +140,7 @@ tag_major_minor:
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:$(MAJOR).$(MINOR)
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:$(MAJOR).$(MINOR)
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:$(MAJOR).$(MINOR)
docker tag $(NAME)/node-phantomjs:$(VERSION) $(NAME)/node-phantomjs:$(MAJOR).$(MINOR)
docker tag $(NAME)/node-chrome-debug:$(VERSION) $(NAME)/node-chrome-debug:$(MAJOR).$(MINOR)
docker tag $(NAME)/node-firefox-debug:$(VERSION) $(NAME)/node-firefox-debug:$(MAJOR).$(MINOR)
docker tag $(NAME)/standalone-chrome:$(VERSION) $(NAME)/standalone-chrome:$(MAJOR).$(MINOR)
Expand All @@ -141,6 +152,7 @@ tag_major_minor:
docker tag $(NAME)/node-base:$(VERSION) $(NAME)/node-base:$(MAJOR_MINOR_PATCH)
docker tag $(NAME)/node-chrome:$(VERSION) $(NAME)/node-chrome:$(MAJOR_MINOR_PATCH)
docker tag $(NAME)/node-firefox:$(VERSION) $(NAME)/node-firefox:$(MAJOR_MINOR_PATCH)
docker tag $(NAME)/node-phantomjs:$(VERSION) $(NAME)/node-phantomjs:$(MAJOR_MINOR_PATCH)
docker tag $(NAME)/node-chrome-debug:$(VERSION) $(NAME)/node-chrome-debug:$(MAJOR_MINOR_PATCH)
docker tag $(NAME)/node-firefox-debug:$(VERSION) $(NAME)/node-firefox-debug:$(MAJOR_MINOR_PATCH)
docker tag $(NAME)/standalone-chrome:$(VERSION) $(NAME)/standalone-chrome:$(MAJOR_MINOR_PATCH)
Expand All @@ -154,6 +166,7 @@ release: tag_major_minor
@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
@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
@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
@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
@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
@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
@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
Expand All @@ -165,6 +178,7 @@ release: tag_major_minor
docker push $(NAME)/node-base:$(VERSION)
docker push $(NAME)/node-chrome:$(VERSION)
docker push $(NAME)/node-firefox:$(VERSION)
docker push $(NAME)/node-phantomjs:$(VERSION)
docker push $(NAME)/node-chrome-debug:$(VERSION)
docker push $(NAME)/node-firefox-debug:$(VERSION)
docker push $(NAME)/standalone-chrome:$(VERSION)
Expand All @@ -177,6 +191,7 @@ release: tag_major_minor
docker push $(NAME)/node-base:$(MAJOR)
docker push $(NAME)/node-chrome:$(MAJOR)
docker push $(NAME)/node-firefox:$(MAJOR)
docker push $(NAME)/node-phantomjs:$(MAJOR)
docker push $(NAME)/node-chrome-debug:$(MAJOR)
docker push $(NAME)/node-firefox-debug:$(MAJOR)
docker push $(NAME)/standalone-chrome:$(MAJOR)
Expand All @@ -189,6 +204,7 @@ release: tag_major_minor
docker push $(NAME)/node-base:$(MAJOR).$(MINOR)
docker push $(NAME)/node-chrome:$(MAJOR).$(MINOR)
docker push $(NAME)/node-firefox:$(MAJOR).$(MINOR)
docker push $(NAME)/node-phantomjs:$(MAJOR).$(MINOR)
docker push $(NAME)/node-chrome-debug:$(MAJOR).$(MINOR)
docker push $(NAME)/node-firefox-debug:$(MAJOR).$(MINOR)
docker push $(NAME)/standalone-chrome:$(MAJOR).$(MINOR)
Expand All @@ -201,6 +217,7 @@ release: tag_major_minor
docker push $(NAME)/node-base:$(MAJOR_MINOR_PATCH)
docker push $(NAME)/node-chrome:$(MAJOR_MINOR_PATCH)
docker push $(NAME)/node-firefox:$(MAJOR_MINOR_PATCH)
docker push $(NAME)/node-phantomjs:$(MAJOR_MINOR_PATCH)
docker push $(NAME)/node-chrome-debug:$(MAJOR_MINOR_PATCH)
docker push $(NAME)/node-firefox-debug:$(MAJOR_MINOR_PATCH)
docker push $(NAME)/standalone-chrome:$(MAJOR_MINOR_PATCH)
Expand All @@ -224,11 +241,13 @@ test:
ci \
firefox \
firefox_debug \
phantomjs \
generate_all \
generate_hub \
generate_nodebase \
generate_chrome \
generate_firefox \
generate_phantomjs \
generate_chrome_debug \
generate_firefox_debug \
generate_standalone_chrome \
Expand Down
36 changes: 36 additions & 0 deletions NodePhantomJS/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED.
# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
FROM selenium/node-base:3.0.1-fermium
MAINTAINER Selenium <[email protected]>

USER root

#==============
# PhantomJS
#==============
RUN apt-get update -y
RUN apt-get install bzip2 libfreetype6 libfontconfig1 -y
RUN wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
RUN tar -xvjf phantomjs-1.9.8-linux-x86_64.tar.bz2 && rm phantomjs-1.9.8-linux-x86_64.tar.bz2
RUN mv /phantomjs-1.9.8-linux-x86_64 /usr/local/phantomjs-1.9.8-linux-x86_64
RUN ln -s /usr/local/phantomjs-1.9.8-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs

#==============================
# Scripts to run Selenium Node
#==============================
COPY entry_point.sh /opt/bin/entry_point.sh
RUN chmod +x /opt/bin/entry_point.sh

#============================
# Some configuration options
#============================
ENV SCREEN_WIDTH 1360
ENV SCREEN_HEIGHT 1020
ENV SCREEN_DEPTH 24
ENV DISPLAY :99.0

USER seluser

CMD ["/opt/bin/entry_point.sh"]
31 changes: 31 additions & 0 deletions NodePhantomJS/Dockerfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
MAINTAINER Selenium <[email protected]>

USER root

#==============
# PhantomJS
#==============
RUN apt-get update -y
RUN apt-get install bzip2 libfreetype6 libfontconfig1 -y
RUN wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
RUN tar -xvjf phantomjs-1.9.8-linux-x86_64.tar.bz2 && rm phantomjs-1.9.8-linux-x86_64.tar.bz2
RUN mv /phantomjs-1.9.8-linux-x86_64 /usr/local/phantomjs-1.9.8-linux-x86_64
RUN ln -s /usr/local/phantomjs-1.9.8-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs

#==============================
# Scripts to run Selenium Node
#==============================
COPY entry_point.sh /opt/bin/entry_point.sh
RUN chmod +x /opt/bin/entry_point.sh

#============================
# Some configuration options
#============================
ENV SCREEN_WIDTH 1360
ENV SCREEN_HEIGHT 1020
ENV SCREEN_DEPTH 24
ENV DISPLAY :99.0

USER seluser

CMD ["/opt/bin/entry_point.sh"]
1 change: 1 addition & 0 deletions NodePhantomJS/README-short.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Selenium Node configured to run PhantomJS.
54 changes: 54 additions & 0 deletions NodePhantomJS/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Selenium Grid Node - PhantomJS

Selenium Node configured to run PhantomJS.

## Dockerfile

[`selenium/node-phantomjs` Dockerfile](https://github.com/SeleniumHQ/docker-selenium/blob/master/NodePhantomJS/Dockerfile)

## How to use this image

First, you will need a Selenium Grid Hub that the Node will connect to.

```
$ docker run -d -P --name selenium-hub selenium/hub
```

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.

```
$ docker run -d --link selenium-hub:hub selenium/node-phantomjs
```

## What is Selenium?
_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.

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.

See the Selenium [site](http://docs.seleniumhq.org/) for documation on usage within your test code.

## License

View [license information](https://github.com/SeleniumHQ/docker-selenium/blob/master/LICENSE.md) for the software contained in this image.

## Getting Help

### User Group

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.

_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!_

### Chat Room

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/).

### Issues

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).

## Contributing

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.

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/)
23 changes: 23 additions & 0 deletions NodePhantomJS/entry_point.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

source /opt/bin/functions.sh

if [ -z "$HUB_PORT_4444_TCP_ADDR" ]; then
echo Not linked with a running Hub container 1>&2
exit 1
fi

function shutdown {
kill -s SIGTERM $NODE_PID
wait $NODE_PID
}

if [ -z "$IP" ]; then
IP="$(hostname -i)"
fi


phantomjs --webdriver=$IP:4444 ${PHANTOMJS_OPTS} --webdriver-selenium-grid-hub=http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT

trap shutdown SIGTERM SIGINT
wait $NODE_PID
9 changes: 9 additions & 0 deletions NodePhantomJS/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
VERSION=$1

echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" > ./Dockerfile
echo "# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED." >> ./Dockerfile
echo "# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE" >> ./Dockerfile
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> ./Dockerfile
echo FROM selenium/node-base:$VERSION >> ./Dockerfile
cat ./Dockerfile.txt >> ./Dockerfile

0 comments on commit f12d43a

Please sign in to comment.