import copy from "copy-to-clipboard"; import { CopyIcon, ExternalLinkIcon, ServerIcon, Settings } from "lucide-react"; import Link from "next/link"; import { useState } from "react"; import { toast } from "sonner"; import { AlertBlock } from "@/components/shared/alert-block"; import { CodeEditor } from "@/components/shared/code-editor"; import { DialogAction } from "@/components/shared/dialog-action"; import { DrawerLogs } from "@/components/shared/drawer-logs"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { DropdownMenuItem } from "@/components/ui/dropdown-menu"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { cn } from "@/lib/utils"; import { api } from "@/utils/api"; import { ShowDeployment } from "../../application/deployments/show-deployment"; import { type LogLine, parseLogs } from "../../docker/logs/utils"; import { EditScript } from "./edit-script"; import { GPUSupport } from "./gpu-support"; import { SecurityAudit } from "./security-audit"; import { SetupMonitoring } from "./setup-monitoring"; import { ValidateServer } from "./validate-server"; interface Props { serverId: string; asButton?: boolean; } export const SetupServer = ({ serverId, asButton = false }: Props) => { const [isOpen, setIsOpen] = useState(false); const { data: server } = api.server.one.useQuery( { serverId, }, { enabled: !!serverId, }, ); const [activeLog, setActiveLog] = useState(null); const { data: isCloud } = api.settings.isCloud.useQuery(); const isBuildServer = server?.serverType === "build"; const [isDrawerOpen, setIsDrawerOpen] = useState(false); const [filteredLogs, setFilteredLogs] = useState([]); const [isDeploying, setIsDeploying] = useState(false); api.server.setupWithLogs.useSubscription( { serverId: serverId, }, { enabled: isDeploying, onData(log) { if (!isDrawerOpen) { setIsDrawerOpen(true); } if (log === "Deployment completed successfully!") { setIsDeploying(false); } const parsedLogs = parseLogs(log); setFilteredLogs((prev) => [...prev, ...parsedLogs]); }, onError(error) { console.error("Deployment logs error:", error); setIsDeploying(false); }, }, ); return ( {asButton ? ( ) : ( { e.preventDefault(); setIsOpen(true); }} > Setup Server )}
Setup Server

To setup a server, please click on the button below.

{!server?.sshKeyId ? (
Please add a SSH Key to your server before setting up the server. you can assign a SSH Key to your server in Edit Server.
) : (
Using a root user is required to ensure everything works as expected. SSH Keys Deployments Validate {!isBuildServer && ( <> Security {isCloud && ( Monitoring )} GPU Setup )}

You have two options to add SSH Keys to your server:

  • 1. Add the public SSH Key when you create a server in your preffered provider (Hostinger, Digital Ocean, Hetzner, etc){" "}
  • 2. Add The SSH Key to Server Manually
Copy Public Key ({server?.sshKey?.name})
Automatic process View Tutorial
Manual process
  • 1. Login to your server{" "} ssh {server?.username}@{server?.ipAddress}
  • 2. When you are logged in run the following command
    > ~/.ssh/authorized_keys`} readOnly className="font-mono opacity-60" />
  • 3. You're done, you can test the connection by entering to the terminal or by setting up the server tab.
Supported Distros:

We strongly recommend to use the following distros to ensure the best experience:

  • 1. Ubuntu 24.04 LTS
  • 2. Ubuntu 23.10 LTS
  • 3. Ubuntu 22.04 LTS
  • 4. Ubuntu 20.04 LTS
  • 5. Ubuntu 18.04 LTS
  • 6. Debian 12
  • 7. Debian 11
  • 8. Debian 10
  • 9. Fedora 40
  • 10. Centos 9
  • 11. Centos 8
Setup Server To setup a server, please click on the button below.
When your server is ready, you can click on the button below, to directly run the script we use for setup the server or directly modify the script
{ setIsDeploying(true); }} >
setActiveLog(null)} logPath={activeLog} />
{!isBuildServer && ( <>
)}
)}
{ setIsDrawerOpen(false); setFilteredLogs([]); setIsDeploying(false); }} filteredLogs={filteredLogs} />
); };