Example: Run Chrome puppeteer browser with puppeteer

Run Chrome puppeteer browser and with puppeteer on decentralized docker container.

Install and run Planetr Gateway on your computer

To install Planetr gateway on your computer, please read the Get Started section. This can be achieved on a laptop, a desktop computer, or a cloud instance.

Install and run the Chromium with puppeteer docker image on Planetr decentralized cloud

Make sure Planetr gateway is installed and running on your computer.

$ planetr dcu-ps

Create and run a decentralized compute unit (DCU) on Planetr network. For this tutorial we will be using an alpine docker image planetrio/chrome-puppeteer with chromium and puppeteer installed. You can see the source files to build the docker image here.

$ planetr dcu-run planetrio/chrome-puppeteer g.medium 
INSTANCE ID            STATUS    TYPE       IMAGE                       NAME   PORTS  
c2pnkbf2hraosbb0rmq0   Pending   g.medium   planetrio/chrome-puppeteer     

Please wait for the status to become 'Running'

$ planetr dcu-ps
INSTANCE ID            STATUS    TYPE       IMAGE                       NAME   PORTS 
c2pnkbf2hraosbb0rmq0   Running   g.medium   planetrio/chrome-puppeteer     

Run puppeteer code. There are two javascript files pdf.js and screenshot.js in /usr/src/ folder to start with.

$ planetr dcu-exec c2pnkbf2hraosbb0rmq0 "node screenshot.js https://planetr.io"

The above command should create a screen grab of the web site https://planetr.io (you can change this to any website URL). Check if the screenshot file screenshot.jpg is created within the container.

$ planetr dcu-exec c2pnkbf2hraosbb0rmq0  "ls -al"
total 84
drwxr-xr-x    1 chrome   chrome        4096 May 30 11:43 .
drwxr-xr-x    1 root     root          4096 May 30 06:48 ..
drwxr-xr-x    7 chrome   chrome        4096 May 30 07:33 .git
-rw-r--r--    1 chrome   chrome         438 May 30 06:48 Dockerfile
-rw-r--r--    1 chrome   chrome         934 May 30 07:32 README.md
drwxr-xr-x   56 chrome   chrome        4096 May 30 06:48 node_modules
-rw-r--r--    1 chrome   chrome       16518 May 30 06:41 package-lock.json
-rw-r--r--    1 chrome   chrome         204 May 30 06:40 package.json
-rw-r--r--    1 chrome   chrome         634 May 30 07:04 pdf.js
-rw-r--r--    1 chrome   chrome       22261 May 30 11:43 screenshot.jpg
-rw-r--r--    1 chrome   chrome         605 May 30 07:07 screenshot.js

Copy the file to your local drive.

$ planetr dcu-cp-from c2pnkbf2hraosbb0rmq0 /usr/src/screenshot.jpg screenshot.jpg
File copied.

Docker project at: GitHub