From 2dec76638f7d9c07da8649a294d5f8cb256c9bf2 Mon Sep 17 00:00:00 2001 From: kev Date: Wed, 4 Aug 2021 13:32:37 +0800 Subject: [PATCH] add playwright --- README.md | 1 + playwright/README.md | 25 +++++++++++++++++++++++++ playwright/data/example.js | 9 +++++++++ playwright/docker-compose.yml | 15 +++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 playwright/README.md create mode 100644 playwright/data/example.js create mode 100644 playwright/docker-compose.yml diff --git a/README.md b/README.md index a073e91..a3bed82 100644 --- a/README.md +++ b/README.md @@ -366,6 +366,7 @@ A collection of delicious docker recipes. - [x] owncloud - [x] phpmyadmin - [x] pihole/pihole +- [x] mcr.microsoft.com/playwright - [x] portainer/portainer :+1: - [x] postgres - [x] postgrest/postgrest diff --git a/playwright/README.md b/playwright/README.md new file mode 100644 index 0000000..7dccbbc --- /dev/null +++ b/playwright/README.md @@ -0,0 +1,25 @@ +playwright +========== + +```bash +$ mkdir data +$ chown 1000:1000 data +$ docker-compose up -d +$ docker exec --user root playwright npm install -g playwright +$ alias playwright='docker exec playwright npx playwright' + +$ docker exec playwright node example.js + +$ playwright pdf https://github.com github.pdf +Navigating to https://github.com +Saving as pdf into github.pdf + +$ playwright screenshot --full-page https://github.com github.png +Navigating to https://github.com +Capturing screenshot into github.png + +$ tree data +├── example.png +├── github.pdf +└── github.png +``` diff --git a/playwright/data/example.js b/playwright/data/example.js new file mode 100644 index 0000000..8e214b0 --- /dev/null +++ b/playwright/data/example.js @@ -0,0 +1,9 @@ +const { webkit } = require('playwright'); + +(async () => { + const browser = await webkit.launch(); + const page = await browser.newPage(); + await page.goto('http://whatsmyuseragent.org/'); + await page.screenshot({ path: `example.png` }); + await browser.close(); +})(); diff --git a/playwright/docker-compose.yml b/playwright/docker-compose.yml new file mode 100644 index 0000000..36e816c --- /dev/null +++ b/playwright/docker-compose.yml @@ -0,0 +1,15 @@ +playwright: + image: mcr.microsoft.com/playwright:focal + command: sleep inf + container_name: playwright + user: pwuser + ipc: host + security_opt: + - seccomp=unconfined + volumes: + - ./data:/data + - /usr/lib/node_modules + environment: + - NODE_PATH=/usr/lib/node_modules + working_dir: /data + restart: unless-stopped