Public | Automated Build

Last pushed: 2 years ago
Short Description
Docker image (cloning casperbox) to run casperjs script
Full Description


A Node.js module that runs CasperJS scripts in Docker

It is a slightly modified version of the one used by the service
(now shut down).


Tested on Ubuntu 14.04.

  1. Install Docker
  2. Build the Docker image used to run CasperJS scripts in:

     $ sudo docker build -t ubuntu/14.04:casperbox .
  3. Edit the file to update the sudo password


docker run -a stdout -u casperbox -h casperbox -m 192m --rm=true -v "$(pwd)":/home/casperbox/source_files -w="/home/casperbox" --env PHANTOMJS_EXECUTABLE=phantomjs/bin/phantomjs ubuntu/14.04:casperbox casperjs/bin/casperjs source_files/source.js arg1 arg2

Original Usage follows

var casper = require('./casperjs-docker');
  "var casper = require('casper').create();\
  casper.start('', function() {\
    casper.echo('Hello, world!');\
  function(err, script) {
  source: 'var casper = require(\'casper\').create();\ncasper.start(\'\', function() {\n  casper.echo(\'Hello, world!\');\n});\;\n',
  startedAt: 1434145107992,
  output: 'Hello, world!\n',
  finishedAt: 1434145111563

Scripts are run with CasperJS 1.1-beta3 and PhantomJS 1.9.7. If you'd
like to use other versions feel free to modify the Dockerfile and rebuild
the image.

Every script is automatically terminated after 30 seconds. If it's not enough
for you feel free to modify the timeout in the casperjs-docker.js file (look
for the maxScriptRunTime variable).


There are a couple of Mocha tests. If you're curious you
can run them like this (the -t option is the test case timeout):

$ mocha -t 35000

There's also a
blog post
on my blog.

Docker Pull Command
Source Repository