-
-
Notifications
You must be signed in to change notification settings - Fork 724
Fix: fixes and prerequisites for v4 self-hosting #2150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4c4dbf6
remove pgadmin
nicktrn 42d61fa
remove V3_ENABLED
nicktrn 7b25885
v3 is always enabled
nicktrn 0562485
Merge remote-tracking branch 'origin/main' into v4/self-hosting
nicktrn 35aaaf6
enfore docker machine presets by default
nicktrn 8f78d3d
rename autoremove env var
nicktrn 4b5adbf
prefix more k8s-specific env vars
nicktrn a4e2515
same prefix for all docker settings
nicktrn 0f0967d
improve profile switcher copy
nicktrn ceab383
supervisor can load token from file
nicktrn f142a5e
optional webapp worker group bootstrap
nicktrn 45c1ea0
fix error message
nicktrn 43df3b3
fix app origin fallback for otlp endpoint
nicktrn 10ba001
use pnpm cache for webapp docker builds
nicktrn 86cdea9
increase default org and env concurrency limit to 100
nicktrn 141590f
optional machine preset overrides
nicktrn 0ec2984
Merge remote-tracking branch 'origin/main' into v4/self-hosting
nicktrn 57238b0
Merge remote-tracking branch 'origin/main' into v4/self-hosting
nicktrn 8f6e8be
Merge remote-tracking branch 'origin/main' into v4/self-hosting
nicktrn 54ac089
improve s3 pre-signing errors
nicktrn c69cb4b
fix DOCKER_ENFORCE_MACHINE_PRESETS bool coercion
nicktrn 918542c
shard unit tests
nicktrn b803efb
Merge remote-tracking branch 'origin/main' into v4/self-hosting
nicktrn 7a14cb5
fix for s3-compatible services
nicktrn 0e82bc0
optional object store region
nicktrn 4cf8a55
Merge remote-tracking branch 'origin/main' into v4/self-hosting
nicktrn 1f19a8c
Merge remote-tracking branch 'origin/main' into v4/self-hosting
nicktrn 5c5f117
Update apps/supervisor/src/workerToken.ts
nicktrn 5b7c729
fix DEPLOY_REGISTRY_HOST example
nicktrn 3851ffd
fix platform mock
nicktrn fb257fc
remove remaining v3Enabled refs
nicktrn 49f63b7
fix error type.. bad bot
nicktrn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"trigger.dev": patch | ||
--- | ||
|
||
Update profile switcher |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,8 +62,6 @@ branch are tagged into a release periodically. | |
pnpm run docker | ||
``` | ||
|
||
This will also start and run a local instance of [pgAdmin](https://www.pgadmin.org/) on [localhost:5480](http://localhost:5480), preconfigured with email `[email protected]` and pwd `admin`. Then use `postgres` as the password to the Trigger.dev server. | ||
|
||
9. Migrate the database | ||
``` | ||
pnpm run db:migrate | ||
|
@@ -94,13 +92,11 @@ We use the `<root>/references/v3-catalog` subdirectory as a staging ground for t | |
|
||
First, make sure you are running the webapp according to the instructions above. Then: | ||
|
||
1. In Postgres go to the "Organizations" table and on your org set the `v3Enabled` column to `true`. | ||
|
||
2. Visit http://localhost:3030 in your browser and create a new V3 project called "v3-catalog". If you don't see an option for V3, you haven't set the `v3Enabled` flag to true. | ||
1. Visit http://localhost:3030 in your browser and create a new V3 project called "v3-catalog". | ||
|
||
3. In Postgres go to the "Projects" table and for the project you create change the `externalRef` to `yubjwjsfkxnylobaqvqz`. | ||
2. In Postgres go to the "Projects" table and for the project you create change the `externalRef` to `yubjwjsfkxnylobaqvqz`. | ||
|
||
4. Build the CLI | ||
3. Build the CLI | ||
|
||
```sh | ||
# Build the CLI | ||
|
@@ -109,7 +105,7 @@ pnpm run build --filter trigger.dev | |
pnpm i | ||
``` | ||
|
||
5. Change into the `<root>/references/v3-catalog` directory and authorize the CLI to the local server: | ||
4. Change into the `<root>/references/v3-catalog` directory and authorize the CLI to the local server: | ||
|
||
```sh | ||
cd references/v3-catalog | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { readFileSync } from "fs"; | ||
import { env } from "./env.js"; | ||
|
||
export function getWorkerToken() { | ||
if (!env.TRIGGER_WORKER_TOKEN.startsWith("file://")) { | ||
return env.TRIGGER_WORKER_TOKEN; | ||
} | ||
|
||
const tokenPath = env.TRIGGER_WORKER_TOKEN.replace("file://", ""); | ||
|
||
console.debug( | ||
JSON.stringify({ | ||
message: "🔑 Reading worker token from file", | ||
tokenPath, | ||
}) | ||
); | ||
|
||
try { | ||
const token = readFileSync(tokenPath, "utf8").trim(); | ||
return token; | ||
} catch (error) { | ||
console.error(`Failed to read worker token from file: ${tokenPath}`, error); | ||
throw new Error( | ||
`Unable to read worker token from file: ${ | ||
error instanceof Error ? error.message : "Unknown error" | ||
}` | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { mkdir, writeFile } from "fs/promises"; | ||
import { prisma } from "./db.server"; | ||
import { env } from "./env.server"; | ||
import { WorkerGroupService } from "./v3/services/worker/workerGroupService.server"; | ||
import { dirname } from "path"; | ||
import { tryCatch } from "@trigger.dev/core"; | ||
|
||
export async function bootstrap() { | ||
if (env.TRIGGER_BOOTSTRAP_ENABLED !== "1") { | ||
return; | ||
} | ||
|
||
if (env.TRIGGER_BOOTSTRAP_WORKER_GROUP_NAME) { | ||
const [error] = await tryCatch(createWorkerGroup()); | ||
if (error) { | ||
console.error("Failed to create worker group", { error }); | ||
} | ||
} | ||
} | ||
|
||
async function createWorkerGroup() { | ||
const workerGroupName = env.TRIGGER_BOOTSTRAP_WORKER_GROUP_NAME; | ||
const tokenPath = env.TRIGGER_BOOTSTRAP_WORKER_TOKEN_PATH; | ||
|
||
const existingWorkerGroup = await prisma.workerInstanceGroup.findFirst({ | ||
where: { | ||
name: workerGroupName, | ||
}, | ||
}); | ||
|
||
if (existingWorkerGroup) { | ||
console.warn(`[bootstrap] Worker group ${workerGroupName} already exists`); | ||
return; | ||
} | ||
|
||
const service = new WorkerGroupService(); | ||
const { token, workerGroup } = await service.createWorkerGroup({ | ||
name: workerGroupName, | ||
}); | ||
|
||
console.log(` | ||
========================== | ||
Trigger.dev Bootstrap - Worker Token | ||
|
||
WARNING: This will only be shown once. Save it now! | ||
|
||
Worker group: | ||
${workerGroup.name} | ||
|
||
Token: | ||
${token.plaintext} | ||
|
||
If using docker compose, set: | ||
TRIGGER_WORKER_TOKEN=${token.plaintext} | ||
|
||
${ | ||
tokenPath | ||
? `Or, if using a file: | ||
TRIGGER_WORKER_TOKEN=file://${tokenPath}` | ||
: "" | ||
} | ||
|
||
========================== | ||
`); | ||
|
||
if (tokenPath) { | ||
const dir = dirname(tokenPath); | ||
await mkdir(dir, { recursive: true }); | ||
await writeFile(tokenPath, token.plaintext, { | ||
mode: 0o600, | ||
}); | ||
|
||
console.log(`[bootstrap] Worker token saved to ${tokenPath}`); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.