Container setup for browser flows
Use container mode when your app has no PR preview. Code Hawk mounts the pull request checkout into a trusted application image and runs your start command from the checkout. The image supplies tools and system dependencies. The checkout supplies the app under test.
1. Prepare a seeded app
Section titled “1. Prepare a seeded app”Use a start command that initializes a fresh test database before serving the app. Seed the accounts, passwords and authenticator seeds named in .github/codehawk-flows.json. Bind to 127.0.0.1:3000 on a Linux runner, or set the caller's base_url to your app's address. Use test-only credentials and make the root URL return HTTP 2xx for the readiness probe.
For a sample Node repository, save the following as e2e-server.mjs. Each process seeds one in-memory user. The sample accepts any six-digit code to exercise the driver's two-step form. Keep this fixture in a sample app and use your app's normal authenticator in a real test environment.
import { createServer } from 'node:http';import { text } from 'node:stream/consumers';
const owner = { email: 'owner@example.test', password: 'fixture-only-password' };const form = (target, fields) => `<form method="post" action="${target}">${fields}<button>Sign in</button></form>`;
createServer(async (request, response) => { const { method, url } = request; response.setHeader('content-type', 'text/html; charset=utf-8'); if (method === 'GET' && url === '/') return response.end('Ready'); if (method === 'GET' && url === '/sign-in') { return response.end(form('/sign-in', '<label>Email <input name="email" type="email"></label>' + '<label>Password <input name="password" type="password"></label>')); } if (method === 'GET' && url === '/app' && request.headers.cookie === 'fixture=owner') { return response.end('<h1>Overview</h1>'); } if (method === 'POST' && (url === '/sign-in' || url === '/verify')) { const body = new URLSearchParams(await text(request)); if (url === '/sign-in' && body.get('email') === owner.email && body.get('password') === owner.password) { return response.end(form('/verify', '<label>Six-digit code <input name="code"></label>')); } if (url === '/verify' && /^[0-9]{6}$/.test(body.get('code') ?? '')) { response.writeHead(303, { location: '/app', 'set-cookie': 'fixture=owner; Path=/; HttpOnly; SameSite=Lax' }); return response.end(); } } response.writeHead(404).end('Page not found');}).listen(3000, '127.0.0.1');Create a package.json with npm init -y, then use npm install --save-dev --save-exact @playwright/test@1.63.0 and commit both npm files. Copy the sample flow library to .github/codehawk-flows.json. Its fixture user and Overview flow match this app. The reusable workflow installs this Playwright package inside a container and supplies the matching browser image.
2. Build and publish pinned images
Section titled “2. Build and publish pinned images”Save this starter Dockerfile at the repository root. It contains only the runtime needed by the sample. Add system dependencies to the runtime stage for your app, using a reviewed base image digest. Code Hawk runs commands from the mounted checkout, so keep application source and credentials out of these reusable images.
FROM node:24-bookworm@sha256:934240a162082fd8b8a2f90cd5114446443f1eba1c5378f6687167ca405e6584 AS runtime
FROM runtime AS app
FROM runtime AS testENV CI=trueSave the following as .github/workflows/codehawk-images.yml on the default branch. Run Publish Code Hawk images from that branch in the Actions tab. The job uses GitHub's package token to publish the containers and writes the immutable references in its run summary. It needs no model key or storage credentials. Docker Buildx metadata · GitHub Container registry
name: Publish Code Hawk images
on: workflow_dispatch:
permissions: {}
jobs: publish: if: github.ref_name == github.event.repository.default_branch && github.ref_type == 'branch' runs-on: ubuntu-24.04 permissions: contents: read packages: write steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false - name: Build trusted images env: REGISTRY_TOKEN: ${{ github.token }} run: | set -euo pipefail printf '%s' "$REGISTRY_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin for target in app test; do image="ghcr.io/${GITHUB_REPOSITORY,,}/codehawk-$target" metadata="$RUNNER_TEMP/codehawk-$target.json" docker buildx build --platform linux/amd64 --target "$target" --push \ --label "org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \ --tag "$image:$GITHUB_SHA" --metadata-file "$metadata" . digest=$(jq -er '."containerimage.digest"' "$metadata") printf '`%s@%s`\n\n' "$image" "$digest" >> "$GITHUB_STEP_SUMMARY" doneFor this sample, make the two runtime packages anonymously pullable so the called workflows can fetch them without registry credentials. Verify you can docker pull both digest references from a machine signed out of that registry. For a private runtime, arrange authenticated pulls on a trusted runner before invoking the action.
3. Set the variables and run a pull request
Section titled “3. Set the variables and run a pull request”In Settings → Secrets and variables → Actions → Variables, copy the references from the build summary. Use the full image@sha256:… reference for each value.
| Variable | Where to use it |
|---|---|
CODEHAWK_APPLICATION_IMAGE |
Pass the codehawk-app reference as application_image to the browser workflow. |
CODEHAWK_TEST_IMAGE |
Pass the codehawk-test reference as install_image for the sample browser workflow. Use it as test_image for verified fixes if that image provides your test tools. |
Add the browser caller to the default branch. Set application_command to '["node","e2e-server.mjs"]' and add install_image: ${{ vars.CODEHAWK_TEST_IMAGE }} under with. Keep base_url: http://localhost:3000. Remove application_env and CODEHAWK_APPLICATION_ENV for this sample, which has no external database. For an existing app, pass a command such as '["npm","run","e2e:serve"]' that seeds and starts the app in the container. The action passes this array directly to Docker.
Install CodeHawk App and set up your model and key. Configure the private recording bucket and its credentials. Open a non-draft pull request from a branch in the same repository and apply hawk-browser-flows. In the report, check that Open Overview passed and open its recording. Use the local run to debug without a bucket or App token.