-
-
-
-
+
+
+
+
diff --git a/apps/dokploy/server/api/routers/server.ts b/apps/dokploy/server/api/routers/server.ts
index 8a01228f8..3b0985e43 100644
--- a/apps/dokploy/server/api/routers/server.ts
+++ b/apps/dokploy/server/api/routers/server.ts
@@ -124,10 +124,30 @@ export const serverRouter = createTRPCRouter({
isNotNull(server.sshKeyId),
eq(server.organizationId, ctx.session.activeOrganizationId),
eq(server.serverStatus, "active"),
+ eq(server.serverType, "deploy"),
)
: and(
isNotNull(server.sshKeyId),
eq(server.organizationId, ctx.session.activeOrganizationId),
+ eq(server.serverType, "deploy"),
+ ),
+ });
+ return result;
+ }),
+ buildServers: protectedProcedure.query(async ({ ctx }) => {
+ const result = await db.query.server.findMany({
+ orderBy: desc(server.createdAt),
+ where: IS_CLOUD
+ ? and(
+ isNotNull(server.sshKeyId),
+ eq(server.organizationId, ctx.session.activeOrganizationId),
+ eq(server.serverStatus, "active"),
+ eq(server.serverType, "build"),
+ )
+ : and(
+ isNotNull(server.sshKeyId),
+ eq(server.organizationId, ctx.session.activeOrganizationId),
+ eq(server.serverType, "build"),
),
});
return result;
diff --git a/packages/server/src/db/schema/application.ts b/packages/server/src/db/schema/application.ts
index f3e402cc5..a7bf83ad5 100644
--- a/packages/server/src/db/schema/application.ts
+++ b/packages/server/src/db/schema/application.ts
@@ -204,6 +204,15 @@ export const applications = pgTable("application", {
serverId: text("serverId").references(() => server.serverId, {
onDelete: "cascade",
}),
+ buildServerId: text("buildServerId").references(() => server.serverId, {
+ onDelete: "set null",
+ }),
+ buildRegistryId: text("buildRegistryId").references(
+ () => registry.registryId,
+ {
+ onDelete: "set null",
+ },
+ ),
});
export const applicationsRelations = relations(
@@ -247,6 +256,14 @@ export const applicationsRelations = relations(
fields: [applications.serverId],
references: [server.serverId],
}),
+ buildServer: one(server, {
+ fields: [applications.buildServerId],
+ references: [server.serverId],
+ }),
+ buildRegistry: one(registry, {
+ fields: [applications.buildRegistryId],
+ references: [registry.registryId],
+ }),
previewDeployments: many(previewDeployments),
}),
);
diff --git a/packages/server/src/db/schema/server.ts b/packages/server/src/db/schema/server.ts
index 4313e95dd..317aa68ee 100644
--- a/packages/server/src/db/schema/server.ts
+++ b/packages/server/src/db/schema/server.ts
@@ -24,6 +24,7 @@ import { schedules } from "./schedule";
import { sshKeys } from "./ssh-key";
import { generateAppName } from "./utils";
export const serverStatus = pgEnum("serverStatus", ["active", "inactive"]);
+export const serverType = pgEnum("serverType", ["deploy", "build"]);
export const server = pgTable("server", {
serverId: text("serverId")
@@ -44,6 +45,7 @@ export const server = pgTable("server", {
.notNull()
.references(() => organization.id, { onDelete: "cascade" }),
serverStatus: serverStatus("serverStatus").notNull().default("active"),
+ serverType: serverType("serverType").notNull().default("deploy"),
command: text("command").notNull().default(""),
sshKeyId: text("sshKeyId").references(() => sshKeys.sshKeyId, {
onDelete: "set null",
@@ -131,6 +133,7 @@ export const apiCreateServer = createSchema
port: true,
username: true,
sshKeyId: true,
+ serverType: true,
})
.required();
@@ -155,6 +158,7 @@ export const apiUpdateServer = createSchema
port: true,
username: true,
sshKeyId: true,
+ serverType: true,
})
.required()
.extend({
From 65d962efc88537666cfc0b8d75ee85030eb29703 Mon Sep 17 00:00:00 2001
From: Mauricio Siu
Date: Sat, 29 Nov 2025 21:46:12 -0600
Subject: [PATCH 16/50] feat: enhance server validation and setup for build
servers
- Added logic to differentiate between build servers and regular servers in the ValidateServer component.
- Updated the server setup process to conditionally install dependencies based on server type.
- Enhanced the default command generation to include specific commands for build servers.
- Improved UI feedback to reflect the server type in the dashboard.
---
.../settings/servers/validate-server.tsx | 81 +++++++++++--------
apps/dokploy/server/api/routers/server.ts | 6 +-
packages/server/src/setup/server-setup.ts | 36 ++++++++-
3 files changed, 85 insertions(+), 38 deletions(-)
diff --git a/apps/dokploy/components/dashboard/settings/servers/validate-server.tsx b/apps/dokploy/components/dashboard/settings/servers/validate-server.tsx
index c09753f3e..5aaf154fd 100644
--- a/apps/dokploy/components/dashboard/settings/servers/validate-server.tsx
+++ b/apps/dokploy/components/dashboard/settings/servers/validate-server.tsx
@@ -25,6 +25,13 @@ export const ValidateServer = ({ serverId }: Props) => {
enabled: !!serverId,
},
);
+ const { data: server } = api.server.one.useQuery(
+ { serverId },
+ {
+ enabled: !!serverId,
+ },
+ );
+ const isBuildServer = server?.serverType === "build";
const _utils = api.useUtils();
return (
@@ -73,7 +80,9 @@ export const ValidateServer = ({ serverId }: Props) => {
Status
- Shows the server configuration status
+ {isBuildServer
+ ? "Shows the build server configuration status"
+ : "Shows the server configuration status"}
{
: undefined
}
/>
-
+ {!isBuildServer && (
+
+ )}
{
}
/>
-
+ {!isBuildServer && (
+ <>
+
+
+ >
+ )}
{
: "Not Created"
}
/>
-
diff --git a/apps/dokploy/server/api/routers/server.ts b/apps/dokploy/server/api/routers/server.ts
index 3b0985e43..4a044ec54 100644
--- a/apps/dokploy/server/api/routers/server.ts
+++ b/apps/dokploy/server/api/routers/server.ts
@@ -81,8 +81,10 @@ export const serverRouter = createTRPCRouter({
}),
getDefaultCommand: protectedProcedure
.input(apiFindOneServer)
- .query(async () => {
- return defaultCommand();
+ .query(async ({ input }) => {
+ const server = await findServerById(input.serverId);
+ const isBuildServer = server.serverType === "build";
+ return defaultCommand(isBuildServer);
}),
all: protectedProcedure.query(async ({ ctx }) => {
const result = await db
diff --git a/packages/server/src/setup/server-setup.ts b/packages/server/src/setup/server-setup.ts
index 8128b57e0..0636215d9 100644
--- a/packages/server/src/setup/server-setup.ts
+++ b/packages/server/src/setup/server-setup.ts
@@ -51,7 +51,12 @@ export const serverSetup = async (
});
try {
- onData?.("\nInstalling Server Dependencies: ✅\n");
+ const isBuildServer = server.serverType === "build";
+ onData?.(
+ isBuildServer
+ ? "\nInstalling Build Server Dependencies: ✅\n"
+ : "\nInstalling Server Dependencies: ✅\n",
+ );
await installRequirements(serverId, onData);
await updateDeploymentStatus(deployment.deploymentId, "done");
@@ -65,7 +70,7 @@ export const serverSetup = async (
}
};
-export const defaultCommand = () => {
+export const defaultCommand = (isBuildServer = false) => {
const bashCommand = `
set -e;
DOCKER_VERSION=27.0.3
@@ -126,6 +131,7 @@ echo -e "---------------------------------------------"
echo "| CPU Architecture | $SYS_ARCH"
echo "| Operating System | $OS_TYPE $OS_VERSION"
echo "| Docker | $DOCKER_VERSION"
+${isBuildServer ? 'echo "| Server Type | Build Server"' : ""}
echo -e "---------------------------------------------\n"
echo -e "1. Installing required packages (curl, wget, git, jq, openssl). "
@@ -135,6 +141,9 @@ command_exists() {
${installUtilities()}
+${
+ !isBuildServer
+ ? `
echo -e "2. Validating ports. "
${validatePorts()}
@@ -173,6 +182,25 @@ ${installBuildpacks()}
echo -e "13. Installing Railpack"
${installRailpack()}
+`
+ : `
+echo -e "2. Installing Docker. "
+${installDocker()}
+
+echo -e "3. Setting up Directories"
+${setupMainDirectory()}
+${setupDirectories()}
+
+echo -e "4. Installing Nixpacks"
+${installNixpacks()}
+
+echo -e "5. Installing Buildpacks"
+${installBuildpacks()}
+
+echo -e "6. Installing Railpack"
+${installRailpack()}
+`
+}
`;
return bashCommand;
@@ -189,10 +217,12 @@ const installRequirements = async (
throw new Error("No SSH Key found");
}
+ const isBuildServer = server.serverType === "build";
+
return new Promise