FROM --platform=linux/amd64 ubuntu:14.04

RUN apt-get update && apt-get install -y \
    wget bzip2 libfontconfig1 \
    && rm -rf /var/lib/apt/lists/*

RUN wget -q https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 \
    && tar xjf phantomjs-2.1.1-linux-x86_64.tar.bz2 \
    && cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/ \
    && rm -rf phantomjs-2.1.1-linux-x86_64*

RUN echo 'var page=require("webpage").create();var sys=require("system");page.onConsoleMessage=function(m){sys.stdout.writeLine(m)};page.open(sys.args[1],function(){setTimeout(function(){phantom.exit()},5000)})' > /render.js

ENTRYPOINT ["phantomjs", "/render.js"]
