Merge pull request #504 from Jester0027/feature/newt-podman-install

feat(sites): Provide Podman run and Podman Quadlet setup for Newt
This commit is contained in:
Owen Schwartz
2025-04-10 21:40:35 -04:00
committed by GitHub
2 changed files with 50 additions and 24 deletions

2
.gitignore vendored
View File

@@ -32,4 +32,4 @@ installer
bin
.secrets
test_event.json
swagger.ts
.idea/

View File

@@ -25,27 +25,18 @@ import { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
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 CopyTextBox from "@app/components/CopyTextBox";
import CopyToClipboard from "@app/components/CopyToClipboard";
import {
InfoSection,
InfoSectionContent,
InfoSections,
InfoSectionTitle
} from "@app/components/InfoSection";
import { FaWindows, FaApple, FaFreebsd, FaDocker } from "react-icons/fa";
import { InfoSection, InfoSectionContent, InfoSections, InfoSectionTitle } from "@app/components/InfoSection";
import { FaApple, FaCubes, FaDocker, FaFreebsd, FaWindows } from "react-icons/fa";
import { Checkbox } from "@app/components/ui/checkbox";
import { Alert, AlertDescription, AlertTitle } from "@app/components/ui/alert";
import { generateKeypair } from "../[niceId]/wireguardConfig";
import { createApiClient, formatAxiosError } from "@app/lib/api";
import { useEnvContext } from "@app/hooks/useEnvContext";
import {
CreateSiteBody,
CreateSiteResponse,
PickSiteDefaultsResponse
} from "@server/routers/site";
import { CreateSiteBody, CreateSiteResponse, PickSiteDefaultsResponse } from "@server/routers/site";
import { toast } from "@app/hooks/useToast";
import { AxiosResponse } from "axios";
import { useParams, useRouter } from "next/navigation";
@@ -98,8 +89,20 @@ type Commands = {
linux: Record<string, string[]>;
windows: 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() {
const { env } = useEnvContext();
const api = createApiClient({ env });
@@ -132,7 +135,7 @@ export default function Page() {
const [loadingPage, setLoadingPage] = useState(true);
const [platform, setPlatform] = useState("linux");
const [platform, setPlatform] = useState<Platform>("linux");
const [architecture, setArchitecture] = useState("amd64");
const [commands, setCommands] = useState<Commands | null>(null);
@@ -240,6 +243,29 @@ PersistentKeepalive = 5`;
"Docker Run": [
`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);
@@ -255,6 +281,8 @@ PersistentKeepalive = 5`;
return ["x64"];
case "docker":
return ["Docker Compose", "Docker Run"];
case "podman":
return ["Podman Quadlet", "Podman Run"];
case "freebsd":
return ["amd64", "arm64"];
default:
@@ -270,6 +298,8 @@ PersistentKeepalive = 5`;
return "macOS";
case "docker":
return "Docker";
case "podman":
return "Podman";
case "freebsd":
return "FreeBSD";
default:
@@ -286,7 +316,7 @@ PersistentKeepalive = 5`;
if (!platformCommands) {
// get first key
const firstPlatform = Object.keys(commands)[0];
const firstPlatform = Object.keys(commands)[0] as Platform;
platformCommands = commands[firstPlatform as keyof Commands];
setPlatform(firstPlatform);
@@ -312,6 +342,8 @@ PersistentKeepalive = 5`;
return <FaApple className="h-4 w-4 mr-2" />;
case "docker":
return <FaDocker className="h-4 w-4 mr-2" />;
case "podman":
return <FaCubes className="h-4 w-4 mr-2" />;
case "freebsd":
return <FaFreebsd className="h-4 w-4 mr-2" />;
default:
@@ -685,13 +717,7 @@ PersistentKeepalive = 5`;
Operating System
</p>
<div className="grid grid-cols-2 md:grid-cols-5 gap-2">
{[
"linux",
"docker",
"mac",
"windows",
"freebsd"
].map((os) => (
{platforms.map((os) => (
<Button
key={os}
variant={
@@ -713,7 +739,7 @@ PersistentKeepalive = 5`;
<div>
<p className="font-bold mb-3">
{platform === "docker"
{["docker", "podman"].includes(platform)
? "Method"
: "Architecture"}
</p>