Skip to content

Allow self-hosted deploys locally without using tunnel #2064

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 1 commit into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ branch are tagged into a release periodically.
```
pnpm run db:migrate
```
10. Build the server app
10. Build everything
```
pnpm run build --filter webapp
pnpm run build --filter webapp && pnpm run build --filter trigger.dev && pnpm run build --filter @trigger.dev/sdk
```
11. Run the app. See the section below.

Expand Down
2 changes: 1 addition & 1 deletion apps/supervisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TRIGGER_WORKER_TOKEN=tr_wgt_...
pnpm dev
```

4. Build CLI, then deploy a reference project
4. Build CLI, then deploy a test project

```sh
pnpm exec trigger deploy --self-hosted
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/app/routes/api.v1.projects.$projectRef.$env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const result: GetProjectEnvResponse = {
apiKey: runtimeEnv.apiKey,
name: project.name,
apiUrl: processEnv.APP_ORIGIN,
apiUrl: processEnv.API_ORIGIN ?? processEnv.APP_ORIGIN,
projectId: project.id,
};

Expand Down
12 changes: 11 additions & 1 deletion packages/cli-v3/src/deploy/buildImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ async function selfHostedBuildImage(
"--build-arg",
`TRIGGER_PROJECT_REF=${options.projectRef}`,
"--build-arg",
`TRIGGER_API_URL=${options.apiUrl}`,
`TRIGGER_API_URL=${normalizeApiUrlForBuild(options.apiUrl)}`,
"--build-arg",
`TRIGGER_SECRET_KEY=${options.apiKey}`,
...(buildArgs || []),
Expand Down Expand Up @@ -723,3 +723,13 @@ ENTRYPOINT [ "dumb-init", "node", "${options.entrypoint}" ]
CMD []
`;
}

// If apiUrl is something like http://localhost:3030, AND we are on macOS, we need to convert it to http://host.docker.internal:3030
// this way the indexing will work because the docker image can reach the local server
function normalizeApiUrlForBuild(apiUrl: string) {
if (process.platform === "darwin") {
return apiUrl.replace("localhost", "host.docker.internal");
}

return apiUrl;
}