From 690a2e74671c0a2091651dcbc747e8067f055d30 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 14 Dec 2024 12:37:50 -0600 Subject: [PATCH 1/5] refactor: add description on search --- apps/dokploy/components/dashboard/project/add-template.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/dokploy/components/dashboard/project/add-template.tsx b/apps/dokploy/components/dashboard/project/add-template.tsx index f60d8b07..cc37cad4 100644 --- a/apps/dokploy/components/dashboard/project/add-template.tsx +++ b/apps/dokploy/components/dashboard/project/add-template.tsx @@ -92,7 +92,8 @@ export const AddTemplate = ({ projectId }: Props) => { template.tags.some((tag) => selectedTags.includes(tag)); const matchesQuery = query === "" || - template.name.toLowerCase().includes(query.toLowerCase()); + template.name.toLowerCase().includes(query.toLowerCase()) || + template.description.toLowerCase().includes(query.toLowerCase()); return matchesTags && matchesQuery; }) || []; From 1e834ed1d987946930b50a61fe83ec92048ec990 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 14 Dec 2024 20:17:20 -0600 Subject: [PATCH 2/5] feat: add elastic search --- .../public/templates/elasticsearch.svg | 1 + .../elastic-search/docker-compose.yml | 34 +++++++++++++++++++ .../dokploy/templates/elastic-search/index.ts | 28 +++++++++++++++ apps/dokploy/templates/templates.ts | 15 ++++++++ 4 files changed, 78 insertions(+) create mode 100644 apps/dokploy/public/templates/elasticsearch.svg create mode 100644 apps/dokploy/templates/elastic-search/docker-compose.yml create mode 100644 apps/dokploy/templates/elastic-search/index.ts diff --git a/apps/dokploy/public/templates/elasticsearch.svg b/apps/dokploy/public/templates/elasticsearch.svg new file mode 100644 index 00000000..b95507cd --- /dev/null +++ b/apps/dokploy/public/templates/elasticsearch.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/dokploy/templates/elastic-search/docker-compose.yml b/apps/dokploy/templates/elastic-search/docker-compose.yml new file mode 100644 index 00000000..929006ff --- /dev/null +++ b/apps/dokploy/templates/elastic-search/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3.8' + +services: + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:8.10.2 + container_name: elasticsearch + environment: + - discovery.type=single-node + - xpack.security.enabled=false + - bootstrap.memory_lock=true + - ES_JAVA_OPTS=-Xms512m -Xmx512m + ulimits: + memlock: + soft: -1 + hard: -1 + ports: + - "9200" + volumes: + - es_data:/usr/share/elasticsearch/data + + kibana: + image: docker.elastic.co/kibana/kibana:8.10.2 + container_name: kibana + environment: + - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 + ports: + - "5601" + depends_on: + - elasticsearch + +volumes: + es_data: + driver: local + \ No newline at end of file diff --git a/apps/dokploy/templates/elastic-search/index.ts b/apps/dokploy/templates/elastic-search/index.ts new file mode 100644 index 00000000..5a3a31e1 --- /dev/null +++ b/apps/dokploy/templates/elastic-search/index.ts @@ -0,0 +1,28 @@ +import { + type DomainSchema, + type Schema, + type Template, + generateRandomDomain, +} from "../utils"; + +export function generate(schema: Schema): Template { + const mainDomain = generateRandomDomain(schema); + const apiDomain = generateRandomDomain(schema); + + const domains: DomainSchema[] = [ + { + host: mainDomain, + port: 5601, + serviceName: "kibana", + }, + { + host: apiDomain, + port: 9200, + serviceName: "elasticsearch", + }, + ]; + + return { + domains, + }; +} diff --git a/apps/dokploy/templates/templates.ts b/apps/dokploy/templates/templates.ts index 9aaf1ee0..adfc021c 100644 --- a/apps/dokploy/templates/templates.ts +++ b/apps/dokploy/templates/templates.ts @@ -1121,4 +1121,19 @@ export const templates: TemplateData[] = [ tags: ["ai"], load: () => import("./langflow/index").then((m) => m.generate), }, + { + id: "elastic-search", + name: "Elasticsearch", + version: "1.1.1", + description: + "Elasticsearch is an open-source search and analytics engine, used for full-text search and analytics on structured data such as text, web pages, images, and videos.", + logo: "elasticsearch.svg", + links: { + github: "https://github.com/elastic/elasticsearch", + website: "https://www.elastic.co/elasticsearch/", + docs: "https://docs.elastic.co/elasticsearch/", + }, + tags: ["ai"], + load: () => import("./elastic-search/index").then((m) => m.generate), + }, ]; From 3fe057c7f82c8f52a19666f25395184ce0f1e40f Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 14 Dec 2024 20:17:38 -0600 Subject: [PATCH 3/5] refactor: set version --- apps/dokploy/templates/templates.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/dokploy/templates/templates.ts b/apps/dokploy/templates/templates.ts index adfc021c..39243356 100644 --- a/apps/dokploy/templates/templates.ts +++ b/apps/dokploy/templates/templates.ts @@ -1124,7 +1124,7 @@ export const templates: TemplateData[] = [ { id: "elastic-search", name: "Elasticsearch", - version: "1.1.1", + version: "8.10.2", description: "Elasticsearch is an open-source search and analytics engine, used for full-text search and analytics on structured data such as text, web pages, images, and videos.", logo: "elasticsearch.svg", @@ -1133,7 +1133,7 @@ export const templates: TemplateData[] = [ website: "https://www.elastic.co/elasticsearch/", docs: "https://docs.elastic.co/elasticsearch/", }, - tags: ["ai"], + tags: ["search", "analytics"], load: () => import("./elastic-search/index").then((m) => m.generate), }, ]; From ea0f797d0f81aa9998bbced7d4793c0ce221644b Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 14 Dec 2024 20:28:28 -0600 Subject: [PATCH 4/5] feat: redirect to deployments when click on deploy --- .../application/general/deploy-application.tsx | 5 +++++ .../dashboard/compose/general/deploy-compose.tsx | 14 +++++++++++--- .../services/application/[applicationId].tsx | 15 +++++++++++---- .../[projectId]/services/compose/[composeId].tsx | 15 +++++++++++---- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/apps/dokploy/components/dashboard/application/general/deploy-application.tsx b/apps/dokploy/components/dashboard/application/general/deploy-application.tsx index f9115c76..252894dd 100644 --- a/apps/dokploy/components/dashboard/application/general/deploy-application.tsx +++ b/apps/dokploy/components/dashboard/application/general/deploy-application.tsx @@ -11,6 +11,7 @@ import { } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { api } from "@/utils/api"; +import { useRouter } from "next/router"; import { toast } from "sonner"; interface Props { @@ -18,6 +19,7 @@ interface Props { } export const DeployApplication = ({ applicationId }: Props) => { + const router = useRouter(); const { data, refetch } = api.application.one.useQuery( { applicationId, @@ -51,6 +53,9 @@ export const DeployApplication = ({ applicationId }: Props) => { .then(async () => { toast.success("Application deployed succesfully"); await refetch(); + router.push( + `/dashboard/project/${data?.projectId}/services/application/${applicationId}?tab=deployments`, + ); }) .catch(() => { diff --git a/apps/dokploy/components/dashboard/compose/general/deploy-compose.tsx b/apps/dokploy/components/dashboard/compose/general/deploy-compose.tsx index e9d5dfc1..c02a7802 100644 --- a/apps/dokploy/components/dashboard/compose/general/deploy-compose.tsx +++ b/apps/dokploy/components/dashboard/compose/general/deploy-compose.tsx @@ -11,6 +11,7 @@ import { } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { api } from "@/utils/api"; +import { useRouter } from "next/router"; import { toast } from "sonner"; interface Props { @@ -18,6 +19,7 @@ interface Props { } export const DeployCompose = ({ composeId }: Props) => { + const router = useRouter(); const { data, refetch } = api.compose.one.useQuery( { composeId, @@ -48,9 +50,15 @@ export const DeployCompose = ({ composeId }: Props) => { await refetch(); await deploy({ composeId, - }).catch(() => { - toast.error("Error to deploy Compose"); - }); + }) + .then(async () => { + router.push( + `/dashboard/project/${data?.project.projectId}/services/compose/${composeId}?tab=deployments` + ); + }) + .catch(() => { + toast.error("Error to deploy Compose"); + }); await refetch(); }} diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx index 1682348c..8d3f8df2 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx @@ -44,7 +44,7 @@ import type { import Head from "next/head"; import Link from "next/link"; import { useRouter } from "next/router"; -import React, { useState, type ReactElement } from "react"; +import React, { useState, useEffect, type ReactElement } from "react"; import superjson from "superjson"; type TabState = @@ -62,7 +62,14 @@ const Service = ( const { applicationId, activeTab } = props; const router = useRouter(); const { projectId } = router.query; - const [tab, setSab] = useState(activeTab); + const [tab, setTab] = useState(activeTab); + + useEffect(() => { + if (router.query.tab) { + setTab(router.query.tab as TabState); + } + }, [router.query.tab]); + const { data } = api.application.one.useQuery( { applicationId }, { @@ -191,9 +198,9 @@ const Service = ( defaultValue="general" className="w-full" onValueChange={(e) => { - setSab(e as TabState); + setTab(e as TabState); const newPath = `/dashboard/project/${projectId}/services/application/${applicationId}?tab=${e}`; - router.push(newPath, undefined, { shallow: true }); + router.push(newPath); }} >
diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx index 6b9cae51..69145e8a 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx @@ -38,7 +38,7 @@ import type { import Head from "next/head"; import Link from "next/link"; import { useRouter } from "next/router"; -import React, { useState, type ReactElement } from "react"; +import React, { useState, useEffect, type ReactElement } from "react"; import superjson from "superjson"; type TabState = @@ -55,7 +55,14 @@ const Service = ( const { composeId, activeTab } = props; const router = useRouter(); const { projectId } = router.query; - const [tab, setSab] = useState(activeTab); + const [tab, setTab] = useState(activeTab); + + useEffect(() => { + if (router.query.tab) { + setTab(router.query.tab as TabState); + } + }, [router.query.tab]); + const { data } = api.compose.one.useQuery( { composeId }, { @@ -183,9 +190,9 @@ const Service = ( defaultValue="general" className="w-full" onValueChange={(e) => { - setSab(e as TabState); + setTab(e as TabState); const newPath = `/dashboard/project/${projectId}/services/compose/${composeId}?tab=${e}`; - router.push(newPath, undefined, { shallow: true }); + router.push(newPath); }} >
From 7521bc8297dbab03c8c791d2320f2aee650ac52e Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 14 Dec 2024 20:38:33 -0600 Subject: [PATCH 5/5] refactor: remove calculation and pass resources as the docker api expect --- packages/server/src/utils/docker/utils.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/server/src/utils/docker/utils.ts b/packages/server/src/utils/docker/utils.ts index c2dce838..216ee867 100644 --- a/packages/server/src/utils/docker/utils.ts +++ b/packages/server/src/utils/docker/utils.ts @@ -317,16 +317,12 @@ export const calculateResources = ({ }: Resources): ResourceRequirements => { return { Limits: { - MemoryBytes: memoryLimit ? memoryLimit * 1024 * 1024 : undefined, - NanoCPUs: cpuLimit ? (cpuLimit || 1) * 1000 * 1000 * 1000 : undefined, + MemoryBytes: memoryLimit ?? undefined, + NanoCPUs: cpuLimit ?? undefined, }, Reservations: { - MemoryBytes: memoryReservation - ? (memoryReservation || 1) * 1024 * 1024 - : undefined, - NanoCPUs: cpuReservation - ? (cpuReservation || 1) * 1000 * 1000 * 1000 - : undefined, + MemoryBytes: memoryReservation ?? undefined, + NanoCPUs: cpuReservation ?? undefined, }, }; };