From c53833f42dc7c4518c5469bf184a7e73d55058d8 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 1 Jun 2024 20:04:36 -0600 Subject: [PATCH] removed --- .../templates/pocketbase/docker-compose.yml | 23 ------- server/templates/pocketbase/index.ts | 22 ------ server/templates/templates.ts | 69 ------------------- server/templates/types/templates-data.type.ts | 17 ----- server/templates/utils/index.ts | 56 --------------- 5 files changed, 187 deletions(-) delete mode 100644 server/templates/pocketbase/docker-compose.yml delete mode 100644 server/templates/pocketbase/index.ts delete mode 100644 server/templates/templates.ts delete mode 100644 server/templates/types/templates-data.type.ts delete mode 100644 server/templates/utils/index.ts diff --git a/server/templates/pocketbase/docker-compose.yml b/server/templates/pocketbase/docker-compose.yml deleted file mode 100644 index 2e8171ff6..000000000 --- a/server/templates/pocketbase/docker-compose.yml +++ /dev/null @@ -1,23 +0,0 @@ -version: "3.7" -services: - pocketbase: - image: spectado/pocketbase:latest - restart: unless-stopped - ports: - - ${POCKETBASE_PORT} - networks: - - dokploy-network - labels: - - traefik.enable=true - - traefik.http.routers.${HASH}.rule=Host(`${DOMAIN}`) - - traefik.http.routers.${HASH}.entrypoints=websecure - - traefik.http.routers.${HASH}.tls.certResolver=letsencrypt - - traefik.http.services.${HASH}.loadbalancer.server.port=${POCKETBASE_PORT} - volumes: - - /etc/dokploy/templates/${HASH}/data:/pb_data - - /etc/dokploy/templates/${HASH}/public:/pb_public - - /etc/dokploy/templates/${HASH}/migrations:/pb_migrations - -networks: - dokploy-network: - external: true \ No newline at end of file diff --git a/server/templates/pocketbase/index.ts b/server/templates/pocketbase/index.ts deleted file mode 100644 index a38ec3124..000000000 --- a/server/templates/pocketbase/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { - generateHash, - generateRandomDomain, - type Template, - type Schema, -} from "../utils"; - -// https://pocketbase.io/docs/ -export function generate(schema: Schema): Template { - const mainServiceHash = generateHash(schema.projectName); - const randomDomain = generateRandomDomain(schema); - - const envs = [ - `POCKETBASE_HOST=${randomDomain}`, - "POCKETBASE_PORT=80", - `HASH=${mainServiceHash}`, - ]; - - return { - envs, - }; -} diff --git a/server/templates/templates.ts b/server/templates/templates.ts deleted file mode 100644 index 9d24ccd6c..000000000 --- a/server/templates/templates.ts +++ /dev/null @@ -1,69 +0,0 @@ -import type { TemplateData } from "./types/templates-data.type"; - -export const templates: TemplateData[] = [ - { - name: "Pocketbase", - description: - "Pocketbase is a self-hosted alternative to Firebase that allows you to build and host your own backend services.", - type: "docker-compose", - folder: "pocketbase", - links: { - github: "https://github.com/pocketbase/pocketbase", - docs: "https://docs.pocketbase.io/", - }, - logo: "https://pocketbase.io/images/logo.svg", - load: () => import("./pocketbase/index").then((m) => m.generate), - }, - // { - // name: "Plausible", - // description: - // "Plausible is a simple, open source, self-hosted web analytics platform that lets you track website traffic and user behavior.", - // type: "docker-compose", - // folder: "plausible", - // links: { - // github: "https://github.com/plausible/plausible", - // docs: "https://plausible.io/docs/docker/", - // }, - // logo: "https://plausible.io/assets/images/icon/plausible_logo.svg", - // load: () => import("./plausible/index").then((m) => m.generate), - // }, - // { - // name: "Directus", - // description: - // "Directus is a self-hosted headless CMS that allows you to build and host your own backend services.", - // type: "docker-compose", - // folder: "directus", - // links: { - // github: "https://github.com/directus/directus", - // docs: "https://docs.directus.io/", - // }, - // logo: "https://directus.io/_nuxt/logo-dark.Bhm22UGW.svg", - // load: () => import("./directus/index").then((m) => m.generate), - // }, - // { - // name: "ActualBudget", - // description: - // "ActualBudget is a self-hosted budgeting app that allows you to build and host your own backend services.", - // type: "docker-compose", - // folder: "actualbudget", - // links: { - // github: "https://github.com/actualbudget/actualbudget", - // docs: "https://docs.actualbudget.org/", - // }, - // logo: "https://actualbudget.org/img/actual.png", - // load: () => import("./actualbudget/index").then((m) => m.generate), - // }, - // { - // name: "Calcom", - // description: - // "Calcom is a open source alternative to Calendly that allows to create scheduling and booking services.", - // type: "docker-compose", - // folder: "calcom", - // links: { - // github: "https://github.com/calcom/cal.com", - // docs: "https://docs.calcom.com/", - // }, - // logo: "https://raw.githubusercontent.com/calcom/cal.com/main/apps/web/public/emails/logo.png", - // load: () => import("./calcom/index").then((m) => m.generate), - // }, -]; diff --git a/server/templates/types/templates-data.type.ts b/server/templates/types/templates-data.type.ts deleted file mode 100644 index 8cc7ec9df..000000000 --- a/server/templates/types/templates-data.type.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { templates } from "../templates"; -import type { Schema, Template } from "../utils"; - -export type TemplatesKeys = (typeof templates)[number]["folder"]; - -export type TemplateData = { - name: string; - description: string; - type: string; - folder: string; - links: { - github: string; - docs: string; - }; - logo: string; - load: () => Promise<(schema: Schema) => Template>; -}; diff --git a/server/templates/utils/index.ts b/server/templates/utils/index.ts deleted file mode 100644 index d0e2ea4f6..000000000 --- a/server/templates/utils/index.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { randomBytes } from "node:crypto"; -import { TRPCError } from "@trpc/server"; -import { templates } from "../templates"; -import type { TemplatesKeys } from "../types/templates-data.type"; -import { readFile } from "node:fs/promises"; -import { join } from "node:path"; - -export interface Schema { - domain: string; - projectName: string; -} - -export interface Template { - envs: string[]; - mounts?: { - mountPath: string; - content?: string; - }[]; -} - -export const generateRandomDomain = ({ - domain, - projectName, -}: Schema): string => { - const hash = randomBytes(4).toString("hex"); - return `${projectName}-${hash}.${domain}`; -}; - -export const generateHash = (projectName: string): string => { - const hash = randomBytes(4).toString("hex"); - return `${projectName}-${hash}`; -}; - -export const loadTemplateModule = async ( - folder: TemplatesKeys, -): Promise<(schema: Schema) => Template> => { - const templateLoader = templates.find((t) => t.folder === folder); - if (!templateLoader) { - throw new TRPCError({ - code: "BAD_REQUEST", - message: `Template ${folder} not found or not implemented yet`, - }); - } - - const generate = await templateLoader.load(); - return generate; -}; - -export const readComposeFile = async (folder: string) => { - const composeFile = await readFile( - join("server", "templates", folder, "docker-compose.yml"), - "utf8", - ); - - return composeFile; -};