Skip to content

Commit 79d55d8

Browse files
[autofix.ci] apply automated fixes
1 parent d4c6e5b commit 79d55d8

File tree

2 files changed

+112
-114
lines changed

2 files changed

+112
-114
lines changed

apps/dokploy/components/layouts/user-nav.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ export const UserNav = () => {
133133
Servers
134134
</DropdownMenuItem>
135135
)}
136-
137-
138136
</>
139137
)}
140138
</DropdownMenuGroup>

packages/server/src/setup/server-setup.ts

Lines changed: 112 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
11
import path from "node:path";
22
import { paths } from "@dokploy/server/constants";
33
import {
4-
createServerDeployment,
5-
updateDeploymentStatus,
4+
createServerDeployment,
5+
updateDeploymentStatus,
66
} from "@dokploy/server/services/deployment";
77
import { findServerById } from "@dokploy/server/services/server";
88
import {
9-
TRAEFIK_HTTP3_PORT,
10-
TRAEFIK_PORT,
11-
TRAEFIK_SSL_PORT,
12-
TRAEFIK_VERSION,
13-
getDefaultMiddlewares,
14-
getDefaultServerTraefikConfig,
9+
TRAEFIK_HTTP3_PORT,
10+
TRAEFIK_PORT,
11+
TRAEFIK_SSL_PORT,
12+
TRAEFIK_VERSION,
13+
getDefaultMiddlewares,
14+
getDefaultServerTraefikConfig,
1515
} from "@dokploy/server/setup/traefik-setup";
1616
import { Client } from "ssh2";
1717
import { recreateDirectory } from "../utils/filesystem/directory";
1818

1919
import slug from "slugify";
2020

2121
export const slugify = (text: string | undefined) => {
22-
if (!text) {
23-
return "";
24-
}
22+
if (!text) {
23+
return "";
24+
}
2525

26-
const cleanedText = text.trim().replace(/[^a-zA-Z0-9\s]/g, "");
26+
const cleanedText = text.trim().replace(/[^a-zA-Z0-9\s]/g, "");
2727

28-
return slug(cleanedText, {
29-
lower: true,
30-
trim: true,
31-
strict: true,
32-
});
28+
return slug(cleanedText, {
29+
lower: true,
30+
trim: true,
31+
strict: true,
32+
});
3333
};
3434

3535
export const serverSetup = async (
36-
serverId: string,
37-
onData?: (data: any) => void
36+
serverId: string,
37+
onData?: (data: any) => void,
3838
) => {
39-
const server = await findServerById(serverId);
40-
const { LOGS_PATH } = paths();
39+
const server = await findServerById(serverId);
40+
const { LOGS_PATH } = paths();
4141

42-
const slugifyName = slugify(`server ${server.name}`);
42+
const slugifyName = slugify(`server ${server.name}`);
4343

44-
const fullPath = path.join(LOGS_PATH, slugifyName);
44+
const fullPath = path.join(LOGS_PATH, slugifyName);
4545

46-
await recreateDirectory(fullPath);
46+
await recreateDirectory(fullPath);
4747

48-
const deployment = await createServerDeployment({
49-
serverId: server.serverId,
50-
title: "Setup Server",
51-
description: "Setup Server",
52-
});
48+
const deployment = await createServerDeployment({
49+
serverId: server.serverId,
50+
title: "Setup Server",
51+
description: "Setup Server",
52+
});
5353

54-
try {
55-
onData?.("\nInstalling Server Dependencies: ✅\n");
56-
await installRequirements(serverId, onData);
54+
try {
55+
onData?.("\nInstalling Server Dependencies: ✅\n");
56+
await installRequirements(serverId, onData);
5757

58-
await updateDeploymentStatus(deployment.deploymentId, "done");
58+
await updateDeploymentStatus(deployment.deploymentId, "done");
5959

60-
onData?.("\nSetup Server: ✅\n");
61-
} catch (err) {
62-
console.log(err);
60+
onData?.("\nSetup Server: ✅\n");
61+
} catch (err) {
62+
console.log(err);
6363

64-
await updateDeploymentStatus(deployment.deploymentId, "error");
65-
onData?.(`${err} ❌\n`);
66-
}
64+
await updateDeploymentStatus(deployment.deploymentId, "error");
65+
onData?.(`${err} ❌\n`);
66+
}
6767
};
6868

