import { AlertBlock } from "@/components/shared/alert-block"; import { CodeEditor } from "@/components/shared/code-editor"; import { Button } from "@/components/ui/button"; import { DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, } from "@/components/ui/form"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; import { api } from "@/utils/api"; import { zodResolver } from "@hookform/resolvers/zod"; import { AlertTriangle } from "lucide-react"; import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; import { z } from "zod"; interface Props { composeId: string; } const schema = z.object({ isolatedDeployment: z.boolean().optional(), }); type Schema = z.infer; export const IsolatedDeployment = ({ composeId }: Props) => { const utils = api.useUtils(); const [compose, setCompose] = useState(""); const { mutateAsync, error, isError } = api.compose.isolatedDeployment.useMutation(); const { mutateAsync: updateCompose } = api.compose.update.useMutation(); const { data, refetch } = api.compose.one.useQuery( { composeId }, { enabled: !!composeId }, ); console.log(data); const form = useForm({ defaultValues: { isolatedDeployment: false, }, resolver: zodResolver(schema), }); useEffect(() => { randomizeCompose(); if (data) { form.reset({ isolatedDeployment: data?.isolatedDeployment || false, }); } }, [form, form.reset, form.formState.isSubmitSuccessful, data]); const onSubmit = async (formData: Schema) => { await updateCompose({ composeId, isolatedDeployment: formData?.isolatedDeployment || false, }) .then(async (_data) => { randomizeCompose(); refetch(); toast.success("Compose updated"); }) .catch(() => { toast.error("Error updating the compose"); }); }; const randomizeCompose = async () => { await mutateAsync({ composeId, suffix: data?.appName || "", }) .then(async (data) => { await utils.project.all.invalidate(); setCompose(data); toast.success("Compose Isolated"); }) .catch(() => { toast.error("Error isolating the compose"); }); }; return ( <> Isolate Deployment Use this option to isolate the deployment of this compose file.
This feature creates an isolated environment for your deployment by adding unique prefixes to all resources. It establishes a dedicated network based on your compose file's name, ensuring your services run in isolation. This prevents conflicts when running multiple instances of the same template or services with identical names.

Resources that will be isolated:

  • Docker volumes
  • Docker networks
{isError && {error?.message}}
{isError && (
{error?.message}
)}
(
Enable Isolated Deployment ({data?.appName}) Enable isolated deployment to the compose file.
)} />
							
						
); };