refactor: update template system with new configuration structure and processing

This commit is contained in:
Mauricio Siu
2025-03-01 03:11:29 -06:00
parent 49b37d531a
commit 9aff4bc10b
11 changed files with 585 additions and 434 deletions

View File

@@ -1,9 +0,0 @@
version: "3.8"
services:
pocketbase:
image: spectado/pocketbase:0.23.3
restart: unless-stopped
volumes:
- /etc/dokploy/templates/${HASH}/data:/pb_data
- /etc/dokploy/templates/${HASH}/public:/pb_public
- /etc/dokploy/templates/${HASH}/migrations:/pb_migrations

View File

@@ -1,22 +0,0 @@
import {
type DomainSchema,
type Schema,
type Template,
generateRandomDomain,
} from "../utils";
export function generate(schema: Schema): Template {
const mainDomain = generateRandomDomain(schema);
const domains: DomainSchema[] = [
{
host: mainDomain,
port: 80,
serviceName: "pocketbase",
},
];
return {
domains,
};
}

View File

@@ -47,21 +47,6 @@ export const templates: TemplateData[] = [
load: () => import("./supabase/index").then((m) => m.generate),
tags: ["database", "firebase", "postgres"],
},
{
id: "pocketbase",
name: "Pocketbase",
version: "v0.22.12",
description:
"Pocketbase is a self-hosted alternative to Firebase that allows you to build and host your own backend services.",
links: {
github: "https://github.com/pocketbase/pocketbase",
website: "https://pocketbase.io/",
docs: "https://pocketbase.io/docs/",
},
logo: "pocketbase.svg",
load: () => import("./pocketbase/index").then((m) => m.generate),
tags: ["database", "cms", "headless"],
},
{
id: "plausible",
name: "Plausible",

View File

@@ -28,7 +28,10 @@ export interface Template {
export const generateRandomDomain = ({
serverIp,
projectName,
}: Schema): string => {
}: {
serverIp: string;
projectName: string;
}): string => {
const hash = randomBytes(3).toString("hex");
const slugIp = serverIp.replaceAll(".", "-");
@@ -41,9 +44,15 @@ export const generateHash = (projectName: string, quantity = 3): string => {
};
export const generatePassword = (quantity = 16): string => {
return randomBytes(Math.ceil(quantity / 2))
.toString("hex")
.slice(0, quantity);
const characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let password = "";
for (let i = 0; i < quantity; i++) {
password += characters.charAt(
Math.floor(Math.random() * characters.length),
);
}
return password.toLowerCase();
};
export const generateBase64 = (bytes = 32): string => {