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