Merge branch 'Dokploy:canary' into feat/internal-path-routing

This commit is contained in:
Jhonatan Caldeira 2025-06-22 17:35:53 -03:00 committed by GitHub
commit dde12e132a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 39 additions and 21 deletions

View File

@ -1,3 +1,4 @@
import { AlertBlock } from "@/components/shared/alert-block";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { import {
Dialog, Dialog,
@ -79,6 +80,11 @@ export const ShowRollbackSettings = ({ applicationId, children }: Props) => {
<DialogDescription> <DialogDescription>
Configure how rollbacks work for this application Configure how rollbacks work for this application
</DialogDescription> </DialogDescription>
<AlertBlock>
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.
</AlertBlock>
</DialogHeader> </DialogHeader>
<Form {...form}> <Form {...form}>

View File

@ -1,6 +1,6 @@
{ {
"name": "dokploy", "name": "dokploy",
"version": "v0.23.2", "version": "v0.23.3",
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",

View File

@ -4,24 +4,24 @@ import { users_temp } from "@dokploy/server/db/schema";
import { eq } from "drizzle-orm"; import { eq } from "drizzle-orm";
(async () => { (async () => {
try { try {
const result = await findAdmin(); const result = await findAdmin();
const update = await db const update = await db
.update(users_temp) .update(users_temp)
.set({ .set({
twoFactorEnabled: false, twoFactorEnabled: false,
}) })
.where(eq(users_temp.id, result.userId)); .where(eq(users_temp.id, result.userId));
if (update) { if (update) {
console.log("2FA reset successful"); console.log("2FA reset successful");
} else { } else {
console.log("Password reset failed"); console.log("Password reset failed");
} }
process.exit(0); process.exit(0);
} catch (error) { } catch (error) {
console.log("Error resetting 2FA", error); console.log("Error resetting 2FA", error);
} }
})(); })();

View File

@ -4,6 +4,8 @@ import { createInsertSchema } from "drizzle-zod";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { z } from "zod"; import { z } from "zod";
import { deployments } from "./deployment"; 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", { export const rollbacks = pgTable("rollback", {
rollbackId: text("rollbackId") rollbackId: text("rollbackId")
@ -20,7 +22,7 @@ export const rollbacks = pgTable("rollback", {
createdAt: text("createdAt") createdAt: text("createdAt")
.notNull() .notNull()
.$defaultFn(() => new Date().toISOString()), .$defaultFn(() => new Date().toISOString()),
fullContext: jsonb("fullContext"), fullContext: jsonb("fullContext").$type<Application & { project: Project }>(),
}); });
export type Rollback = typeof rollbacks.$inferSelect; export type Rollback = typeof rollbacks.$inferSelect;

View File

@ -12,14 +12,16 @@ import type { ApplicationNested } from "../utils/builders";
import { execAsync, execAsyncRemote } from "../utils/process/execAsync"; import { execAsync, execAsyncRemote } from "../utils/process/execAsync";
import type { CreateServiceOptions } from "dockerode"; import type { CreateServiceOptions } from "dockerode";
import { findDeploymentById } from "./deployment"; import { findDeploymentById } from "./deployment";
import { prepareEnvironmentVariables } from "../utils/docker/utils";
export const createRollback = async ( export const createRollback = async (
input: z.infer<typeof createRollbackSchema>, input: z.infer<typeof createRollbackSchema>,
) => { ) => {
await db.transaction(async (tx) => { await db.transaction(async (tx) => {
const { fullContext, ...other } = input;
const rollback = await tx const rollback = await tx
.insert(rollbacks) .insert(rollbacks)
.values(input) .values(other)
.returning() .returning()
.then((res) => res[0]); .then((res) => res[0]);
@ -47,7 +49,7 @@ export const createRollback = async (
.update(rollbacks) .update(rollbacks)
.set({ .set({
image: tagImage, image: tagImage,
fullContext: JSON.stringify(rest), fullContext: rest,
}) })
.where(eq(rollbacks.rollbackId, rollback.rollbackId)); .where(eq(rollbacks.rollbackId, rollback.rollbackId));
@ -150,10 +152,16 @@ export const rollback = async (rollbackId: string) => {
const application = await findApplicationById(deployment.applicationId); const application = await findApplicationById(deployment.applicationId);
const envVariables = prepareEnvironmentVariables(
result?.fullContext?.env || "",
result.fullContext?.project?.env || "",
);
await rollbackApplication( await rollbackApplication(
application.appName, application.appName,
result.image || "", result.image || "",
application.serverId, application.serverId,
envVariables,
); );
}; };
@ -161,6 +169,7 @@ const rollbackApplication = async (
appName: string, appName: string,
image: string, image: string,
serverId?: string | null, serverId?: string | null,
env: string[] = [],
) => { ) => {
const docker = await getRemoteDocker(serverId); const docker = await getRemoteDocker(serverId);
@ -169,6 +178,7 @@ const rollbackApplication = async (
TaskTemplate: { TaskTemplate: {
ContainerSpec: { ContainerSpec: {
Image: image, Image: image,
Env: env,
}, },
}, },
}; };