mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-08 05:56:38 +00:00
feat(sites): Provide Podman run and Podman Quadlet setup for Newt
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -32,3 +32,4 @@ installer
|
|||||||
bin
|
bin
|
||||||
.secrets
|
.secrets
|
||||||
test_event.json
|
test_event.json
|
||||||
|
.idea/
|
||||||
|
|||||||
@@ -25,27 +25,18 @@ import { useEffect, useState } from "react";
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { Input } from "@app/components/ui/input";
|
import { Input } from "@app/components/ui/input";
|
||||||
import { Terminal, InfoIcon } from "lucide-react";
|
import { InfoIcon, Terminal } from "lucide-react";
|
||||||
import { Button } from "@app/components/ui/button";
|
import { Button } from "@app/components/ui/button";
|
||||||
import CopyTextBox from "@app/components/CopyTextBox";
|
import CopyTextBox from "@app/components/CopyTextBox";
|
||||||
import CopyToClipboard from "@app/components/CopyToClipboard";
|
import CopyToClipboard from "@app/components/CopyToClipboard";
|
||||||
import {
|
import { InfoSection, InfoSectionContent, InfoSections, InfoSectionTitle } from "@app/components/InfoSection";
|
||||||
InfoSection,
|
import { FaApple, FaCubes, FaDocker, FaFreebsd, FaWindows } from "react-icons/fa";
|
||||||
InfoSectionContent,
|
|
||||||
InfoSections,
|
|
||||||
InfoSectionTitle
|
|
||||||
} from "@app/components/InfoSection";
|
|
||||||
import { FaWindows, FaApple, FaFreebsd, FaDocker } from "react-icons/fa";
|
|
||||||
import { Checkbox } from "@app/components/ui/checkbox";
|
import { Checkbox } from "@app/components/ui/checkbox";
|
||||||
import { Alert, AlertDescription, AlertTitle } from "@app/components/ui/alert";
|
import { Alert, AlertDescription, AlertTitle } from "@app/components/ui/alert";
|
||||||
import { generateKeypair } from "../[niceId]/wireguardConfig";
|
import { generateKeypair } from "../[niceId]/wireguardConfig";
|
||||||
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
import {
|
import { CreateSiteBody, CreateSiteResponse, PickSiteDefaultsResponse } from "@server/routers/site";
|
||||||
CreateSiteBody,
|
|
||||||
CreateSiteResponse,
|
|
||||||
PickSiteDefaultsResponse
|
|
||||||
} from "@server/routers/site";
|
|
||||||
import { toast } from "@app/hooks/useToast";
|
import { toast } from "@app/hooks/useToast";
|
||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
import { useParams, useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
@@ -91,8 +82,20 @@ type Commands = {
|
|||||||
linux: Record<string, string[]>;
|
linux: Record<string, string[]>;
|
||||||
windows: Record<string, string[]>;
|
windows: Record<string, string[]>;
|
||||||
docker: Record<string, string[]>;
|
docker: Record<string, string[]>;
|
||||||
|
podman: Record<string, string[]>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const platforms = [
|
||||||
|
"linux",
|
||||||
|
"docker",
|
||||||
|
"podman",
|
||||||
|
"mac",
|
||||||
|
"windows",
|
||||||
|
"freebsd"
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
type Platform = typeof platforms[number];
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const { env } = useEnvContext();
|
const { env } = useEnvContext();
|
||||||
const api = createApiClient({ env });
|
const api = createApiClient({ env });
|
||||||
@@ -123,7 +126,7 @@ export default function Page() {
|
|||||||
|
|
||||||
const [loadingPage, setLoadingPage] = useState(true);
|
const [loadingPage, setLoadingPage] = useState(true);
|
||||||
|
|
||||||
const [platform, setPlatform] = useState("linux");
|
const [platform, setPlatform] = useState<Platform>("linux");
|
||||||
const [architecture, setArchitecture] = useState("amd64");
|
const [architecture, setArchitecture] = useState("amd64");
|
||||||
const [commands, setCommands] = useState<Commands | null>(null);
|
const [commands, setCommands] = useState<Commands | null>(null);
|
||||||
|
|
||||||
@@ -231,6 +234,29 @@ PersistentKeepalive = 5`;
|
|||||||
"Docker Run": [
|
"Docker Run": [
|
||||||
`docker run -it fosrl/newt --id ${id} --secret ${secret} --endpoint ${endpoint}`
|
`docker run -it fosrl/newt --id ${id} --secret ${secret} --endpoint ${endpoint}`
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
podman: {
|
||||||
|
"Podman Quadlet": [
|
||||||
|
`[Unit]
|
||||||
|
Description=Newt container
|
||||||
|
|
||||||
|
[Container]
|
||||||
|
ContainerName=newt
|
||||||
|
Image=docker.io/fosrl/newt
|
||||||
|
Environment=PANGOLIN_ENDPOINT=${endpoint}
|
||||||
|
Environment=NEWT_ID=${id}
|
||||||
|
Environment=NEWT_SECRET=${secret}
|
||||||
|
# Secret=newt-secret,type=env,target=NEWT_SECRET
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target`
|
||||||
|
],
|
||||||
|
"Podman Run": [
|
||||||
|
`podman run -it docker.io/fosrl/newt --id ${id} --secret ${secret} --endpoint ${endpoint}`
|
||||||
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setCommands(commands);
|
setCommands(commands);
|
||||||
@@ -246,6 +272,8 @@ PersistentKeepalive = 5`;
|
|||||||
return ["x64"];
|
return ["x64"];
|
||||||
case "docker":
|
case "docker":
|
||||||
return ["Docker Compose", "Docker Run"];
|
return ["Docker Compose", "Docker Run"];
|
||||||
|
case "podman":
|
||||||
|
return ["Podman Quadlet", "Podman Run"];
|
||||||
case "freebsd":
|
case "freebsd":
|
||||||
return ["amd64", "arm64"];
|
return ["amd64", "arm64"];
|
||||||
default:
|
default:
|
||||||
@@ -261,6 +289,8 @@ PersistentKeepalive = 5`;
|
|||||||
return "macOS";
|
return "macOS";
|
||||||
case "docker":
|
case "docker":
|
||||||
return "Docker";
|
return "Docker";
|
||||||
|
case "podman":
|
||||||
|
return "Podman";
|
||||||
case "freebsd":
|
case "freebsd":
|
||||||
return "FreeBSD";
|
return "FreeBSD";
|
||||||
default:
|
default:
|
||||||
@@ -277,7 +307,7 @@ PersistentKeepalive = 5`;
|
|||||||
|
|
||||||
if (!platformCommands) {
|
if (!platformCommands) {
|
||||||
// get first key
|
// get first key
|
||||||
const firstPlatform = Object.keys(commands)[0];
|
const firstPlatform = Object.keys(commands)[0] as Platform;
|
||||||
platformCommands = commands[firstPlatform as keyof Commands];
|
platformCommands = commands[firstPlatform as keyof Commands];
|
||||||
|
|
||||||
setPlatform(firstPlatform);
|
setPlatform(firstPlatform);
|
||||||
@@ -303,6 +333,8 @@ PersistentKeepalive = 5`;
|
|||||||
return <FaApple className="h-4 w-4 mr-2" />;
|
return <FaApple className="h-4 w-4 mr-2" />;
|
||||||
case "docker":
|
case "docker":
|
||||||
return <FaDocker className="h-4 w-4 mr-2" />;
|
return <FaDocker className="h-4 w-4 mr-2" />;
|
||||||
|
case "podman":
|
||||||
|
return <FaCubes className="h-4 w-4 mr-2" />;
|
||||||
case "freebsd":
|
case "freebsd":
|
||||||
return <FaFreebsd className="h-4 w-4 mr-2" />;
|
return <FaFreebsd className="h-4 w-4 mr-2" />;
|
||||||
default:
|
default:
|
||||||
@@ -689,13 +721,7 @@ PersistentKeepalive = 5`;
|
|||||||
Operating System
|
Operating System
|
||||||
</p>
|
</p>
|
||||||
<div className="grid grid-cols-2 md:grid-cols-5 gap-2">
|
<div className="grid grid-cols-2 md:grid-cols-5 gap-2">
|
||||||
{[
|
{platforms.map((os) => (
|
||||||
"linux",
|
|
||||||
"docker",
|
|
||||||
"mac",
|
|
||||||
"windows",
|
|
||||||
"freebsd"
|
|
||||||
].map((os) => (
|
|
||||||
<Button
|
<Button
|
||||||
key={os}
|
key={os}
|
||||||
variant={
|
variant={
|
||||||
@@ -717,7 +743,7 @@ PersistentKeepalive = 5`;
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p className="font-bold mb-3">
|
<p className="font-bold mb-3">
|
||||||
{platform === "docker"
|
{["docker", "podman"].includes(platform)
|
||||||
? "Method"
|
? "Method"
|
||||||
: "Architecture"}
|
: "Architecture"}
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user