1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-12-12 11:14:57 +02:00
dockerfiles/browserless/README.md
2018-11-08 18:02:28 +08:00

917 B

browserless

docker-compose.yml

browserless:
  image: browserless/chrome
  ports:
    - "3000:3000"
  environment:
    - DEBUG=browserless/chrome
    - MAX_CONCURRENT_SESSIONS=10
    - CONNECTION_TIMEOUT=600000
    - MAX_QUEUE_LENGTH=10
    - ENABLE_CORS=true
    - CHROME_REFRESH_TIME=3600000
  shm_size: 2gb
  restart: always

screenshot.js

'use strict';

const puppeteer = require('puppeteer');

(async() => {
  const browser = await puppeteer.connect({browserWSEndpoint: 'ws://localhost:3000'});
  const page = await browser.newPage();
  await page.goto('https://www.google.com/', {waitUntil: 'networkidle2'});
  await page.screenshot({path: 'google.png', fullPage: true});
  await browser.close();
})();

Up and Running

$ docker-compose up -d
$ PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm install puppeteer
$ node screenshot.js
$ imgcat google.png