From 21dee4abac133165e5214e2f308bfa3d479512c6 Mon Sep 17 00:00:00 2001
From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com>
Date: Sun, 22 Sep 2024 20:03:48 -0600
Subject: [PATCH 1/8] refactor: update social networks
---
apps/docs/app/[lang]/[[...slug]]/page.tsx | 2 +-
apps/website/components/Footer.tsx | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/docs/app/[lang]/[[...slug]]/page.tsx b/apps/docs/app/[lang]/[[...slug]]/page.tsx
index 9a7f3d2c..8307d655 100644
--- a/apps/docs/app/[lang]/[[...slug]]/page.tsx
+++ b/apps/docs/app/[lang]/[[...slug]]/page.tsx
@@ -74,7 +74,7 @@ export function generateMetadata({
},
twitter: {
card: "summary_large_image",
- creator: "@siumauricio",
+ creator: "@getdokploy",
title: page.data.title,
description: page.data.description,
images: [
diff --git a/apps/website/components/Footer.tsx b/apps/website/components/Footer.tsx
index c1235add..88ac33a5 100644
--- a/apps/website/components/Footer.tsx
+++ b/apps/website/components/Footer.tsx
@@ -33,7 +33,7 @@ export function Footer() {
From 3b9f5d6f5c73f1d13c9e5ecd37b2bb11eef3db57 Mon Sep 17 00:00:00 2001
From: Ben
Date: Thu, 26 Sep 2024 13:14:14 +0200
Subject: [PATCH 2/8] feat: add presets for add-redirect dialog
---
.../advanced/redirects/add-redirect.tsx | 85 +++++++++++++++++--
1 file changed, 80 insertions(+), 5 deletions(-)
diff --git a/apps/dokploy/components/dashboard/application/advanced/redirects/add-redirect.tsx b/apps/dokploy/components/dashboard/application/advanced/redirects/add-redirect.tsx
index efe1b9ac..320471ba 100644
--- a/apps/dokploy/components/dashboard/application/advanced/redirects/add-redirect.tsx
+++ b/apps/dokploy/components/dashboard/application/advanced/redirects/add-redirect.tsx
@@ -19,6 +19,15 @@ import {
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import { Separator } from "@/components/ui/separator";
import { Switch } from "@/components/ui/switch";
import { api } from "@/utils/api";
import { zodResolver } from "@hookform/resolvers/zod";
@@ -36,6 +45,36 @@ const AddRedirectchema = z.object({
type AddRedirect = z.infer;
+// Default presets
+const redirectPresets = [
+ // {
+ // label: "Allow www & non-www.",
+ // redirect: {
+ // regex: "",
+ // permanent: false,
+ // replacement: "",
+ // },
+ // },
+ {
+ id: "to-www",
+ label: "Redirect to www",
+ redirect: {
+ regex: "^https?://(?:www.)?(.+)",
+ permanent: true,
+ replacement: "https://www.$${1}",
+ },
+ },
+ {
+ id: "to-non-www",
+ label: "Redirect to non-www",
+ redirect: {
+ regex: "^https?://www.(.+)",
+ permanent: true,
+ replacement: "https://$${1}",
+ },
+ },
+];
+
interface Props {
applicationId: string;
children?: React.ReactNode;
@@ -43,9 +82,10 @@ interface Props {
export const AddRedirect = ({
applicationId,
- children = ,
+ children = ,
}: Props) => {
const [isOpen, setIsOpen] = useState(false);
+ const [presetSelected, setPresetSelected] = useState("");
const utils = api.useUtils();
const { mutateAsync, isLoading, error, isError } =
@@ -81,19 +121,36 @@ export const AddRedirect = ({
await utils.application.readTraefikConfig.invalidate({
applicationId,
});
- setIsOpen(false);
+ onDialogToggle(false);
})
.catch(() => {
toast.error("Error to create the redirect");
});
};
+ const onDialogToggle = (open: boolean) => {
+ setIsOpen(open);
+ // commented for the moment because not reseting the form if accidentally closed the dialog can be considered as a feature instead of a bug
+ // setPresetSelected("");
+ // form.reset();
+ };
+
+ const onPresetSelect = (presetId: string) => {
+ const redirectPreset = redirectPresets.find(
+ (preset) => preset.id === presetId,
+ )?.redirect;
+ if (!redirectPreset) return;
+ const { regex, permanent, replacement } = redirectPreset;
+ form.reset({ regex, permanent, replacement }, { keepDefaultValues: true });
+ setPresetSelected(presetId);
+ };
+
return (
-
diff --git a/apps/dokploy/components/dashboard/compose/domains/add-domain.tsx b/apps/dokploy/components/dashboard/compose/domains/add-domain.tsx
index 056c003a..91f211d1 100644
--- a/apps/dokploy/components/dashboard/compose/domains/add-domain.tsx
+++ b/apps/dokploy/components/dashboard/compose/domains/add-domain.tsx
@@ -161,7 +161,7 @@ export const AddDomainCompose = ({
{children}
-
+
Domain
{dictionary.dialogDescription}
@@ -190,7 +190,7 @@ export const AddDomainCompose = ({
{errorServices?.message}
)}
-
+
+
+
(
+
+
+ HTTPS
+
+ Automatically provision SSL Certificate.
+
+
+
+
+
+
+
+ )}
+ />
+
{https && (
)}
-
- (
-
-
- HTTPS
-
- Automatically provision SSL Certificate.
-
-
-
-
-
-
-
- )}
- />
From 65c1001751642c73ddc560805006b8894749004b Mon Sep 17 00:00:00 2001
From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com>
Date: Fri, 27 Sep 2024 11:22:52 -0600
Subject: [PATCH 4/8] fix(swagger): add mising validation
---
apps/dokploy/server/auth/token.ts | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/apps/dokploy/server/auth/token.ts b/apps/dokploy/server/auth/token.ts
index 54162fdc..64009fef 100644
--- a/apps/dokploy/server/auth/token.ts
+++ b/apps/dokploy/server/auth/token.ts
@@ -2,6 +2,8 @@ import type { IncomingMessage } from "node:http";
import { TimeSpan } from "lucia";
import { Lucia } from "lucia/dist/core.js";
import { type ReturnValidateToken, adapter } from "./auth";
+import { findAdminByAuthId } from "../api/services/admin";
+import { findUserByAuthId } from "../api/services/user";
export const luciaToken = new Lucia(adapter, {
sessionCookie: {
@@ -31,6 +33,16 @@ export const validateBearerToken = async (
};
}
const result = await luciaToken.validateSession(sessionId);
+
+ if (result.user) {
+ if (result.user?.rol === "admin") {
+ const admin = await findAdminByAuthId(result.user.id);
+ result.user.adminId = admin.adminId;
+ } else if (result.user?.rol === "user") {
+ const userResult = await findUserByAuthId(result.user.id);
+ result.user.adminId = userResult.adminId;
+ }
+ }
return {
session: result.session,
...((result.user && {
From bbfe095045cba813654bb583c11f982f887c9954 Mon Sep 17 00:00:00 2001
From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com>
Date: Fri, 27 Sep 2024 11:23:44 -0600
Subject: [PATCH 5/8] chore(version): bump version
---
apps/dokploy/package.json | 2 +-
apps/dokploy/server/auth/token.ts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/dokploy/package.json b/apps/dokploy/package.json
index 02321899..f5b57635 100644
--- a/apps/dokploy/package.json
+++ b/apps/dokploy/package.json
@@ -1,6 +1,6 @@
{
"name": "dokploy",
- "version": "v0.9.0",
+ "version": "v0.9.1",
"private": true,
"license": "Apache-2.0",
"type": "module",
diff --git a/apps/dokploy/server/auth/token.ts b/apps/dokploy/server/auth/token.ts
index 64009fef..5581777a 100644
--- a/apps/dokploy/server/auth/token.ts
+++ b/apps/dokploy/server/auth/token.ts
@@ -1,9 +1,9 @@
import type { IncomingMessage } from "node:http";
import { TimeSpan } from "lucia";
import { Lucia } from "lucia/dist/core.js";
-import { type ReturnValidateToken, adapter } from "./auth";
import { findAdminByAuthId } from "../api/services/admin";
import { findUserByAuthId } from "../api/services/user";
+import { type ReturnValidateToken, adapter } from "./auth";
export const luciaToken = new Lucia(adapter, {
sessionCookie: {
From 3dc3672406f68b457e9e2b5b64f4a20699935bb8 Mon Sep 17 00:00:00 2001
From: Ben
Date: Fri, 27 Sep 2024 19:30:41 +0200
Subject: [PATCH 6/8] docs: add explanation how to use multiline env variables
---
apps/docs/content/docs/core/application/overview.mdx | 2 ++
apps/docs/content/docs/core/databases/overview.mdx | 2 ++
2 files changed, 4 insertions(+)
diff --git a/apps/docs/content/docs/core/application/overview.mdx b/apps/docs/content/docs/core/application/overview.mdx
index 788daff8..9f881f6b 100644
--- a/apps/docs/content/docs/core/application/overview.mdx
+++ b/apps/docs/content/docs/core/application/overview.mdx
@@ -15,6 +15,8 @@ Configure the source of your code, the way your application is built, and also m
If you need to assign environment variables to your application, you can do so here.
+In case you need to use a multiline variable, you can wrap it in double quotes just like this `'"here_is_my_private_key"'`.
+
## Monitoring
Four graphs will be displayed for the use of memory, CPU, disk, and network. Note that the information is only updated if you are viewing the current page, otherwise it will not be updated.
diff --git a/apps/docs/content/docs/core/databases/overview.mdx b/apps/docs/content/docs/core/databases/overview.mdx
index f9702fb0..0fd2f5b0 100644
--- a/apps/docs/content/docs/core/databases/overview.mdx
+++ b/apps/docs/content/docs/core/databases/overview.mdx
@@ -26,6 +26,8 @@ Actions like deploying, updating, and deleting your database, and stopping it.
If you need to assign environment variables to your application, you can do so here.
+In case you need to use a multiline variable, you can wrap it in double quotes just like this `'"here_is_my_private_key"'`.
+
## Monitoring
Four graphs will be displayed for the use of memory, CPU, disk, and network. Note that the information is only updated if you are viewing the current page, otherwise it will not be updated.
From b48b9765cd4aabf281734f032560eea4c05bfa3b Mon Sep 17 00:00:00 2001
From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com>
Date: Sat, 28 Sep 2024 02:23:30 -0600
Subject: [PATCH 7/8] fix(nixpacks): adjust build path on nixpacks static
---
.../dokploy/server/utils/builders/nixpacks.ts | 24 +++++++++++++++----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/apps/dokploy/server/utils/builders/nixpacks.ts b/apps/dokploy/server/utils/builders/nixpacks.ts
index 0f408743..4ae4b2cb 100644
--- a/apps/dokploy/server/utils/builders/nixpacks.ts
+++ b/apps/dokploy/server/utils/builders/nixpacks.ts
@@ -1,4 +1,4 @@
-import type { WriteStream } from "node:fs";
+import { mkdirSync, type WriteStream, existsSync } from "node:fs";
import path from "node:path";
import { buildStatic, getStaticCommand } from "@/server/utils/builders/static";
import { nanoid } from "nanoid";
@@ -42,7 +42,6 @@ export const buildNixpacks = async (
and copy the artifacts on the host filesystem.
Then, remove the container and create a static build.
*/
-
if (publishDirectory) {
await spawnAsync(
"docker",
@@ -50,12 +49,22 @@ export const buildNixpacks = async (
writeToStream,
);
+ const localPath = path.join(buildAppDirectory, publishDirectory);
+
+ if (!existsSync(path.dirname(localPath))) {
+ mkdirSync(path.dirname(localPath), { recursive: true });
+ }
+
+ // https://docs.docker.com/reference/cli/docker/container/cp/
+ const isDirectory =
+ publishDirectory.endsWith("/") || !path.extname(publishDirectory);
+
await spawnAsync(
"docker",
[
"cp",
- `${buildContainerId}:/app/${publishDirectory}`,
- path.join(buildAppDirectory, publishDirectory),
+ `${buildContainerId}:/app/${publishDirectory}${isDirectory ? "/." : ""}`,
+ localPath,
],
writeToStream,
);
@@ -108,9 +117,14 @@ echo "✅ Nixpacks build completed." >> ${logPath};
Then, remove the container and create a static build.
*/
if (publishDirectory) {
+ const localPath = path.join(buildAppDirectory, publishDirectory);
+ const isDirectory =
+ publishDirectory.endsWith("/") || !path.extname(publishDirectory);
+
bashCommand += `
docker create --name ${buildContainerId} ${appName}
-docker cp ${buildContainerId}:/app/${publishDirectory} ${path.join(buildAppDirectory, publishDirectory)} >> ${logPath} 2>> ${logPath} || {
+mkdir -p ${localPath}
+docker cp ${buildContainerId}:/app/${publishDirectory}${isDirectory ? "/." : ""} ${path.join(buildAppDirectory, publishDirectory)} >> ${logPath} 2>> ${logPath} || {
docker rm ${buildContainerId}
echo "❌ Copying ${publishDirectory} to ${path.join(buildAppDirectory, publishDirectory)} failed" >> ${logPath};
exit 1;
From bf65bc9462785e5125755529e1839fe48e0c01ef Mon Sep 17 00:00:00 2001
From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com>
Date: Sat, 28 Sep 2024 02:25:06 -0600
Subject: [PATCH 8/8] chore(lint): format
---
apps/dokploy/server/utils/builders/nixpacks.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/dokploy/server/utils/builders/nixpacks.ts b/apps/dokploy/server/utils/builders/nixpacks.ts
index 4ae4b2cb..2d81a7c0 100644
--- a/apps/dokploy/server/utils/builders/nixpacks.ts
+++ b/apps/dokploy/server/utils/builders/nixpacks.ts
@@ -1,4 +1,4 @@
-import { mkdirSync, type WriteStream, existsSync } from "node:fs";
+import { type WriteStream, existsSync, mkdirSync } from "node:fs";
import path from "node:path";
import { buildStatic, getStaticCommand } from "@/server/utils/builders/static";
import { nanoid } from "nanoid";