diff --git a/backend/socket-handlers/docker-socket-handler.ts b/backend/socket-handlers/docker-socket-handler.ts index e1049e8..e945bef 100644 --- a/backend/socket-handlers/docker-socket-handler.ts +++ b/backend/socket-handlers/docker-socket-handler.ts @@ -3,6 +3,9 @@ import { DockgeServer } from "../dockge-server"; import { callbackError, checkLogin, DockgeSocket, ValidationError } from "../util-server"; import { Stack } from "../stack"; +// @ts-ignore +import composerize from "composerize"; + export class DockerSocketHandler extends SocketHandler { create(socket : DockgeSocket, server : DockgeServer) { @@ -217,6 +220,25 @@ export class DockerSocketHandler extends SocketHandler { callbackError(e, callback); } }); + + // composerize + socket.on("composerize", async (dockerRunCommand : unknown, callback) => { + try { + checkLogin(socket); + + if (typeof(dockerRunCommand) !== "string") { + throw new ValidationError("dockerRunCommand must be a string"); + } + + const composeTemplate = composerize(dockerRunCommand); + callback({ + ok: true, + composeTemplate, + }); + } catch (e) { + callbackError(e, callback); + } + }); } saveStack(socket : DockgeSocket, server : DockgeServer, name : unknown, composeYAML : unknown, isAdd : unknown) : Stack { diff --git a/frontend/src/pages/DashboardHome.vue b/frontend/src/pages/DashboardHome.vue index 7785ed5..d32ce45 100644 --- a/frontend/src/pages/DashboardHome.vue +++ b/frontend/src/pages/DashboardHome.vue @@ -34,7 +34,6 @@