From d2c8632c4fbdab93286963c53df9ae1e648466ab Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 15 Sep 2024 01:24:55 -0600 Subject: [PATCH] refactor(server): add support for multi server --- .../dashboard/application/logs/show.tsx | 12 ++- .../dashboard/compose/logs/show.tsx | 12 ++- .../dashboard/compose/monitoring/show.tsx | 16 +++- .../web-server/docker-terminal-modal.tsx | 12 ++- .../settings/web-server/show-modal-logs.tsx | 12 ++- .../dokploy/server/api/routers/application.ts | 37 +++++--- apps/dokploy/server/api/routers/compose.ts | 27 +++--- .../server/api/services/application.ts | 45 +++++---- apps/dokploy/server/api/services/compose.ts | 56 ++++++----- .../dokploy/server/api/services/deployment.ts | 14 ++- .../server/queues/deployments-queue.ts | 92 +++++++++---------- apps/dokploy/server/queues/queueSetup.ts | 88 +----------------- apps/dokploy/server/server.ts | 3 +- apps/dokploy/server/utils/builders/compose.ts | 26 ++++-- apps/dokploy/server/utils/builders/heroku.ts | 2 - .../dokploy/server/utils/builders/nixpacks.ts | 5 +- apps/dokploy/server/utils/docker/domain.ts | 2 +- apps/dokploy/server/utils/docker/utils.ts | 12 ++- .../server/utils/filesystem/directory.ts | 39 ++++++-- .../dokploy/server/utils/process/execAsync.ts | 6 +- .../server/utils/providers/bitbucket.ts | 7 +- apps/dokploy/server/utils/providers/git.ts | 10 +- apps/dokploy/server/utils/providers/github.ts | 17 +++- apps/dokploy/server/utils/providers/gitlab.ts | 10 +- .../server/utils/traefik/application.ts | 13 ++- .../server/utils/traefik/middleware.ts | 9 +- 26 files changed, 340 insertions(+), 244 deletions(-) diff --git a/apps/dokploy/components/dashboard/application/logs/show.tsx b/apps/dokploy/components/dashboard/application/logs/show.tsx index 99e33bce..33beab12 100644 --- a/apps/dokploy/components/dashboard/application/logs/show.tsx +++ b/apps/dokploy/components/dashboard/application/logs/show.tsx @@ -16,6 +16,7 @@ import { SelectValue, } from "@/components/ui/select"; import { api } from "@/utils/api"; +import { Loader2 } from "lucide-react"; import dynamic from "next/dynamic"; import { useEffect, useState } from "react"; export const DockerLogs = dynamic( @@ -34,7 +35,7 @@ interface Props { } export const ShowDockerLogs = ({ appName, serverId }: Props) => { - const { data } = api.docker.getContainersByAppNameMatch.useQuery( + const { data, isLoading } = api.docker.getContainersByAppNameMatch.useQuery( { appName, serverId, @@ -64,7 +65,14 @@ export const ShowDockerLogs = ({ appName, serverId }: Props) => { - + {isLoading ? ( +
+ Loading... + +
+ ) : ( + + )}
diff --git a/apps/dokploy/components/dashboard/compose/monitoring/show.tsx b/apps/dokploy/components/dashboard/compose/monitoring/show.tsx index 1d7a724e..d5cdca14 100644 --- a/apps/dokploy/components/dashboard/compose/monitoring/show.tsx +++ b/apps/dokploy/components/dashboard/compose/monitoring/show.tsx @@ -20,6 +20,7 @@ import { api } from "@/utils/api"; import { useEffect, useState } from "react"; import { toast } from "sonner"; import { DockerMonitoring } from "../../monitoring/docker/show"; +import { Loader2 } from "lucide-react"; interface Props { appName: string; @@ -32,7 +33,7 @@ export const ShowMonitoringCompose = ({ appType = "stack", serverId, }: Props) => { - const { data } = api.docker.getContainersByAppNameMatch.useQuery( + const { data, isLoading } = api.docker.getContainersByAppNameMatch.useQuery( { appName: appName, appType, @@ -49,7 +50,7 @@ export const ShowMonitoringCompose = ({ const [containerId, setContainerId] = useState(); - const { mutateAsync: restart, isLoading } = + const { mutateAsync: restart, isLoading: isRestarting } = api.docker.restartContainer.useMutation(); useEffect(() => { @@ -80,7 +81,14 @@ export const ShowMonitoringCompose = ({ value={containerAppName} > - + {isLoading ? ( +
+ Loading... + +
+ ) : ( + + )}
@@ -98,7 +106,7 @@ export const ShowMonitoringCompose = ({