Deploying Rendertron to Google Cloud Platform

Rendertron runs a server that takes a URL and returns static HTML for the URL by using headless Chromium. This guide follows

Deploying Rendertron to Heroku


Setup Herokuapp and Heroku CLI

First, add the Google Chrome buildpack to your project:

$ heroku buildpacks:set -a <app-name>

Next, add the heroku/nodejs buildpack to your project:

$ heroku buildpacks:add --index 2 heroku/nodejs -a <app-name>

Then, update the package.json entry for engines to specific node and npm versions. I used:

  "engines": {
    "node": "10.15.1",
    "npm": "6.4.1"

This was helpful in getting past a node-gyp issue during npm install, which Heroku will run each time you deploy.

Next, enter a new script into your package.json:

  "scripts": {
    "heroku-postbuild": "npm run build"

This will make sure to build rendertron into bin/rendertron on each deploy, in case you have any local changes.

Finally, add a Procfile to your project with the following:

web: node bin/rendertron

Deploying Rendertron in a docker container

Based on Puppeteer instructions we can create a docker image that bundles a headless chrome and rendertron. We can start from node 14 base image.

For more information about chrome installation please see the pupeteer page:

If you don’t want to use rendertron default configurations you can create a config.json file. This file must be created at the project root level, in the same directory as the Dockerfile.

    "cache": "filesystem",
    "cacheConfig": {
        "cacheDurationMinutes": 7200,
        "cacheMaxEntries": 1000,
        "snapshotDir": "/cache"

Then we can define the Dockerfile like this:

FROM node:14.11.0-stretch

RUN apt-get update \
    && apt-get install -y wget gnupg \
    && wget -q -O - | apt-key add - \
    && sh -c 'echo "deb [arch=amd64] stable main" >> /etc/apt/sources.list.d/google.list' \
    && apt-get update \
    && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
    --no-install-recommends \
    && rm -rf /var/lib/apt/lists/*

# This directoty will store cached files as specified in the config.json.
# If you haven't defined the cacheConfig.snapshotDir property you can remove the following line
RUN mkdir /cache

RUN git clone

WORKDIR /rendertron

RUN npm install && npm run build

# If you aren't using a custom config.json file you must remove the following line
ADD config.json .


CMD ["npm", "run", "start"]

And we can build an image using the previous Dockerfile:

docker build . -t rendertron:3.0
docker run -d --log-opt max-size=100m --log-opt max-file=3 --name rendertron -p 3000:3000 rendertron:3.0

The rendertron api will be avaiable at localhost:3000