diff --git a/apps/dokploy/components/dashboard/settings/web-server/update-server.tsx b/apps/dokploy/components/dashboard/settings/web-server/update-server.tsx index 1b7eb91a..ae3cbaec 100644 --- a/apps/dokploy/components/dashboard/settings/web-server/update-server.tsx +++ b/apps/dokploy/components/dashboard/settings/web-server/update-server.tsx @@ -5,6 +5,7 @@ import { DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; +import { Input } from "@/components/ui/input"; import { Tooltip, TooltipContent, @@ -45,8 +46,14 @@ export const UpdateServer = ({ const [isUpdateAvailable, setIsUpdateAvailable] = useState( !!updateData?.updateAvailable, ); + const [customImageUrl, setCustomImageUrl] = useState(""); + const [isCustomUpdate, setIsCustomUpdate] = useState(false); const { mutateAsync: getUpdateData, isLoading } = api.settings.getUpdateData.useMutation(); + const { mutateAsync: pullCustomImage, isLoading: isPullingCustom } = + api.settings.pullCustomImage.useMutation(); + const { mutateAsync: updateServer, isLoading: isUpdatingServer } = + api.settings.updateServer.useMutation(); const { data: dokployVersion } = api.settings.getDokployVersion.useQuery(); const { data: releaseTag } = api.settings.getReleaseTag.useQuery(); const [latestVersion, setLatestVersion] = useState( @@ -79,6 +86,41 @@ export const UpdateServer = ({ } }; + const handleCustomUpdate = async () => { + if (!customImageUrl) { + toast.error("Please enter a valid Docker image URL"); + return; + } + + try { + const success = await pullCustomImage({ + imageUrl: customImageUrl, + }); + if (success) { + toast.success("Custom image pulled successfully"); + + // Update the Docker service to use the new image + await updateServer({ imageUrl: customImageUrl }); + toast.success("Server updated successfully"); + onOpenChange?.(false); + } else { + toast.error("Failed to pull custom image"); + } + } catch (error) { + console.error("Error updating server:", error); + const errorMessage = + error instanceof Error + ? error.message + .split("manifest unknown: manifest unknown")[0] + ?.trim() || "Failed to pull image" + : "An error occurred while updating the server"; + + toast.error(errorMessage, { + description: "Please check if the image URL is correct and accessible", + }); + } + }; + const isOpen = isOpenInternal || isOpenProp; const onOpenChange = (open: boolean) => { setIsOpenInternal(open); @@ -141,116 +183,161 @@ export const UpdateServer = ({ )} - {/* Initial state */} - {!hasCheckedUpdate && ( -
- Check for new releases and update Dokploy.
-
-
- We recommend checking for updates regularly to ensure you have the
- latest features and security improvements.
-
- A new version of the server software is available. Consider - updating if you: -
-- Your server is up to date with all the latest features and - security improvements. -
-- Please wait while we pull the latest version information from - Docker Hub. -
-+ Enter the full Docker image URL you want to pull and update to. +
+ Check for new releases and update Dokploy.
+
+
+ We recommend checking for updates regularly to ensure you
+ have the latest features and security improvements.
+
+ A new version of the server software is available. + Consider updating if you: +
++ Your server is up to date with all the latest features + and security improvements. +
++ Please wait while we pull the latest version information + from Docker Hub. +
+