From 24bff96898d3f7adb25609de7408aed84affdfce Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 22 Jun 2025 09:56:36 -0600 Subject: [PATCH 1/4] feat(rollbacks): enhance fullContext type and refactor createRollback logic - Updated fullContext type in rollbacks schema to include Application and Project types. - Refactored createRollback function to separate fullContext from input and handle it more efficiently. - Integrated environment variable preparation into the rollback process. --- packages/server/src/db/schema/rollbacks.ts | 4 +++- packages/server/src/services/rollbacks.ts | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/server/src/db/schema/rollbacks.ts b/packages/server/src/db/schema/rollbacks.ts index c07842db..7a860687 100644 --- a/packages/server/src/db/schema/rollbacks.ts +++ b/packages/server/src/db/schema/rollbacks.ts @@ -4,6 +4,8 @@ import { createInsertSchema } from "drizzle-zod"; import { nanoid } from "nanoid"; import { z } from "zod"; import { deployments } from "./deployment"; +import type { Application } from "@dokploy/server/services/application"; +import type { Project } from "@dokploy/server/services/project"; export const rollbacks = pgTable("rollback", { rollbackId: text("rollbackId") @@ -20,7 +22,7 @@ export const rollbacks = pgTable("rollback", { createdAt: text("createdAt") .notNull() .$defaultFn(() => new Date().toISOString()), - fullContext: jsonb("fullContext"), + fullContext: jsonb("fullContext").$type(), }); export type Rollback = typeof rollbacks.$inferSelect; diff --git a/packages/server/src/services/rollbacks.ts b/packages/server/src/services/rollbacks.ts index 58df6591..1c1b5a29 100644 --- a/packages/server/src/services/rollbacks.ts +++ b/packages/server/src/services/rollbacks.ts @@ -12,14 +12,16 @@ import type { ApplicationNested } from "../utils/builders"; import { execAsync, execAsyncRemote } from "../utils/process/execAsync"; import type { CreateServiceOptions } from "dockerode"; import { findDeploymentById } from "./deployment"; +import { prepareEnvironmentVariables } from "../utils/docker/utils"; export const createRollback = async ( input: z.infer, ) => { await db.transaction(async (tx) => { + const { fullContext, ...other } = input; const rollback = await tx .insert(rollbacks) - .values(input) + .values(other) .returning() .then((res) => res[0]); @@ -47,7 +49,7 @@ export const createRollback = async ( .update(rollbacks) .set({ image: tagImage, - fullContext: JSON.stringify(rest), + fullContext: rest, }) .where(eq(rollbacks.rollbackId, rollback.rollbackId)); @@ -150,10 +152,16 @@ export const rollback = async (rollbackId: string) => { const application = await findApplicationById(deployment.applicationId); + const envVariables = prepareEnvironmentVariables( + result?.fullContext?.env || "", + result.fullContext?.project?.env || "", + ); + await rollbackApplication( application.appName, result.image || "", application.serverId, + envVariables, ); }; @@ -161,6 +169,7 @@ const rollbackApplication = async ( appName: string, image: string, serverId?: string | null, + env: string[] = [], ) => { const docker = await getRemoteDocker(serverId); @@ -169,6 +178,7 @@ const rollbackApplication = async ( TaskTemplate: { ContainerSpec: { Image: image, + Env: env, }, }, }; From 4babdd45ea163c08fe9eced17e812d792ee5ce7e Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 22 Jun 2025 09:58:35 -0600 Subject: [PATCH 2/4] chore: update version in package.json to v0.23.3 --- apps/dokploy/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dokploy/package.json b/apps/dokploy/package.json index b53e7ecf..ef14fd3b 100644 --- a/apps/dokploy/package.json +++ b/apps/dokploy/package.json @@ -1,6 +1,6 @@ { "name": "dokploy", - "version": "v0.23.2", + "version": "v0.23.3", "private": true, "license": "Apache-2.0", "type": "module", From 6290c217f127b8053710f0acc8f0d3e6edc03b1b Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 22 Jun 2025 10:00:14 -0600 Subject: [PATCH 3/4] feat(rollbacks): add alert for storage usage in rollback settings - Introduced an AlertBlock component to inform users about increased storage usage when rollbacks are enabled. - Added cautionary note regarding the potential deletion of rollback images during manual cache cleaning. --- .../application/rollbacks/show-rollback-settings.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/dokploy/components/dashboard/application/rollbacks/show-rollback-settings.tsx b/apps/dokploy/components/dashboard/application/rollbacks/show-rollback-settings.tsx index 4b2edca0..77575ea0 100644 --- a/apps/dokploy/components/dashboard/application/rollbacks/show-rollback-settings.tsx +++ b/apps/dokploy/components/dashboard/application/rollbacks/show-rollback-settings.tsx @@ -1,3 +1,4 @@ +import { AlertBlock } from "@/components/shared/alert-block"; import { Button } from "@/components/ui/button"; import { Dialog, @@ -79,6 +80,11 @@ export const ShowRollbackSettings = ({ applicationId, children }: Props) => { Configure how rollbacks work for this application + + Having rollbacks enabled increases storage usage. Be careful with + this option. Note that manually cleaning the cache may delete + rollback images, making them unavailable for future rollbacks. +
From 412bb9e8747a8777f76a6b15e31f590158b2b6a9 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sun, 22 Jun 2025 16:00:36 +0000 Subject: [PATCH 4/4] [autofix.ci] apply automated fixes --- apps/dokploy/reset-2fa.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/dokploy/reset-2fa.ts b/apps/dokploy/reset-2fa.ts index 573f31d7..089b7118 100644 --- a/apps/dokploy/reset-2fa.ts +++ b/apps/dokploy/reset-2fa.ts @@ -4,24 +4,24 @@ import { users_temp } from "@dokploy/server/db/schema"; import { eq } from "drizzle-orm"; (async () => { - try { - const result = await findAdmin(); + try { + const result = await findAdmin(); - const update = await db - .update(users_temp) - .set({ - twoFactorEnabled: false, - }) - .where(eq(users_temp.id, result.userId)); + const update = await db + .update(users_temp) + .set({ + twoFactorEnabled: false, + }) + .where(eq(users_temp.id, result.userId)); - if (update) { - console.log("2FA reset successful"); - } else { - console.log("Password reset failed"); - } + if (update) { + console.log("2FA reset successful"); + } else { + console.log("Password reset failed"); + } - process.exit(0); - } catch (error) { - console.log("Error resetting 2FA", error); - } + process.exit(0); + } catch (error) { + console.log("Error resetting 2FA", error); + } })();