Skip to content

Commit f18eacb

Browse files
committed
webapp-driven deploys, multi-platform support, lots of fixes
1 parent 6712571 commit f18eacb

File tree

23 files changed

+419
-306
lines changed

23 files changed

+419
-306
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ CLOUD_SLACK_CLIENT_SECRET=
8080
PROVIDER_SECRET=provider-secret # generate the actual secret with `openssl rand -hex 32`
8181
COORDINATOR_SECRET=coordinator-secret # generate the actual secret with `openssl rand -hex 32`
8282

83+
# DEPOT_ORG_ID=<Depot org id>
8384
# DEPOT_TOKEN=<Depot org token>
84-
# DEPOT_PROJECT_ID=<Depot project id>
8585
# DEPLOY_REGISTRY_HOST=${APP_ORIGIN} # This is the host that the deploy CLI will use to push images to the registry
8686
# DEV_OTEL_EXPORTER_OTLP_ENDPOINT="http://0.0.0.0:4318"
8787
# These are needed for the object store (for handling large payloads/outputs)

apps/webapp/app/entry.server.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,14 @@ import { env } from "./env.server";
221221
import { logger } from "./services/logger.server";
222222
import { Prisma } from "./db.server";
223223
import { registerRunEngineEventBusHandlers } from "./v3/runEngineHandlers.server";
224+
import { remoteBuildsEnabled } from "./v3/remoteImageBuilder.server";
224225

225226
if (env.EVENT_LOOP_MONITOR_ENABLED === "1") {
226227
eventLoopMonitor.enable();
227228
}
229+
230+
if (remoteBuildsEnabled()) {
231+
console.log("🏗️ Remote builds enabled");
232+
} else {
233+
console.log("🏗️ Local builds enabled");
234+
}

