— This feature supports Electronic Lab Notebooks, available in LabKey Biologics LIMS and the Professional Edition of Sample Manager. Learn more
or contact LabKey
Puppeteer is an external web service that can be used to generate PDFs from Notebooks created with LabKey ELN. To use this service, you need to obtain the puppeteer
premium module, and configure your LabKey Server as described in this topic.
Set Up Puppeteer Service
puppeteer-service is a web service that allows for generation of assets (e.g. PDFs, screenshots) via Puppeteer.Service Mode
The puppeteer module has two configuration modes:
- remote: (Recommended) Remote mode configures LabKey Server to communicate with a remote instance of the puppeteer-service. The service is treated strictly as an external web service where the LabKey Server instance does not manage the service in any way.
- docker: (Experimental) Docker mode leverages LabKey's docker module to configure and run a puppeteer-service container on the LabKey Server instance. This mode manages the lifecycle of the container (i.e. startup, running, shutdown) which shares computational resources with the LabKey server instance.
Remote Service Mode (Recommended)
Remote mode is recommended for several reasons:
- Computational resources. Having the service running alongside LabKey Server, like it does in docker mode, can consume significant CPU and memory resources due to the overhead of the service as well as Docker.
- The remote puppeteer-service can be stood up once and shared by several LabKey Server instances (e.g. staging, production, etc.).
For operating in remote mode, all you need to do is obtain the Remote URL
and configure the puppeteer module
as described below.
The "Remote URL" property specifies the URL where the web service can be found. This is provided by whomever sets up the puppeteer-service instance.
Configure Puppeteer Module
The version of Puppeteer is shown in the lower panel for your reference. Instructions for upgrading are available below
All of the puppeteer module properties are also available as LabKey Server Startup Properties
. An example properties file (using Docker mode) would look something like:
Docker Service Mode (Experimental)
The puppeteer-service can be deployed in a Docker container on either a Linux or OSX host. Docker is required to be installed on the host machine. You can retrieve the latest Docker image from Docker Hub
using the following command:
docker pull labkeyteamcity/lk-puppeteer-service
This image can then be run in a container:
docker run -i --init --rm --cap-add=SYS_ADMIN -p 3031:3031 --name puppeteer-service labkeyteamcity/lk-puppeteer-service
To run the container so that it is persistent (i.e. so that it will survive server instance restarts), use the following:
sudo docker run -di --init --cap-add=SYS_ADMIN -p--restart unless-stopped --name puppeteer-service labkeyteamcity/lk-puppeteer-service
A simple HTML view has been added to allow for interacting with the service. To see this view navigate to http://localhost:3031
to get familiar.
Deploying this service on a Windows host is not supported nor tested.
POST to /pdf:
- inputURL: The URL of the website to create a PDF or screenshot from.
- apiKey: (Optional) If visiting a LabKey site that requires credentials you can specify an apiKey.
- fileName: (Optional) Name of the file that is streamed back in the response. Defaults to generated.pdf.
- printFormat: (Optional) Currently supports Letter and A4 page sizes. Defaults to Letter.
- printOrientation: (Optional) Supports Portrait and Landscape orientations. Defaults to Portrait.
Configuration PropertiesDocker Image
Docker mode only. The Docker Image
property specifies the name of the puppeteer-service image that is available on the LabKey Server instance. This image has to be downloaded via docker. See service deployment documentation for how to pull down an image.Docker Port
The Docker Port
property specifies what host port the service container should be bound to.
Upgrade Puppeteer in Docker Mode
We publish a puppeteer container to hub.docker.com
. The method to update to the new container is:
docker pull labkeyteamcity/lk-puppeteer-service
Then restart the docker container.
If puppeteer is running as a service
, i.e. persistently, you will follow this process:
- Stop the puppeteer container
- Remove the container
- Pull the latest container image from hub.docker.com
The commands to execute are:
sudo docker stop puppeteer-service
sudo docker rm puppeteer-service
sudo docker pull labkeyteamcity/lk-puppeteer-service:latest
These commands can be run in one set to simplify the steps:
sudo docker stop puppeteer-service && sudo docker rm puppeteer-service && sudo docker pull labkeyteamcity/lk-puppeteer-service:latest
To confirm that you are running the latest container
, you can inspect the puppeteer image and compare it to the running container:
sudo docker inspect labkeyteamcity/lk-puppeteer-service:latest | grep Id
sudo docker inspect puppeteer-service | grep Image
- The Image field of the running container "puppeteer-service" should match the ID of the labkeyteamcity/lk-puppeteer-service:latest published container.