6969
export const defaultCommand = () => {
70-
const bashCommand = `
70+
const bashCommand = `
7171
set -e;
7272
DOCKER_VERSION=27.0.3
7373
OS_TYPE=$(grep -w "ID" /etc/os-release | cut -d "=" -f 2 | tr -d '"')
@@ -176,83 +176,83 @@ echo -e "13. Installing Railpack"
176176
${installRailpack()}
177177
`;
178178

179-
return bashCommand;
179+
return bashCommand;
180180
};
181181

182182
const installRequirements = async (
183-
serverId: string,
184-
onData?: (data: any) => void
183+
serverId: string,
184+
onData?: (data: any) => void,
185185
) => {
186-
const client = new Client();
187-
const server = await findServerById(serverId);
188-
if (!server.sshKeyId) {
189-
onData?.("❌ No SSH Key found, please assign one to this server");
190-
throw new Error("No SSH Key found");
191-
}
192-
193-
return new Promise<void>((resolve, reject) => {
194-
client
195-
.once("ready", () => {
196-
const command = server.command || defaultCommand();
197-
client.exec(command, (err, stream) => {
198-
if (err) {
199-
onData?.(err.message);
200-
reject(err);
201-
return;
202-
}
203-
stream
204-
.on("close", () => {
205-
client.end();
206-
resolve();
207-
})
208-
.on("data", (data: string) => {
209-
onData?.(data.toString());
210-
})
211-
.stderr.on("data", (data) => {
212-
onData?.(data.toString());
213-
});
214-
});
215-
})
216-
.on("error", (err) => {
217-
client.end();
218-
if (err.level === "client-authentication") {
219-
onData?.(
220-
`Authentication failed: Invalid SSH private key. ❌ Error: ${err.message} ${err.level}`
221-
);
222-
reject(
223-
new Error(
224-
`Authentication failed: Invalid SSH private key. ❌ Error: ${err.message} ${err.level}`
225-
)
226-
);
227-
} else {
228-
onData?.(`SSH connection error: ${err.message} ${err.level}`);
229-
reject(new Error(`SSH connection error: ${err.message}`));
230-
}
231-
})
232-
.connect({
233-
host: server.ipAddress,
234-
port: server.port,
235-
username: server.username,
236-
privateKey: server.sshKey?.privateKey,
237-
});
238-
});
186+
const client = new Client();
187+
const server = await findServerById(serverId);
188+
if (!server.sshKeyId) {
189+
onData?.("❌ No SSH Key found, please assign one to this server");
190+
throw new Error("No SSH Key found");
191+
}
192+
193+
return new Promise<void>((resolve, reject) => {
194+
client
195+
.once("ready", () => {
196+
const command = server.command || defaultCommand();
197+
client.exec(command, (err, stream) => {
198+
if (err) {
199+
onData?.(err.message);
200+
reject(err);
201+
return;
202+
}
203+
stream
204+
.on("close", () => {
205+
client.end();
206+
resolve();
207+
})
208+
.on("data", (data: string) => {
209+
onData?.(data.toString());
210+
})
211+
.stderr.on("data", (data) => {
212+
onData?.(data.toString());
213+
});
214+
});
215+
})
216+
.on("error", (err) => {
217+
client.end();
218+
if (err.level === "client-authentication") {
219+
onData?.(
220+
`Authentication failed: Invalid SSH private key. ❌ Error: ${err.message} ${err.level}`,
221+
);
222+
reject(
223+
new Error(
224+
`Authentication failed: Invalid SSH private key. ❌ Error: ${err.message} ${err.level}`,
225+
),
226+
);
227+
} else {
228+
onData?.(`SSH connection error: ${err.message} ${err.level}`);
229+
reject(new Error(`SSH connection error: ${err.message}`));
230+
}
231+
})
232+
.connect({
233+
host: server.ipAddress,
234+
port: server.port,
235+
username: server.username,
236+
privateKey: server.sshKey?.privateKey,
237+
});
238+
});
239239
};
240240

241241
const setupDirectories = () => {
242-
const { SSH_PATH } = paths(true);
243-
const directories = Object.values(paths(true));
242+
const { SSH_PATH } = paths(true);
243+
const directories = Object.values(paths(true));
244244

245-
const createDirsCommand = directories
246-
.map((dir) => `mkdir -p "${dir}"`)
247-
.join(" && ");
248-
const chmodCommand = `chmod 700 "${SSH_PATH}"`;
245+
const createDirsCommand = directories
246+
.map((dir) => `mkdir -p "${dir}"`)
247+
.join(" && ");
248+
const chmodCommand = `chmod 700 "${SSH_PATH}"`;
249249

250-
const command = `
250+
const command = `
251251
${createDirsCommand}
252252
${chmodCommand}
253253
`;
254254

255-
return command;
255+
return command;
256256
};
257257

258258
const setupMainDirectory = () => `
@@ -502,9 +502,9 @@ fi
502502
`;
503503

504504
const createTraefikConfig = () => {
505-
const config = getDefaultServerTraefikConfig();
505+
const config = getDefaultServerTraefikConfig();
506506

507-
const command = `
507+
const command = `
508508
if [ -f "/etc/dokploy/traefik/dynamic/acme.json" ]; then
509509
chmod 600 "/etc/dokploy/traefik/dynamic/acme.json"
510510
fi
@@ -515,19 +515,19 @@ const createTraefikConfig = () => {
515515
fi
516516
`;
517517

518-
return command;
518+
return command;
519519
};
520520

521521
const createDefaultMiddlewares = () => {
522-
const config = getDefaultMiddlewares();
523-
const command = `
522+
const config = getDefaultMiddlewares();
523+
const command = `
524524
if [ -f "/etc/dokploy/traefik/dynamic/middlewares.yml" ]; then
525525
echo "Middlewares config already exists ✅"
526526
else
527527
echo "${config}" > /etc/dokploy/traefik/dynamic/middlewares.yml
528528
fi
529529
`;
530-
return command;
530+
return command;
531531
};
532532

533533
export const installRClone = () => `
@@ -541,7 +541,7 @@ export const installRClone = () => `
541541
`;
542542

543543
export const createTraefikInstance = () => {
544-
const command = `
544+
const command = `
545545
# Check if dokpyloy-traefik exists
546546
if docker service inspect dokploy-traefik > /dev/null 2>&1; then
547547
echo "Migrating Traefik to Standalone..."
@@ -570,7 +570,7 @@ export const createTraefikInstance = () => {
570570
fi
571571
`;
572572

573-
return command;
573+
return command;
574574
};
575575

576576
const installNixpacks = () => `

0 commit comments

Comments
 (0)