mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-24 08:35:26 +02:00
24 lines
654 B
TypeScript
24 lines
654 B
TypeScript
import { findServerById } from "@/server/api/services/server";
|
|
import { docker } from "@/server/constants";
|
|
import Dockerode from "dockerode";
|
|
import { readSSHKey } from "../filesystem/ssh";
|
|
|
|
export const getRemoteDocker = async (serverId?: string | null) => {
|
|
if (!serverId) return docker;
|
|
const server = await findServerById(serverId);
|
|
if (!server.sshKeyId) return docker;
|
|
const keys = await readSSHKey(server.sshKeyId);
|
|
const dockerode = new Dockerode({
|
|
host: server.ipAddress,
|
|
port: server.port,
|
|
username: server.username,
|
|
protocol: "ssh",
|
|
// @ts-ignore
|
|
sshOptions: {
|
|
privateKey: keys.privateKey,
|
|
},
|
|
});
|
|
|
|
return dockerode;
|
|
};
|