mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat: add cleanup cache on deployments
This commit is contained in:
@@ -3,7 +3,6 @@ import { paths } from "@dokploy/server/constants";
|
||||
import { db } from "@dokploy/server/db";
|
||||
import { type apiCreateCompose, compose } from "@dokploy/server/db/schema";
|
||||
import { buildAppName, cleanAppName } from "@dokploy/server/db/schema";
|
||||
import { generatePassword } from "@dokploy/server/templates/utils";
|
||||
import {
|
||||
buildCompose,
|
||||
getBuildComposeCommand,
|
||||
@@ -45,9 +44,10 @@ import {
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { encodeBase64 } from "../utils/docker/utils";
|
||||
import { getDokployUrl } from "./admin";
|
||||
import { findAdminById, getDokployUrl } from "./admin";
|
||||
import { createDeploymentCompose, updateDeploymentStatus } from "./deployment";
|
||||
import { validUniqueServerAppName } from "./project";
|
||||
import { cleanupFullDocker } from "./settings";
|
||||
|
||||
export type Compose = typeof compose.$inferSelect;
|
||||
|
||||
@@ -260,6 +260,11 @@ export const deployCompose = async ({
|
||||
adminId: compose.project.adminId,
|
||||
});
|
||||
throw error;
|
||||
} finally {
|
||||
const admin = await findAdminById(compose.project.adminId);
|
||||
if (admin.cleanupCacheOnCompose) {
|
||||
await cleanupFullDocker(compose?.serverId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -296,6 +301,11 @@ export const rebuildCompose = async ({
|
||||
composeStatus: "error",
|
||||
});
|
||||
throw error;
|
||||
} finally {
|
||||
const admin = await findAdminById(compose.project.adminId);
|
||||
if (admin.cleanupCacheOnCompose) {
|
||||
await cleanupFullDocker(compose?.serverId);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -394,6 +404,11 @@ export const deployRemoteCompose = async ({
|
||||
adminId: compose.project.adminId,
|
||||
});
|
||||
throw error;
|
||||
} finally {
|
||||
const admin = await findAdminById(compose.project.adminId);
|
||||
if (admin.cleanupCacheOnCompose) {
|
||||
await cleanupFullDocker(compose?.serverId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -438,6 +453,11 @@ export const rebuildRemoteCompose = async ({
|
||||
composeStatus: "error",
|
||||
});
|
||||
throw error;
|
||||
} finally {
|
||||
const admin = await findAdminById(compose.project.adminId);
|
||||
if (admin.cleanupCacheOnCompose) {
|
||||
await cleanupFullDocker(compose?.serverId);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user