Quick start
You need Docker with the Compose plugin, curl, and Node.js 20 or later for the
client example. BrowserThing runs its browsers in containers. You do not need to
install browsers on the client machine.
This local setup runs the service and its browser worker on your machine. For your application deployment, you can move workers to separate hosts so browser CPU and memory use stays off your application servers.
1. Download the configuration
Section titled “1. Download the configuration”Create an empty directory for this deployment. Keep its name unchanged when you upgrade, because Docker Compose uses it to name the database volume.
mkdir browserthingcd browserthingcurl -fsSLO https://mbroton.github.io/browserthing/downloads/docker-compose.yamlcurl -fsSL --create-dirs -o worker/seccomp_profile.json https://raw.githubusercontent.com/mbroton/browserthing/v0.6.0/worker/seccomp_profile.jsonThis site’s Compose file pins both BrowserThing images to 0.6.0. It starts
PostgreSQL, the server, and one Chromium worker with five session slots.
2. Start the service
Section titled “2. Start the service”docker compose up -ddocker compose pscurl -fsS http://localhost:8080/v1/capacityThe first start downloads the images. If the capacity request fails or shows no
workers, wait for startup and try again. Check docker compose logs if the worker
does not register.
3. Run a browser task
Section titled “3. Run a browser task”Install the matching Playwright client:
npm init -ynpm install playwright@1.63.0Save this as preview.mjs. This example saves a screenshot. Replace the task
with the browser actions your application needs:
import { chromium } from 'playwright';
const browser = await chromium.connect('ws://localhost:8080');try { const context = await browser.newContext(); const page = await context.newPage(); await page.goto('https://example.com'); await page.screenshot({ path: 'preview.png', fullPage: true });} finally { await browser.close();}Run it:
node preview.mjsOpen preview.png in the current directory to see the result. The browser runs
on the worker, and Playwright saves the screenshot on the client machine.
Closing the connection releases the session’s resources for the next task.
The client and worker must have the same Playwright major and minor version.
For these images, use 1.63.x.
4. Add capacity or stop
Section titled “4. Add capacity or stop”Start three workers for 15 concurrent session slots:
docker compose up -d --scale worker=3Stop the service and keep its database volume:
docker compose downContinue with connection examples or deployment.