mirror of
https://github.com/kou029w/_.git
synced 2025-01-30 22:08:02 +00:00
create docker-playwright
This commit is contained in:
parent
cc2a795f5b
commit
bca1a13dcc
2 changed files with 34 additions and 0 deletions
26
docker-playwright/README.md
Normal file
26
docker-playwright/README.md
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# デスクトップ環境で Docker イメージを使って Playwright のブラウザーを起動してみる
|
||||||
|
|
||||||
|
WebKit の環境が必要だったので構築してみた。
|
||||||
|
|
||||||
|
Ubuntu ならば Playwright が公式にサポートしているためホントは不要だが、環境を汚さないので便利かもしれないと思った。
|
||||||
|
|
||||||
|
## 前提
|
||||||
|
|
||||||
|
- Docker
|
||||||
|
- X11 の UNIX ドメインソケットが/tmp/.X11-unix に存在すること
|
||||||
|
|
||||||
|
## やり方
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker run --rm -it -u $(id -u):$(id -g) -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix mcr.microsoft.com/playwright npx playwright wk example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
Digest: `sha256:310e3ca5bb884f4b9a4a8452dbabda4a35ac62a0d6f46eee953558e8d7d4cfb0`
|
||||||
|
|
||||||
|
### Docker Compose の場合
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo UID=$(id -u) >> .env
|
||||||
|
echo GID=$(id -g) >> .env
|
||||||
|
docker-compose up
|
||||||
|
```
|
8
docker-playwright/docker-compose.yml
Normal file
8
docker-playwright/docker-compose.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
playwright:
|
||||||
|
image: mcr.microsoft.com/playwright
|
||||||
|
user: "${UID}:${GID}"
|
||||||
|
environment: [DISPLAY]
|
||||||
|
volumes: ["/tmp/.X11-unix:/tmp/.X11-unix"]
|
||||||
|
command: npx playwright wk example.com
|
Loading…
Add table
Reference in a new issue