mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-16 08:55:18 +00:00
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.
This commit is contained in:
@@ -25,6 +25,13 @@ export const ValidateServer = ({ serverId }: Props) => {
|
|||||||
enabled: !!serverId,
|
enabled: !!serverId,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
const { data: server } = api.server.one.useQuery(
|
||||||
|
{ serverId },
|
||||||
|
{
|
||||||
|
enabled: !!serverId,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const isBuildServer = server?.serverType === "build";
|
||||||
const _utils = api.useUtils();
|
const _utils = api.useUtils();
|
||||||
return (
|
return (
|
||||||
<CardContent className="p-0">
|
<CardContent className="p-0">
|
||||||
@@ -73,7 +80,9 @@ export const ValidateServer = ({ serverId }: Props) => {
|
|||||||
<div className="border rounded-lg p-4">
|
<div className="border rounded-lg p-4">
|
||||||
<h3 className="text-lg font-semibold mb-1">Status</h3>
|
<h3 className="text-lg font-semibold mb-1">Status</h3>
|
||||||
<p className="text-sm text-muted-foreground mb-4">
|
<p className="text-sm text-muted-foreground mb-4">
|
||||||
Shows the server configuration status
|
{isBuildServer
|
||||||
|
? "Shows the build server configuration status"
|
||||||
|
: "Shows the server configuration status"}
|
||||||
</p>
|
</p>
|
||||||
<div className="grid gap-2.5">
|
<div className="grid gap-2.5">
|
||||||
<StatusRow
|
<StatusRow
|
||||||
@@ -85,15 +94,17 @@ export const ValidateServer = ({ serverId }: Props) => {
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<StatusRow
|
{!isBuildServer && (
|
||||||
label="RClone Installed"
|
<StatusRow
|
||||||
isEnabled={data?.rclone?.enabled}
|
label="RClone Installed"
|
||||||
description={
|
isEnabled={data?.rclone?.enabled}
|
||||||
data?.rclone?.enabled
|
description={
|
||||||
? `Installed: ${data?.rclone?.version}`
|
data?.rclone?.enabled
|
||||||
: undefined
|
? `Installed: ${data?.rclone?.version}`
|
||||||
}
|
: undefined
|
||||||
/>
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<StatusRow
|
<StatusRow
|
||||||
label="Nixpacks Installed"
|
label="Nixpacks Installed"
|
||||||
isEnabled={data?.nixpacks?.enabled}
|
isEnabled={data?.nixpacks?.enabled}
|
||||||
@@ -113,23 +124,36 @@ export const ValidateServer = ({ serverId }: Props) => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<StatusRow
|
<StatusRow
|
||||||
label="Docker Swarm Initialized"
|
label="Railpack Installed"
|
||||||
isEnabled={data?.isSwarmInstalled}
|
isEnabled={data?.railpack?.enabled}
|
||||||
description={
|
description={
|
||||||
data?.isSwarmInstalled
|
data?.railpack?.enabled
|
||||||
? "Initialized"
|
? `Installed: ${data?.railpack?.version}`
|
||||||
: "Not Initialized"
|
: undefined
|
||||||
}
|
|
||||||
/>
|
|
||||||
<StatusRow
|
|
||||||
label="Dokploy Network Created"
|
|
||||||
isEnabled={data?.isDokployNetworkInstalled}
|
|
||||||
description={
|
|
||||||
data?.isDokployNetworkInstalled
|
|
||||||
? "Created"
|
|
||||||
: "Not Created"
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
{!isBuildServer && (
|
||||||
|
<>
|
||||||
|
<StatusRow
|
||||||
|
label="Docker Swarm Initialized"
|
||||||
|
isEnabled={data?.isSwarmInstalled}
|
||||||
|
description={
|
||||||
|
data?.isSwarmInstalled
|
||||||
|
? "Initialized"
|
||||||
|
: "Not Initialized"
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<StatusRow
|
||||||
|
label="Dokploy Network Created"
|
||||||
|
isEnabled={data?.isDokployNetworkInstalled}
|
||||||
|
description={
|
||||||
|
data?.isDokployNetworkInstalled
|
||||||
|
? "Created"
|
||||||
|
: "Not Created"
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<StatusRow
|
<StatusRow
|
||||||
label="Main Directory Created"
|
label="Main Directory Created"
|
||||||
isEnabled={data?.isMainDirectoryInstalled}
|
isEnabled={data?.isMainDirectoryInstalled}
|
||||||
@@ -139,15 +163,6 @@ export const ValidateServer = ({ serverId }: Props) => {
|
|||||||
: "Not Created"
|
: "Not Created"
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<StatusRow
|
|
||||||
label="Railpack Installed"
|
|
||||||
isEnabled={data?.railpack?.enabled}
|
|
||||||
description={
|
|
||||||
data?.railpack?.enabled
|
|
||||||
? `Installed: ${data?.railpack?.version}`
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -81,8 +81,10 @@ export const serverRouter = createTRPCRouter({
|
|||||||
}),
|
}),
|
||||||
getDefaultCommand: protectedProcedure
|
getDefaultCommand: protectedProcedure
|
||||||
.input(apiFindOneServer)
|
.input(apiFindOneServer)
|
||||||
.query(async () => {
|
.query(async ({ input }) => {
|
||||||
return defaultCommand();
|
const server = await findServerById(input.serverId);
|
||||||
|
const isBuildServer = server.serverType === "build";
|
||||||
|
return defaultCommand(isBuildServer);
|
||||||
}),
|
}),
|
||||||
all: protectedProcedure.query(async ({ ctx }) => {
|
all: protectedProcedure.query(async ({ ctx }) => {
|
||||||
const result = await db
|
const result = await db
|
||||||
|
|||||||
@@ -51,7 +51,12 @@ export const serverSetup = async (
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
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 installRequirements(serverId, onData);
|
||||||
|
|
||||||
await updateDeploymentStatus(deployment.deploymentId, "done");
|
await updateDeploymentStatus(deployment.deploymentId, "done");
|
||||||
@@ -65,7 +70,7 @@ export const serverSetup = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultCommand = () => {
|
export const defaultCommand = (isBuildServer = false) => {
|
||||||
const bashCommand = `
|
const bashCommand = `
|
||||||
set -e;
|
set -e;
|
||||||
DOCKER_VERSION=27.0.3
|
DOCKER_VERSION=27.0.3
|
||||||
@@ -126,6 +131,7 @@ echo -e "---------------------------------------------"
|
|||||||
echo "| CPU Architecture | $SYS_ARCH"
|
echo "| CPU Architecture | $SYS_ARCH"
|
||||||
echo "| Operating System | $OS_TYPE $OS_VERSION"
|
echo "| Operating System | $OS_TYPE $OS_VERSION"
|
||||||
echo "| Docker | $DOCKER_VERSION"
|
echo "| Docker | $DOCKER_VERSION"
|
||||||
|
${isBuildServer ? 'echo "| Server Type | Build Server"' : ""}
|
||||||
echo -e "---------------------------------------------\n"
|
echo -e "---------------------------------------------\n"
|
||||||
echo -e "1. Installing required packages (curl, wget, git, jq, openssl). "
|
echo -e "1. Installing required packages (curl, wget, git, jq, openssl). "
|
||||||
|
|
||||||
@@ -135,6 +141,9 @@ command_exists() {
|
|||||||
|
|
||||||
${installUtilities()}
|
${installUtilities()}
|
||||||
|
|
||||||
|
${
|
||||||
|
!isBuildServer
|
||||||
|
? `
|
||||||
echo -e "2. Validating ports. "
|
echo -e "2. Validating ports. "
|
||||||
${validatePorts()}
|
${validatePorts()}
|
||||||
|
|
||||||
@@ -173,6 +182,25 @@ ${installBuildpacks()}
|
|||||||
|
|
||||||
echo -e "13. Installing Railpack"
|
echo -e "13. Installing Railpack"
|
||||||
${installRailpack()}
|
${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;
|
return bashCommand;
|
||||||
@@ -189,10 +217,12 @@ const installRequirements = async (
|
|||||||
throw new Error("No SSH Key found");
|
throw new Error("No SSH Key found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isBuildServer = server.serverType === "build";
|
||||||
|
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
client
|
client
|
||||||
.once("ready", () => {
|
.once("ready", () => {
|
||||||
const command = server.command || defaultCommand();
|
const command = server.command || defaultCommand(isBuildServer);
|
||||||
client.exec(command, (err, stream) => {
|
client.exec(command, (err, stream) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
onData?.(err.message);
|
onData?.(err.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user