Allow self-hosted deploys locally by pointing to docker.host.internal on macOS (#2064)

This commit is contained in:
Eric Allam
2025-05-16 15:20:48 +01:00
committed by GitHub
parent ad4daa3301
commit a69621bdcc
4 changed files with 15 additions and 5 deletions
+2 -2
View File
@@ -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.
+1 -1
View File
@@ -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
@@ -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,
};
+11 -1
View File
@@ -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 || []),
@@ -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;
}