diff --git a/apps/dokploy/components/dashboard/application/deployments/show-deployments.tsx b/apps/dokploy/components/dashboard/application/deployments/show-deployments.tsx
index 294772228..3f674aa3c 100644
--- a/apps/dokploy/components/dashboard/application/deployments/show-deployments.tsx
+++ b/apps/dokploy/components/dashboard/application/deployments/show-deployments.tsx
@@ -259,16 +259,9 @@ export const ShowDeployments = ({
const isExpanded = expandedDescriptions.has(
deployment.deploymentId,
);
- const lastSuccessfulDeployment = deployments?.find(
- (d) => d.status === "done",
- );
- const isLastSuccessfulDeployment =
- lastSuccessfulDeployment?.deploymentId ===
- deployment.deploymentId;
const canDelete =
- deployments &&
- deployments.length > 1 &&
- !isLastSuccessfulDeployment;
+ deployment.status === "done" || deployment.status === "error";
+
return (
{
const deployment = await db
.delete(deployments)
.where(eq(deployments.deploymentId, deploymentId))
- .returning();
- return deployment[0];
+ .returning()
+ .then((result) => result[0]);
+
+ if (!deployment) {
+ throw new TRPCError({
+ code: "BAD_REQUEST",
+ message: "Deployment not found",
+ });
+ }
+ const command = `
+ rm -f ${deployment.logPath};
+ `;
+ if (deployment.serverId) {
+ await execAsyncRemote(deployment.serverId, command);
+ } else {
+ await execAsync(command);
+ }
+
+ return deployment;
} catch (error) {
const message =
error instanceof Error ? error.message : "Error creating the deployment";
@@ -848,7 +868,7 @@ export const clearOldDeploymentsByApplicationId = async (
// If there's an active deployment, keep it and remove all others
// If there's no active deployment, keep the most recent one and remove the rest
- let deploymentsToKeep: string[] = [];
+ const deploymentsToKeep: string[] = [];
if (activeDeployment) {
deploymentsToKeep.push(activeDeployment.deploymentId);
@@ -901,7 +921,7 @@ export const clearOldDeploymentsByComposeId = async (composeId: string) => {
// If there's an active deployment, keep it and remove all others
// If there's no active deployment, keep the most recent one and remove the rest
- let deploymentsToKeep: string[] = [];
+ const deploymentsToKeep: string[] = [];
if (activeDeployment) {
deploymentsToKeep.push(activeDeployment.deploymentId);