Giter Site home page Giter Site logo

docker-nodejs's Introduction

NodeJS Docker

The project is made possible by volunteer contributors who have put in many hours of their own time, and made the source code freely available under the Apache License 2.0.

Docker images for NodeJS Standalone Server

Travis CI

Images included:

  • jpavlic/base: Base image which includes Java runtime
  • jpavlic/nodejs-base: Base image for NodeJS
  • jpavlic/nodejs: NodeJS installed
  • jpavlic/nodejs-debug: NodeJS installed and runs a VNC server
  • jpavlic/standalone-nodejs: NodeJS Standalone
  • jpavlic/standalone-nodejs-debug: NodeJS Standalone and runs a VNC server

Running the images

NodeJS

$ docker run -d -p 8080:8080 jpavlic/standalone-nodejs:latest

Standalone NodeJS

$ docker run -d -p 8080:8080 jpavlic/standalone-nodeJS:latest

Note: Only one NodeJS image can run on port 8080 at a time.

To inspect visually what the browser is doing use the standalone-chrome-debug or standalone-firefox-debug images. See Debugging section for details.

Via docker-compose

The most simple way to start a grid is with docker-compose, use the following snippet as your docker-compose.yaml, save it locally and in the same folder run docker-compose up.

Deploying to Kubernetes

Check out the Kubernetes examples on how to deploy selenium hub and nodes on a Kubernetes cluster.

Configuring the containers

Building the images

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

$ VERSION=local make build

If you need to configure environment variable in order to build the image (http proxy for instance), simply set an environment variable BUILD_ARGS that contains the additional variables to pass to the docker context (this will only work with docker >= 1.9)

$ BUILD_ARGS="--build-arg http_proxy=http://acme:3128 --build-arg https_proxy=http://acme:3128" make build

Note: Omitting VERSION=local will build the images with the current version number thus overwriting the images downloaded from Docker Hub.

Debugging

In the event you wish to visually see what the browser is doing you will want to run the debug variant of node or standalone images. A VNC server will run on port 5900. You are free to map that to any free external port that you wish. Keep in mind that you will only be able to run one node per port so if you wish to include a second node, or more, you will have to use different ports, the 5900 as the internal port will have to remain the same though as thats the VNC service on the node. The second example below shows how to run multiple nodes and with different VNC ports open:

$ docker run -d -P -p <port4VNC>:5900 --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-chrome-debug:latest
$ docker run -d -P -p <port4VNC>:5900 --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-firefox-debug:latest

e.g.:

$ docker run -d -P -p 5900:5900 --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-chrome-debug:latest
$ docker run -d -P -p 5901:5900 --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-firefox-debug:latest

to connect to the Chrome node on 5900 and the Firefox node on 5901 (assuming those node are free, and reachable).

And for standalone:

$ docker run -d -p 4444:4444 -p <port4VNC>:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:latest
# OR
$ docker run -d -p 4444:4444 -p <port4VNC>:5900 -v /dev/shm:/dev/shm selenium/standalone-firefox-debug:latest

or

$ docker run -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:latest
# OR
$ docker run -d -p 4444:4444 -p 5901:5900 -v /dev/shm:/dev/shm selenium/standalone-firefox-debug:latest

You can acquire the port that the VNC server is exposed to by running: (Assuming that we mapped the ports like this: 49338:5900)

$ docker port <container-name|container-id> 5900
#=> 0.0.0.0:49338

In case you have RealVNC binary vnc in your path, you can always take a look, view only to avoid messing around your tests with an unintended mouse click or keyboard interrupt:

$ ./bin/vncview 127.0.0.1:49160

If you are running Boot2Docker on OS X then you already have a VNC client built-in. You can connect by entering vnc://<boot2docker-ip>:49160 in Safari or Alfred.

When you are prompted for the password it is secret. If you wish to change this then you should either change it in the /NodeBase/Dockerfile and build the images yourself, or you can define a Docker image that derives from the posted ones which reconfigures it:

#FROM selenium/node-chrome-debug:latest
#FROM selenium/node-firefox-debug:latest
#Choose the FROM statement that works for you.

RUN x11vnc -storepasswd <your-password-here> /home/nodejsuser/.vnc/passwd

If you want to run VNC without password authentication you can set the environment variable VNC_NO_PASSWORD=1.

Troubleshooting

All output is sent to stdout so it can be inspected by running:

$ docker logs -f <container-id|container-name>

You can turn on debugging by passing environment variable to the hub and the nodes containers:

GRID_DEBUG=true

Headless

If you see the following selenium exceptions:

Message: invalid argument: can't kill an exited process

or

Message: unknown error: Chrome failed to start: exited abnormally

The reason might be that you've set the START_XVFB environment variable to "false", but forgot to actually run Firefox or Chrome (respectively) in headless mode.

docker-nodejs

docker-nodejs's People

Watchers

James Pavlic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.