Docker image (cloning casperbox) to run casperjs script
411
A Node.js module that runs CasperJS scripts in Docker containers.
It is a slightly modified version of the one used by the casperbox.com service (now shut down).
Tested on Ubuntu 14.04.
Install Docker
Build the Docker image used to run CasperJS scripts in:
$ sudo docker build -t ubuntu/14.04:casperbox .
Edit the run-script-in-docker--password.sh 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
var casper = require('./casperjs-docker');
casper.runScript(
"var casper = require('casper').create();\
casper.start('http://casperjs.org', function() {\
casper.echo('Hello, world!');\
});\
casper.run();",
function(err, script) {
console.log(script);
}
);
{
source: 'var casper = require(\'casper\').create();\ncasper.start(\'http://casperjs.org\', function() {\n casper.echo(\'Hello, world!\');\n});\ncasper.run();\n',
startedAt: 1434145107992,
output: 'Hello, world!\n',
finishedAt: 1434145111563
}
Scripts are run with CasperJS
1.1-beta3and PhantomJS1.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.jsfile (look for themaxScriptRunTimevariable).
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.
Content type
Image
Digest
Size
278.5 MB
Last updated
over 10 years ago
docker pull maddyonline/casperjs-docker