Skip to content

Commit

Permalink
docs: Update README with info about building local container image
Browse files Browse the repository at this point in the history
  • Loading branch information
ahwayakchih committed Jan 14, 2025
1 parent 40ae437 commit d1f08ca
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Changelog
- Improved error output when private key cannot be loaded
- Updated example ZIP and CRX binaries because tests failed on differences in compression ratio (of exactly the same sources!)
- Dropped use of runners on AppVeyor (Windows) and Cirrus CI (Linux & MacOS)
- Added puppeteer.containerfile and usage info

**v1.1.3** - 2020-11-06

Expand Down
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Tests include optional support for checking if CRX files built by the module wil

- make sure that Chrome or Chromium browser is already installed,
- make sure that `CHROME_BIN` environment variable is set with path to the browser's executable,
- make sure that `CHROME_POLICIES` environment variable points to exisitng directory tree used by the browser to read policies,
- make sure that `CHROME_POLICIES` environment variable points to existing directory tree used by the browser to read policies,
- optionally set `DEBUG` environment variable to `true`, to get additional output from test server,
- optionally set `FILE_CHECK_DELAY` environment variable to number of milliseconds to wait for between various checks (defaults to 1500),
- run `npm run puppeteer` to install additional dependencies.
Expand All @@ -156,14 +156,38 @@ Tests include optional support for checking if CRX files built by the module wil

**WARNING:** Since there is no way to imitate installation process of a CRX file through the puppeteer (or is there?), test will try to create an `${CHROME_POLICIES}/managed/crx3-example-extension-test.json` policy file to "force install" it. That is why it is best to run whole thing in a virtual machine, e.g., using [`qemu`](https://www.qemu.org/), or in a container, e.g., using [`podman`](https://podman.io/) or [`docker`](https://www.docker.com/).

Using `podman`:
There is an official puppeteer docker image, but it's ~2 GB, which is unnecessarily huge. Using `podman` or `docker`, you can build image that's less than half of that size and is more than enough for testing if generated CRX3 works in a Chromium browser.

### Testing with rootless `podman`

First step is to prepare container image. This step is needed only once.

```sh
# 1. Prepare container, this step is needed only once
podman build -t puppeteer -f puppeteer.containerfile
# 2. Install puppeteer-core, this step is needed only once
podman run --rm --init -v $(pwd):/app -w /app --userns=keep-id -it puppeteer:latest npm run puppeteer
```

After container image is ready, every time you want to run test, just use:

```sh
podman run --rm -v $(pwd):/app -v $(pwd)/node_modules:/app/node_modules --userns=keep-id -it ahwayakchih/nodeapp:puppeteer xvfb-run npm test
podman run --rm --init -v $(pwd):/app -w /app --userns=keep-id -it puppeteer:latest xvfb-run npm test
```

Using `docker`:
### Testing with `docker`

First step is to prepare container image. This step is needed only once.

```sh
docker run --rm -v $(pwd):/app -v $(pwd)/node_modules:/app/node_modules -it ahwayakchih/nodeapp:puppeteer xvfb-run npm test
# 1. Prepare container, this step is needed only once
docker build -t puppeteer -f puppeteer.containerfile
# 2. Install puppeteer-core, this step is needed only once
docker run --rm --init -v $(pwd):/app -w /app -it puppeteer:latest npm run puppeteer
```

After container image is ready, every time you want to run test, just use:

```sh
docker run --rm --init -v $(pwd):/app -w /app -it puppeteer:latest xvfb-run npm test
```

0 comments on commit d1f08ca

Please sign in to comment.