apps/webapp/app/env.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,13 @@ const EnvironmentSchema = z.object({
264264
PROVIDER_SECRET: z.string().default("provider-secret"),
265265
COORDINATOR_SECRET: z.string().default("coordinator-secret"),
266266
DEPOT_TOKEN: z.string().optional(),
267-
DEPOT_PROJECT_ID: z.string().optional(),
268267
DEPOT_ORG_ID: z.string().optional(),
269268
DEPOT_REGION: z.string().default("us-east-1"),
270-
DEPLOY_REGISTRY_HOST: z.string().optional(),
269+
DEPLOY_REGISTRY_HOST: z.string(),
271270
DEPLOY_REGISTRY_USERNAME: z.string().optional(),
272271
DEPLOY_REGISTRY_PASSWORD: z.string().optional(),
273272
DEPLOY_REGISTRY_NAMESPACE: z.string().default("trigger"),
273+
DEPLOY_BUILD_PLATFORM: z.string().default("linux/amd64"),
274274
DEPLOY_TIMEOUT_MS: z.coerce
275275
.number()
276276
.int()

apps/webapp/app/presenters/v3/DeploymentPresenter.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export class DeploymentPresenter {
7474
version: true,
7575
errorData: true,
7676
imageReference: true,
77+
imagePlatform: true,
7778
externalBuildData: true,
7879
projectId: true,
7980
type: true,
@@ -157,6 +158,7 @@ export class DeploymentPresenter {
157158
sdkVersion: deployment.worker?.sdkVersion,
158159
cliVersion: deployment.worker?.cliVersion,
159160
imageReference: deployment.imageReference,
161+
imagePlatform: deployment.imagePlatform,
160162
externalBuildData:
161163
externalBuildData && externalBuildData.success ? externalBuildData.data : undefined,
162164
projectId: deployment.projectId,

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.deployments.$deploymentParam/route.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ export default function Page() {
9191
<Property.Value>{deployment.imageReference}</Property.Value>
9292
</Property.Item>
9393
)}
94+
<Property.Item>
95+
<Property.Label>Platform</Property.Label>
96+
<Property.Value>{deployment.imagePlatform}</Property.Value>
97+
</Property.Item>
9498
{deployment.externalBuildData && (
9599
<Property.Item>
96100
<Property.Label>Build Server</Property.Label>

apps/webapp/app/routes/api.v1.deployments.$deploymentId.background-workers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { authenticateApiRequest } from "~/services/apiAuth.server";
55
import { logger } from "~/services/logger.server";
66
import { ServiceValidationError } from "~/v3/services/baseService.server";
77
import { CreateDeclarativeScheduleError } from "~/v3/services/createBackgroundWorker.server";
8-
import { CreateDeploymentBackgroundWorkerService } from "~/v3/services/createDeploymentBackgroundWorker.server";
8+
import { CreateDeploymentBackgroundWorkerServiceV4 } from "~/v3/services/createDeploymentBackgroundWorkerV4.server";
99

1010
const ParamsSchema = z.object({
1111
deploymentId: z.string(),
@@ -42,7 +42,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
4242
return json({ error: "Invalid body", issues: body.error.issues }, { status: 400 });
4343
}
4444

45-
const service = new CreateDeploymentBackgroundWorkerService();
45+
const service = new CreateDeploymentBackgroundWorkerServiceV4();
4646

4747
try {
4848
const backgroundWorker = await service.call(authenticatedEnv, deploymentId, body.data);
@@ -63,7 +63,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
6363
logger.error("Failed to create background worker", { error: e });
6464

6565
if (e instanceof ServiceValidationError) {
66-
return json({ error: e.message }, { status: 400 });
66+
return json({ error: e.message }, { status: e.status ?? 400 });
6767
} else if (e instanceof CreateDeclarativeScheduleError) {
6868
return json({ error: e.message }, { status: 400 });
6969
}

apps/webapp/app/routes/api.v1.deployments.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
InitializeDeploymentRequestBody,
44
InitializeDeploymentResponseBody,
55
} from "@trigger.dev/core/v3";
6-
import { env } from "~/env.server";
76
import { authenticateApiRequest } from "~/services/apiAuth.server";
87
import { logger } from "~/services/logger.server";
98
import { ServiceValidationError } from "~/v3/services/baseService.server";
@@ -35,7 +34,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
3534
const service = new InitializeDeploymentService();
3635

3736
try {
38-
const { deployment, imageTag } = await service.call(authenticatedEnv, body.data);
37+
const { deployment, imageRef } = await service.call(authenticatedEnv, body.data);
3938

4039
const responseBody: InitializeDeploymentResponseBody = {
4140
id: deployment.friendlyId,
@@ -44,8 +43,8 @@ export async function action({ request, params }: ActionFunctionArgs) {
4443
version: deployment.version,
4544
externalBuildData:
4645
deployment.externalBuildData as InitializeDeploymentResponseBody["externalBuildData"],
47-
imageTag,
48-
registryHost: body.data.registryHost ?? env.DEPLOY_REGISTRY_HOST,
46+
imageTag: imageRef,
47+
imagePlatform: deployment.imagePlatform,
4948
};
5049

5150
return json(responseBody, { status: 200 });

apps/webapp/app/services/runsReplicationInstance.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ function initializeRunsReplicationInstance() {
1616
invariant(typeof DATABASE_URL === "string", "DATABASE_URL env var not set");
1717

1818
if (!env.RUN_REPLICATION_CLICKHOUSE_URL) {
19-
console.log("🗃️ Runs replication service not enabled");
19+
console.log("🗃️ Runs replication service not enabled");
2020
return;
2121
}
2222

23-
console.log("🗃️ Runs replication service enabled");
23+
console.log("🗃️ Runs replication service enabled");
2424

2525
const clickhouse = new ClickHouse({
2626
url: env.RUN_REPLICATION_CLICKHOUSE_URL,

apps/webapp/app/v3/handleSocketIo.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { engine } from "./runEngine.server";
2828
import { CompleteAttemptService } from "./services/completeAttempt.server";
2929
import { CrashTaskRunService } from "./services/crashTaskRun.server";
3030
import { CreateCheckpointService } from "./services/createCheckpoint.server";
31-
import { CreateDeployedBackgroundWorkerService } from "./services/createDeployedBackgroundWorker.server";
31+
import { CreateDeploymentBackgroundWorkerServiceV3 } from "./services/createDeploymentBackgroundWorkerV3.server";
3232
import { CreateTaskRunAttemptService } from "./services/createTaskRunAttempt.server";
3333
import { DeploymentIndexFailed } from "./services/deploymentIndexFailed.server";
3434
import { ResumeAttemptService } from "./services/resumeAttempt.server";
@@ -245,7 +245,7 @@ function createCoordinatorNamespace(io: Server) {
245245
return { success: false };
246246
}
247247

248-
const service = new CreateDeployedBackgroundWorkerService();
248+
const service = new CreateDeploymentBackgroundWorkerServiceV3();
249249
const worker = await service.call(message.projectRef, environment, message.deploymentId, {
250250
localOnly: false,
251251
metadata: message.metadata,

apps/webapp/app/v3/remoteImageBuilder.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ async function createBuilderProjectIfNotExists(project: Project) {
5959
}
6060

6161
export function remoteBuildsEnabled() {
62-
return env.DEPOT_TOKEN && env.DEPOT_PROJECT_ID && env.DEPOT_ORG_ID && env.DEPOT_REGION;
62+
return env.DEPOT_TOKEN && env.DEPOT_ORG_ID && env.DEPOT_REGION;
6363
}

0 commit comments

Comments
 (0)