Puppeteer HTTP Server
This guide shows you how to use Puppeteer, a Node.js library which provides a high-level API to control browsers, including the option to run them headless (no UI).
To run it, follow these steps:
-
Install the CLI and a container runtime engine, for example Docker. Use the unikraft CLI or the legacy kraft CLI.
-
Clone the
examplesrepository andcdinto theexamples/httpserver-node-express-puppeteer/directory:
Code
Make sure to log into Unikraft Cloud and pick a metro close to you.
This guide uses fra (Frankfurt, 🇩🇪):
The UKC_TOKEN and UKC_METRO environment variables are only supported by the legacy CLI.
Note: A Puppeteer instance on Unikraft Cloud requires 4GB to run. Request an increase in the instance memory quota when you need more memory.
When done, invoke the following command to deploy this app on Unikraft Cloud:
The output shows the instance address and other details:
Code
In this case, the instance name is httpserver-node-express-puppeteer-7afg3.
They're different for each run.
Use a browser to access the landing page of the Puppeteer (that uses ExpressJS). The app and the landing page are part of this repository.
In the example run above the landing page is at https://nameless-fog-0tvh1uov.fra.unikraft.app.
You can use the landing page to generate the PDF version of a remote page.
You can list information about the instance by running:
Code
Code
When done, you can remove the instance:
Customize your deployment
The current deployment uses an ExpressJS service that uses the PDF generating functionality of Puppeteer. Customizing the deployment means updating the service, such as adding new functionalities provided by Puppeteer. You can update the service to provide a REST-like interface.
Learn more
Use the --help option for detailed information on using Unikraft Cloud:
Code
Or visit the CLI Reference or the legacy CLI Reference.