mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Merge pull request #279 from Dokploy/fix/remove-expose-port-traefik
feat(traefik): add toggle for disable the traefik dashboard
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
|||||||
} from "@/components/ui/card";
|
} from "@/components/ui/card";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import React, { useEffect, useState } from "react";
|
import React from "react";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
@@ -37,6 +37,9 @@ export const WebServer = () => {
|
|||||||
api.settings.reloadTraefik.useMutation();
|
api.settings.reloadTraefik.useMutation();
|
||||||
const { mutateAsync: cleanAll, isLoading: cleanAllIsLoading } =
|
const { mutateAsync: cleanAll, isLoading: cleanAllIsLoading } =
|
||||||
api.settings.cleanAll.useMutation();
|
api.settings.cleanAll.useMutation();
|
||||||
|
const { mutateAsync: toggleDashboard, isLoading: toggleDashboardIsLoading } =
|
||||||
|
api.settings.toggleDashboard.useMutation();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
mutateAsync: cleanDockerBuilder,
|
mutateAsync: cleanDockerBuilder,
|
||||||
isLoading: cleanDockerBuilderIsLoading,
|
isLoading: cleanDockerBuilderIsLoading,
|
||||||
@@ -107,6 +110,7 @@ export const WebServer = () => {
|
|||||||
<span>View Traefik config</span>
|
<span>View Traefik config</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</ShowServerTraefikConfig>
|
</ShowServerTraefikConfig>
|
||||||
|
|
||||||
<ShowServerMiddlewareConfig>
|
<ShowServerMiddlewareConfig>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onSelect={(e) => e.preventDefault()}
|
onSelect={(e) => e.preventDefault()}
|
||||||
@@ -124,8 +128,14 @@ export const WebServer = () => {
|
|||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild disabled={reloadTraefikIsLoading}>
|
<DropdownMenuTrigger
|
||||||
<Button isLoading={reloadTraefikIsLoading} variant="outline">
|
asChild
|
||||||
|
disabled={reloadTraefikIsLoading || toggleDashboardIsLoading}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
isLoading={reloadTraefikIsLoading || toggleDashboardIsLoading}
|
||||||
|
variant="outline"
|
||||||
|
>
|
||||||
Traefik
|
Traefik
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
@@ -157,6 +167,38 @@ export const WebServer = () => {
|
|||||||
<span>View Traefik config</span>
|
<span>View Traefik config</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</ShowMainTraefikConfig>
|
</ShowMainTraefikConfig>
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={async () => {
|
||||||
|
await toggleDashboard({
|
||||||
|
enableDashboard: true,
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
toast.success("Dashboard Enabled");
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
toast.error("Error to enable Dashboard");
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
className="w-full cursor-pointer space-x-3"
|
||||||
|
>
|
||||||
|
<span>Enable Dashboard</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={async () => {
|
||||||
|
await toggleDashboard({
|
||||||
|
enableDashboard: false,
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
toast.success("Dashboard Disabled");
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
toast.error("Error to disable Dashboard");
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
className="w-full cursor-pointer space-x-3"
|
||||||
|
>
|
||||||
|
<span>Disable Dashboard</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
|
||||||
<DockerTerminalModal appName="dokploy-traefik">
|
<DockerTerminalModal appName="dokploy-traefik">
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import { MAIN_TRAEFIK_PATH, MONITORING_PATH, docker } from "@/server/constants";
|
import { MAIN_TRAEFIK_PATH, MONITORING_PATH, docker } from "@/server/constants";
|
||||||
import {
|
import {
|
||||||
apiAssignDomain,
|
apiAssignDomain,
|
||||||
|
apiEnableDashboard,
|
||||||
apiModifyTraefikConfig,
|
apiModifyTraefikConfig,
|
||||||
apiReadTraefikConfig,
|
apiReadTraefikConfig,
|
||||||
apiSaveSSHKey,
|
apiSaveSSHKey,
|
||||||
apiTraefikConfig,
|
apiTraefikConfig,
|
||||||
apiUpdateDockerCleanup,
|
apiUpdateDockerCleanup,
|
||||||
} from "@/server/db/schema";
|
} from "@/server/db/schema";
|
||||||
|
import { initializeTraefik } from "@/server/setup/traefik-setup";
|
||||||
import {
|
import {
|
||||||
cleanStoppedContainers,
|
cleanStoppedContainers,
|
||||||
cleanUpDockerBuilder,
|
cleanUpDockerBuilder,
|
||||||
@@ -67,6 +69,13 @@ export const settingsRouter = createTRPCRouter({
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
|
toggleDashboard: adminProcedure
|
||||||
|
.input(apiEnableDashboard)
|
||||||
|
.mutation(async ({ input }) => {
|
||||||
|
await initializeTraefik(input.enableDashboard);
|
||||||
|
return true;
|
||||||
|
}),
|
||||||
|
|
||||||
cleanUnusedImages: adminProcedure.mutation(async () => {
|
cleanUnusedImages: adminProcedure.mutation(async () => {
|
||||||
await cleanUpUnusedImages();
|
await cleanUpUnusedImages();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -93,3 +93,7 @@ export const apiModifyTraefikConfig = z.object({
|
|||||||
export const apiReadTraefikConfig = z.object({
|
export const apiReadTraefikConfig = z.object({
|
||||||
path: z.string().min(1),
|
path: z.string().min(1),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const apiEnableDashboard = z.object({
|
||||||
|
enableDashboard: z.boolean().optional(),
|
||||||
|
});
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const TRAEFIK_SSL_PORT =
|
|||||||
Number.parseInt(process.env.TRAEFIK_SSL_PORT ?? "", 10) || 443;
|
Number.parseInt(process.env.TRAEFIK_SSL_PORT ?? "", 10) || 443;
|
||||||
const TRAEFIK_PORT = Number.parseInt(process.env.TRAEFIK_PORT ?? "", 10) || 80;
|
const TRAEFIK_PORT = Number.parseInt(process.env.TRAEFIK_PORT ?? "", 10) || 80;
|
||||||
|
|
||||||
export const initializeTraefik = async () => {
|
export const initializeTraefik = async (enableDashboard = false) => {
|
||||||
const imageName = "traefik:v2.5";
|
const imageName = "traefik:v2.5";
|
||||||
const containerName = "dokploy-traefik";
|
const containerName = "dokploy-traefik";
|
||||||
const settings: CreateServiceOptions = {
|
const settings: CreateServiceOptions = {
|
||||||
@@ -59,11 +59,15 @@ export const initializeTraefik = async () => {
|
|||||||
PublishedPort: TRAEFIK_PORT,
|
PublishedPort: TRAEFIK_PORT,
|
||||||
PublishMode: "host",
|
PublishMode: "host",
|
||||||
},
|
},
|
||||||
{
|
...(enableDashboard
|
||||||
TargetPort: 8080,
|
? [
|
||||||
PublishedPort: 8080,
|
{
|
||||||
PublishMode: "host",
|
TargetPort: 8080,
|
||||||
},
|
PublishedPort: 8080,
|
||||||
|
PublishMode: "host" as const,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user