refactor(cloud): add deploy to external API

This commit is contained in:
Mauricio Siu
2024-10-04 18:53:46 -06:00
parent 3df2f8e58c
commit 5cebf5540a
10 changed files with 92 additions and 3 deletions
@@ -2,6 +2,8 @@ import { db } from "@/server/db";
import { applications } from "@/server/db/schema";
import type { DeploymentJob } from "@/server/queues/deployments-queue";
import { myQueue } from "@/server/queues/queueSetup";
import { deploy } from "@/server/utils/deploy";
import { IS_CLOUD } from "@dokploy/builders";
import { eq } from "drizzle-orm";
import type { NextApiRequest, NextApiResponse } from "next";
@@ -89,6 +91,12 @@ export default async function handler(
applicationType: "application",
server: !!application.serverId,
};
if (IS_CLOUD && application.serverId) {
jobData.serverId = application.serverId;
await deploy(jobData);
return true;
}
await myQueue.add(
"deployments",
{ ...jobData },