diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index 388a7e0..6ca6853 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -128,8 +128,8 @@ const client = : null; client?.connect(); -const git = process.env.DOKKU_KEY ? new SecureGitClient( - "dokku@gitwit.app", +const git = process.env.DOKKU_HOST && process.env.DOKKU_KEY ? new SecureGitClient( + `dokku@${process.env.DOKKU_HOST}`, process.env.DOKKU_KEY ) : null; diff --git a/frontend/components/editor/navbar/deploy.tsx b/frontend/components/editor/navbar/deploy.tsx index c498286..9202e2b 100644 --- a/frontend/components/editor/navbar/deploy.tsx +++ b/frontend/components/editor/navbar/deploy.tsx @@ -2,26 +2,30 @@ import { useState } from "react"; import { Button } from "@/components/ui/button"; +import { useTerminal } from "@/context/TerminalContext"; import { Play, Pause } from "lucide-react"; export default function DeployButtonModal() { + const { deploy } = useTerminal(); const [isDeploying, setIsDeploying] = useState(false); const handleDeploy = () => { if (isDeploying) { console.log("Stopping deployment..."); - } else { console.log("Starting deployment..."); + setIsDeploying(true); + deploy(() => { + setIsDeploying(false); + }); } - setIsDeploying(!isDeploying); }; return ( <> ); diff --git a/frontend/context/TerminalContext.tsx b/frontend/context/TerminalContext.tsx index abb9621..a329bec 100644 --- a/frontend/context/TerminalContext.tsx +++ b/frontend/context/TerminalContext.tsx @@ -16,6 +16,7 @@ interface TerminalContextType { createNewTerminal: (command?: string) => Promise; closeTerminal: (id: string) => void; setUserAndSandboxId: (userId: string, sandboxId: string) => void; + deploy: (callback: () => void) => void; } const TerminalContext = createContext(undefined); @@ -89,6 +90,14 @@ export const TerminalProvider: React.FC<{ children: React.ReactNode }> = ({ chil setSandboxId(newSandboxId); }; + const deploy = (callback: () => void) => { + if (!socket) console.error("Couldn't deploy: No socket"); + console.log("Deploying...") + socket?.emit("deploy", () => { + callback(); + }); + } + const value = { socket, terminals, @@ -100,6 +109,7 @@ export const TerminalProvider: React.FC<{ children: React.ReactNode }> = ({ chil createNewTerminal, closeTerminal, setUserAndSandboxId, + deploy }; return (