mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(multi-server): enable docker terminal inside of containers
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import { ShowBuildChooseForm } from "@/components/dashboard/application/build/show";
|
import { ShowBuildChooseForm } from "@/components/dashboard/application/build/show";
|
||||||
import { ShowProviderForm } from "@/components/dashboard/application/general/generic/show";
|
import { ShowProviderForm } from "@/components/dashboard/application/general/generic/show";
|
||||||
import { Badge } from "@/components/ui/badge";
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { Toggle } from "@/components/ui/toggle";
|
import { Toggle } from "@/components/ui/toggle";
|
||||||
@@ -76,8 +75,6 @@ export const ShowGeneralApplication = ({ applicationId }: Props) => {
|
|||||||
Open Terminal
|
Open Terminal
|
||||||
</Button>
|
</Button>
|
||||||
</DockerTerminalModal>
|
</DockerTerminalModal>
|
||||||
|
|
||||||
{/* {data?.server?.name || "No Server"} */}
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
<ShowProviderForm applicationId={applicationId} />
|
<ShowProviderForm applicationId={applicationId} />
|
||||||
|
|||||||
@@ -75,7 +75,10 @@ export const ComposeActions = ({ composeId }: Props) => {
|
|||||||
<StopCompose composeId={composeId} />
|
<StopCompose composeId={composeId} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<DockerTerminalModal appName={data?.appName || ""}>
|
<DockerTerminalModal
|
||||||
|
appName={data?.appName || ""}
|
||||||
|
serverId={data?.serverId || ""}
|
||||||
|
>
|
||||||
<Button variant="outline">
|
<Button variant="outline">
|
||||||
<Terminal />
|
<Terminal />
|
||||||
Open Terminal
|
Open Terminal
|
||||||
|
|||||||
@@ -124,7 +124,10 @@ export const columns: ColumnDef<Container>[] = [
|
|||||||
containerId={container.containerId}
|
containerId={container.containerId}
|
||||||
serverId={container.serverId || ""}
|
serverId={container.serverId || ""}
|
||||||
/>
|
/>
|
||||||
<DockerTerminalModal containerId={container.containerId}>
|
<DockerTerminalModal
|
||||||
|
containerId={container.containerId}
|
||||||
|
serverId={container.serverId || ""}
|
||||||
|
>
|
||||||
Terminal
|
Terminal
|
||||||
</DockerTerminalModal>
|
</DockerTerminalModal>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
|
|||||||
@@ -36,7 +36,10 @@ export const ShowGeneralMariadb = ({ mariadbId }: Props) => {
|
|||||||
) : (
|
) : (
|
||||||
<StopMariadb mariadbId={mariadbId} />
|
<StopMariadb mariadbId={mariadbId} />
|
||||||
)}
|
)}
|
||||||
<DockerTerminalModal appName={data?.appName || ""}>
|
<DockerTerminalModal
|
||||||
|
appName={data?.appName || ""}
|
||||||
|
serverId={data?.serverId || ""}
|
||||||
|
>
|
||||||
<Button variant="outline">
|
<Button variant="outline">
|
||||||
<Terminal />
|
<Terminal />
|
||||||
Open Terminal
|
Open Terminal
|
||||||
|
|||||||
@@ -34,7 +34,10 @@ export const ShowGeneralMongo = ({ mongoId }: Props) => {
|
|||||||
) : (
|
) : (
|
||||||
<StopMongo mongoId={mongoId} />
|
<StopMongo mongoId={mongoId} />
|
||||||
)}
|
)}
|
||||||
<DockerTerminalModal appName={data?.appName || ""}>
|
<DockerTerminalModal
|
||||||
|
appName={data?.appName || ""}
|
||||||
|
serverId={data?.serverId || ""}
|
||||||
|
>
|
||||||
<Button variant="outline">
|
<Button variant="outline">
|
||||||
<Terminal />
|
<Terminal />
|
||||||
Open Terminal
|
Open Terminal
|
||||||
|
|||||||
@@ -35,7 +35,10 @@ export const ShowGeneralMysql = ({ mysqlId }: Props) => {
|
|||||||
<StopMysql mysqlId={mysqlId} />
|
<StopMysql mysqlId={mysqlId} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<DockerTerminalModal appName={data?.appName || ""}>
|
<DockerTerminalModal
|
||||||
|
appName={data?.appName || ""}
|
||||||
|
serverId={data?.serverId || ""}
|
||||||
|
>
|
||||||
<Button variant="outline">
|
<Button variant="outline">
|
||||||
<Terminal />
|
<Terminal />
|
||||||
Open Terminal
|
Open Terminal
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ export const ShowGeneralPostgres = ({ postgresId }: Props) => {
|
|||||||
<StopPostgres postgresId={postgresId} />
|
<StopPostgres postgresId={postgresId} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<DockerTerminalModal appName={data?.appName || ""}>
|
<DockerTerminalModal
|
||||||
|
appName={data?.appName || ""}
|
||||||
|
serverId={data?.serverId || ""}
|
||||||
|
>
|
||||||
<Button variant="outline">
|
<Button variant="outline">
|
||||||
<Terminal />
|
<Terminal />
|
||||||
Open Terminal
|
Open Terminal
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ export const ShowGeneralRedis = ({ redisId }: Props) => {
|
|||||||
<StopRedis redisId={redisId} />
|
<StopRedis redisId={redisId} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<DockerTerminalModal appName={data?.appName || ""}>
|
<DockerTerminalModal
|
||||||
|
appName={data?.appName || ""}
|
||||||
|
serverId={data?.serverId || ""}
|
||||||
|
>
|
||||||
<Button variant="outline">
|
<Button variant="outline">
|
||||||
<Terminal />
|
<Terminal />
|
||||||
Open Terminal
|
Open Terminal
|
||||||
|
|||||||
@@ -55,115 +55,61 @@ export const setupDockerContainerTerminalWebSocketServer = (
|
|||||||
const conn = new Client();
|
const conn = new Client();
|
||||||
let stdout = "";
|
let stdout = "";
|
||||||
let stderr = "";
|
let stderr = "";
|
||||||
// conn
|
conn
|
||||||
// .once("ready", () => {
|
.once("ready", () => {
|
||||||
// console.log("Client :: ready");
|
conn.exec(
|
||||||
// conn.exec(
|
`docker exec -it ${containerId} ${activeWay}`,
|
||||||
// `docker run -i ${containerId} ${activeWay}`,
|
{ pty: true },
|
||||||
// (err, stream) => {
|
(err, stream) => {
|
||||||
// if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
// stream
|
stream
|
||||||
// .on("close", (code: number, signal: string) => {
|
.on("close", (code: number, signal: string) => {
|
||||||
// console.log(
|
console.log(
|
||||||
// `Stream :: close :: code: ${code}, signal: ${signal}`,
|
`Stream :: close :: code: ${code}, signal: ${signal}`,
|
||||||
// );
|
);
|
||||||
// conn.end();
|
ws.send(`\nContainer closed with code: ${code}\n`);
|
||||||
// })
|
conn.end();
|
||||||
// .on("data", (data: string) => {
|
})
|
||||||
// stdout += data.toString();
|
.on("data", (data: string) => {
|
||||||
// ws.send(data.toString());
|
stdout += data.toString();
|
||||||
// })
|
ws.send(data.toString());
|
||||||
// .stderr.on("data", (data) => {
|
})
|
||||||
// stderr += data.toString();
|
.stderr.on("data", (data) => {
|
||||||
// ws.send(data.toString());
|
stderr += data.toString();
|
||||||
// console.error("Error: ", data.toString());
|
ws.send(data.toString());
|
||||||
// });
|
console.error("Error: ", data.toString());
|
||||||
|
});
|
||||||
|
|
||||||
// // Maneja la entrada de comandos desde WebSocket
|
ws.on("message", (message) => {
|
||||||
// ws.on("message", (message) => {
|
try {
|
||||||
// try {
|
let command: string | Buffer[] | Buffer | ArrayBuffer;
|
||||||
// let command: string | Buffer[] | Buffer | ArrayBuffer;
|
if (Buffer.isBuffer(message)) {
|
||||||
// if (Buffer.isBuffer(message)) {
|
command = message.toString("utf8");
|
||||||
// command = message.toString("utf8");
|
} else {
|
||||||
// } else {
|
command = message;
|
||||||
// command = message;
|
}
|
||||||
// }
|
stream.write(command.toString());
|
||||||
// stream.write(command.toString());
|
} catch (error) {
|
||||||
// } catch (error) {
|
// @ts-ignore
|
||||||
// // @ts-ignore
|
const errorMessage = error?.message as unknown as string;
|
||||||
// const errorMessage = error?.message as unknown as string;
|
ws.send(errorMessage);
|
||||||
// ws.send(errorMessage);
|
}
|
||||||
// }
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
// // Cuando se cierra la conexión WebSocket
|
ws.on("close", () => {
|
||||||
// ws.on("close", () => {
|
stream.end();
|
||||||
// stream.end();
|
});
|
||||||
// });
|
},
|
||||||
// },
|
);
|
||||||
// );
|
})
|
||||||
// })p
|
.connect({
|
||||||
// .connect({
|
host: server.ipAddress,
|
||||||
// host: server.ipAddress,
|
port: server.port,
|
||||||
// port: server.port,
|
username: server.username,
|
||||||
// username: server.username,
|
privateKey: keys.privateKey,
|
||||||
// privateKey: keys.privateKey,
|
timeout: 99999,
|
||||||
// timeout: 99999,
|
});
|
||||||
// });
|
|
||||||
// conn
|
|
||||||
// .once("ready", () => {
|
|
||||||
// console.log("Client :: ready");
|
|
||||||
// conn.shell((err, stream) => {
|
|
||||||
// if (err) throw err;
|
|
||||||
|
|
||||||
// stream
|
|
||||||
// .on("close", (code: number, signal: string) => {
|
|
||||||
// console.log(
|
|
||||||
// `Stream :: close :: code: ${code}, signal: ${signal}`,
|
|
||||||
// );
|
|
||||||
// conn.end();
|
|
||||||
// })
|
|
||||||
// .on("data", (data: string) => {
|
|
||||||
// stdout += data.toString();
|
|
||||||
// ws.send(data.toString());
|
|
||||||
// })
|
|
||||||
// .stderr.on("data", (data) => {
|
|
||||||
// stderr += data.toString();
|
|
||||||
// ws.send(data.toString());
|
|
||||||
// console.error("Error: ", data.toString());
|
|
||||||
// });
|
|
||||||
// stream.write(`docker exec -it ${containerId} ${activeWay}\n`);
|
|
||||||
// // Maneja la entrada de comandos desde WebSocket
|
|
||||||
// ws.on("message", (message) => {
|
|
||||||
// try {
|
|
||||||
// let command: string | Buffer[] | Buffer | ArrayBuffer;
|
|
||||||
// if (Buffer.isBuffer(message)) {
|
|
||||||
// command = message.toString("utf8");
|
|
||||||
// } else {
|
|
||||||
// command = message;
|
|
||||||
// }
|
|
||||||
// stream.write(command.toString());
|
|
||||||
// } catch (error) {
|
|
||||||
// // @ts-ignore
|
|
||||||
// const errorMessage = error?.message as unknown as string;
|
|
||||||
// ws.send(errorMessage);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // Cuando se cierra la conexión WebSocket
|
|
||||||
// ws.on("close", () => {
|
|
||||||
// stream.end();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// })
|
|
||||||
// .connect({
|
|
||||||
// host: server.ipAddress,
|
|
||||||
// port: server.port,
|
|
||||||
// username: server.username,
|
|
||||||
// privateKey: keys.privateKey,
|
|
||||||
// timeout: 99999,
|
|
||||||
// });
|
|
||||||
} else {
|
} else {
|
||||||
const shell = getShell();
|
const shell = getShell();
|
||||||
const ptyProcess = spawn(
|
const ptyProcess = spawn(
|
||||||
|
|||||||
Reference in New Issue
Block a user