Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/itchy-frogs-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---

Log images sizes for self-hosted deploys
5 changes: 5 additions & 0 deletions .changeset/witty-donkeys-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/build": patch
---

Add playwright extension
6 changes: 6 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ jobs:
unitTests:
name: "🧪 Unit Tests"
runs-on: ubuntu-latest
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
steps:
- name: 🔧 Disable IPv6
run: |
Expand Down Expand Up @@ -52,10 +54,14 @@ jobs:

# ..to avoid rate limits when pulling images
- name: 🐳 Login to DockerHub
if: ${{ env.DOCKERHUB_USERNAME }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 🐳 Skipping DockerHub login (no secrets available)
if: ${{ !env.DOCKERHUB_USERNAME }}
run: echo "DockerHub login skipped because secrets are not available."

- name: 📥 Download deps
run: pnpm install --frozen-lockfile
Expand Down
1 change: 1 addition & 0 deletions docs/config/extensions/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Trigger.dev provides a set of built-in extensions that you can use to customize
| :-------------------------------------------------------------------- | :----------------------------------------------------------------------------- |
| [prismaExtension](/config/extensions/prismaExtension) | Using prisma in your Trigger.dev tasks |
| [pythonExtension](/config/extensions/pythonExtension) | Execute Python scripts in your project |
| [playwright](/config/extensions/playwright) | Use Playwright in your Trigger.dev tasks |
| [puppeteer](/config/extensions/puppeteer) | Use Puppeteer in your Trigger.dev tasks |
| [ffmpeg](/config/extensions/ffmpeg) | Use FFmpeg in your Trigger.dev tasks |
| [aptGet](/config/extensions/aptGet) | Install system packages in your build image |
Expand Down
103 changes: 103 additions & 0 deletions docs/config/extensions/playwright.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
title: "Playwright"
sidebarTitle: "playwright"
description: "Use the playwright build extension to use Playwright with Trigger.dev"
---

If you are using Playwright, you should use the Playwright build extension.

- Automatically installs Playwright and required browser dependencies
- Allows you to specify which browsers to install (chromium, firefox, webkit)
- Supports headless or non-headless mode
- Lets you specify the Playwright version, or auto-detects it
- Installs only the dependencies needed for the selected browsers to optimize build time and image size

You can use it for a simple Playwright setup like this:

```ts
import { defineConfig } from "@trigger.dev/sdk/v3";
import { playwright } from "@trigger.dev/build/extensions/playwright";

export default defineConfig({
project: "<project ref>",
// Your other config settings...
build: {
extensions: [
playwright(),
],
},
});
```

<Note>
This extension only affects the build and deploy process, not the `dev` command.
</Note>

### Options

- `browsers`: Array of browsers to install. Valid values: `"chromium"`, `"firefox"`, `"webkit"`. Default: `["chromium"]`.
- `headless`: Run browsers in headless mode. Default: `true`. If set to `false`, a virtual display (Xvfb) will be set up automatically.
- `version`: Playwright version to install. If not provided, the version will be auto-detected from your dependencies (recommended).

<Warning>
Using a different version in your app than specified here will break things.
</Warning>

### Custom browsers and version

```ts
import { defineConfig } from "@trigger.dev/sdk/v3";
import { playwright } from "@trigger.dev/build/extensions/playwright";

export default defineConfig({
project: "<project ref>",
build: {
extensions: [
playwright({
browsers: ["chromium", "webkit"], // optional, will use ["chromium"] if not provided
version: "1.43.1", // optional, will automatically detect the version if not provided
}),
],
},
});
```

### Headless mode

By default, browsers are run in headless mode. If you need to run browsers with a UI (for example, for debugging), set `headless: false`. This will automatically set up a virtual display using Xvfb.

```ts
import { defineConfig } from "@trigger.dev/sdk/v3";
import { playwright } from "@trigger.dev/build/extensions/playwright";

export default defineConfig({
project: "<project ref>",
build: {
extensions: [
playwright({
headless: false,
}),
],
},
});
```

### Environment variables

The extension sets the following environment variables during the build:

- `PLAYWRIGHT_BROWSERS_PATH`: Set to `/ms-playwright` so Playwright finds the installed browsers
- `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD`: Set to `1` to skip browser download at runtime
- `PLAYWRIGHT_SKIP_BROWSER_VALIDATION`: Set to `1` to skip browser validation at runtime
- `DISPLAY`: Set to `:99` if `headless: false` (for Xvfb)

### Notes

- The extension installs only the dependencies required for the browsers you select, reducing build time and image size.
- Playwright is installed globally in the build image.
- The extension does not affect local development (`dev` command), only the build and deploy process.
- Only specify the Playwright version in the options if automatic detection is not working.

<Note>
For more information about Playwright, see the [official Playwright documentation](https://playwright.dev/).
</Note>
1 change: 1 addition & 0 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"pages": [
"config/extensions/prismaExtension",
"config/extensions/pythonExtension",
"config/extensions/playwright",
"config/extensions/puppeteer",
"config/extensions/ffmpeg",
"config/extensions/aptGet",
Expand Down
17 changes: 16 additions & 1 deletion packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"./extensions/prisma": "./src/extensions/prisma.ts",
"./extensions/audioWaveform": "./src/extensions/audioWaveform.ts",
"./extensions/typescript": "./src/extensions/typescript.ts",
"./extensions/puppeteer": "./src/extensions/puppeteer.ts"
"./extensions/puppeteer": "./src/extensions/puppeteer.ts",
"./extensions/playwright": "./src/extensions/playwright.ts"
},
"sourceDialects": [
"@triggerdotdev/source"
Expand Down Expand Up @@ -57,6 +58,9 @@
],
"extensions/puppeteer": [
"dist/commonjs/extensions/puppeteer.d.ts"
],
"extensions/playwright": [
"dist/commonjs/extensions/playwright.d.ts"
]
}
},
Expand Down Expand Up @@ -173,6 +177,17 @@
"types": "./dist/commonjs/extensions/puppeteer.d.ts",
"default": "./dist/commonjs/extensions/puppeteer.js"
}
},
"./extensions/playwright": {
"import": {
"@triggerdotdev/source": "./src/extensions/playwright.ts",
"types": "./dist/esm/extensions/playwright.d.ts",
"default": "./dist/esm/extensions/playwright.js"
},
"require": {
"types": "./dist/commonjs/extensions/playwright.d.ts",
"default": "./dist/commonjs/extensions/playwright.js"
}
}
},
"main": "./dist/commonjs/index.js",
Expand Down
Loading