Skip to content

Commit a69621b

Browse files
authored
Allow self-hosted deploys locally by pointing to docker.host.internal on macOS (#2064)
1 parent ad4daa3 commit a69621b

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ branch are tagged into a release periodically.
6868
```
6969
pnpm run db:migrate
7070
```
71-
10. Build the server app
71+
10. Build everything
7272
```
73-
pnpm run build --filter webapp
73+
pnpm run build --filter webapp && pnpm run build --filter trigger.dev && pnpm run build --filter @trigger.dev/sdk
7474
```
7575
11. Run the app. See the section below.
7676

apps/supervisor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ TRIGGER_WORKER_TOKEN=tr_wgt_...
3636
pnpm dev
3737
```
3838

39-
4. Build CLI, then deploy a reference project
39+
4. Build CLI, then deploy a test project
4040

4141
```sh
4242
pnpm exec trigger deploy --self-hosted

apps/webapp/app/routes/api.v1.projects.$projectRef.$env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
8888
const result: GetProjectEnvResponse = {
8989
apiKey: runtimeEnv.apiKey,
9090
name: project.name,
91-
apiUrl: processEnv.APP_ORIGIN,
91+
apiUrl: processEnv.API_ORIGIN ?? processEnv.APP_ORIGIN,
9292
projectId: project.id,
9393
};
9494

packages/cli-v3/src/deploy/buildImage.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ async function selfHostedBuildImage(
327327
"--build-arg",
328328
`TRIGGER_PROJECT_REF=${options.projectRef}`,
329329
"--build-arg",
330-
`TRIGGER_API_URL=${options.apiUrl}`,
330+
`TRIGGER_API_URL=${normalizeApiUrlForBuild(options.apiUrl)}`,
331331
"--build-arg",
332332
`TRIGGER_SECRET_KEY=${options.apiKey}`,
333333
...(buildArgs || []),
@@ -723,3 +723,13 @@ ENTRYPOINT [ "dumb-init", "node", "${options.entrypoint}" ]
723723
CMD []
724724
`;
725725
}
726+
727+
// If apiUrl is something like http://localhost:3030, AND we are on macOS, we need to convert it to http://host.docker.internal:3030
728+
// this way the indexing will work because the docker image can reach the local server
729+
function normalizeApiUrlForBuild(apiUrl: string) {
730+
if (process.platform === "darwin") {
731+
return apiUrl.replace("localhost", "host.docker.internal");
732+
}
733+
734+
return apiUrl;
735+
}

0 commit comments

Comments
 (0)