|
1 | 1 | import type { BuildExtension } from "@trigger.dev/core/v3/build"; |
2 | 2 |
|
| 3 | +const NAME = 'LightpandaExtension' |
| 4 | + |
3 | 5 | type LightpandaOpts = { |
4 | 6 | arch?: 'aarch64' | 'x86_64' |
5 | 7 | version?: 'nightly' |
| 8 | + disableTelemetry?: boolean |
6 | 9 | } |
7 | 10 |
|
8 | | -export const lightpanda = ({ arch = 'x86_64', version = 'nightly' }: LightpandaOpts = {}): BuildExtension => ({ |
9 | | - name: "LightpandaExtension", |
| 11 | +export const lightpanda = ({ arch = 'x86_64', version = 'nightly', disableTelemetry = false }: LightpandaOpts = {}): BuildExtension => ({ |
| 12 | + name: NAME, |
10 | 13 | onBuildComplete: async (context) => { |
| 14 | + context.logger.progress(`Running ${NAME} on ${context.target} env for arch ${arch}`); |
| 15 | + context.logger.progress(`version: ${version}`); |
| 16 | + |
11 | 17 | if (context.target === "dev") { |
12 | 18 | return |
13 | 19 | } |
14 | 20 |
|
15 | | - context.logger.debug(lightpanda.name); |
| 21 | + const instructions: string[] = [] |
| 22 | + |
| 23 | + if (disableTelemetry) { |
| 24 | + instructions.push('RUN export LIGHTPANDA_DISABLE_TELEMETRY=true') |
| 25 | + } |
| 26 | + |
| 27 | + /* Update / install required packages */ |
| 28 | + instructions.push( |
| 29 | + `RUN apt-get update && apt-get install --no-install-recommends -y \ |
| 30 | + curl \ |
| 31 | + ca-certificates \ |
| 32 | + && update-ca-certificates \ |
| 33 | + && apt-get clean && rm -rf /var/lib/apt/lists/*`, |
| 34 | + ) |
| 35 | + |
| 36 | + /* Install Lightpanda */ |
| 37 | + instructions.push( |
| 38 | + `RUN curl -L -o lightpanda https://github.com/lightpanda-io/browser/releases/download/${version}/lightpanda-${arch}-linux`, |
| 39 | + 'RUN chmod a+x ./lightpanda', |
| 40 | + 'RUN mv ./lightpanda /usr/bin/lightpanda', |
| 41 | + ) |
| 42 | + |
16 | 43 | context.addLayer({ |
17 | 44 | id: "lightpanda", |
18 | 45 | image: { |
19 | | - instructions: [ |
20 | | - `RUN apt-get update && apt-get install curl -y \ && |
21 | | - curl -L -o lightpanda https://github.com/lightpanda-io/browser/releases/download/${version}/lightpanda-${arch}-linux \ && |
22 | | - chmod a+x ./lightpanda`, |
23 | | - ], |
| 46 | + instructions, |
| 47 | + }, |
| 48 | + deploy: { |
| 49 | + env: { |
| 50 | + LIGHTPANDA_BROWSER_PATH: "/usr/bin/lightpanda", |
| 51 | + }, |
| 52 | + override: true, |
24 | 53 | }, |
25 | 54 | }) |
26 | 55 | }, |
|
0 commit comments