Skip to content

Commit

Permalink
Merge pull request #647 from Dokploy/canary
Browse files Browse the repository at this point in the history
v0.10.10
  • Loading branch information
Siumauricio authored Nov 4, 2024
2 parents 89c7e96 + 34b12a0 commit 5cd624c
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/dokploy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dokploy",
"version": "v0.10.9",
"version": "v0.10.10",
"private": true,
"license": "Apache-2.0",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions apps/dokploy/server/api/routers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const settingsRouter = createTRPCRouter({
await cleanUpUnusedImages(server.serverId);
await cleanUpDockerBuilder(server.serverId);
await cleanUpSystemPrune(server.serverId);
await sendDockerCleanupNotifications();
await sendDockerCleanupNotifications(server.adminId);
});
}
} else {
Expand Down Expand Up @@ -278,7 +278,7 @@ export const settingsRouter = createTRPCRouter({
await cleanUpUnusedImages();
await cleanUpDockerBuilder();
await cleanUpSystemPrune();
await sendDockerCleanupNotifications();
await sendDockerCleanupNotifications(admin.adminId);
});
} else {
const currentJob = scheduledJobs["docker-cleanup"];
Expand Down
4 changes: 4 additions & 0 deletions packages/server/src/services/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export const deployApplication = async ({
applicationName: application.name,
applicationType: "application",
buildLink,
adminId: application.project.adminId,
});
} catch (error) {
await updateDeploymentStatus(deployment.deploymentId, "error");
Expand All @@ -204,6 +205,7 @@ export const deployApplication = async ({
// @ts-ignore
errorMessage: error?.message || "Error to build",
buildLink,
adminId: application.project.adminId,
});

console.log(
Expand Down Expand Up @@ -314,6 +316,7 @@ export const deployRemoteApplication = async ({
applicationName: application.name,
applicationType: "application",
buildLink,
adminId: application.project.adminId,
});
} catch (error) {
// @ts-ignore
Expand All @@ -336,6 +339,7 @@ export const deployRemoteApplication = async ({
// @ts-ignore
errorMessage: error?.message || "Error to build",
buildLink,
adminId: application.project.adminId,
});

console.log(
Expand Down
4 changes: 4 additions & 0 deletions packages/server/src/services/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export const deployCompose = async ({
applicationName: compose.name,
applicationType: "compose",
buildLink,
adminId: compose.project.adminId,
});
} catch (error) {
await updateDeploymentStatus(deployment.deploymentId, "error");
Expand All @@ -248,6 +249,7 @@ export const deployCompose = async ({
// @ts-ignore
errorMessage: error?.message || "Error to build",
buildLink,
adminId: compose.project.adminId,
});
throw error;
}
Expand Down Expand Up @@ -353,6 +355,7 @@ export const deployRemoteCompose = async ({
applicationName: compose.name,
applicationType: "compose",
buildLink,
adminId: compose.project.adminId,
});
} catch (error) {
// @ts-ignore
Expand All @@ -376,6 +379,7 @@ export const deployRemoteCompose = async ({
// @ts-ignore
errorMessage: error?.message || "Error to build",
buildLink,
adminId: compose.project.adminId,
});
throw error;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/server/src/utils/backups/mariadb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const runMariadbBackup = async (
projectName: project.name,
databaseType: "mariadb",
type: "success",
adminId: project.adminId,
});
} catch (error) {
console.log(error);
Expand All @@ -59,6 +60,7 @@ export const runMariadbBackup = async (
type: "error",
// @ts-ignore
errorMessage: error?.message || "Error message not provided",
adminId: project.adminId,
});
throw error;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/server/src/utils/backups/mongo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const runMongoBackup = async (mongo: Mongo, backup: BackupSchedule) => {
projectName: project.name,
databaseType: "mongodb",
type: "success",
adminId: project.adminId,
});
} catch (error) {
console.log(error);
Expand All @@ -56,6 +57,7 @@ export const runMongoBackup = async (mongo: Mongo, backup: BackupSchedule) => {
type: "error",
// @ts-ignore
errorMessage: error?.message || "Error message not provided",
adminId: project.adminId,
});
throw error;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/server/src/utils/backups/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const runMySqlBackup = async (mysql: MySql, backup: BackupSchedule) => {
projectName: project.name,
databaseType: "mysql",
type: "success",
adminId: project.adminId,
});
} catch (error) {
console.log(error);
Expand All @@ -56,6 +57,7 @@ export const runMySqlBackup = async (mysql: MySql, backup: BackupSchedule) => {
type: "error",
// @ts-ignore
errorMessage: error?.message || "Error message not provided",
adminId: project.adminId,
});
throw error;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/server/src/utils/backups/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const runPostgresBackup = async (
projectName: project.name,
databaseType: "postgres",
type: "success",
adminId: project.adminId,
});
} catch (error) {
await sendDatabaseBackupNotifications({
Expand All @@ -58,6 +59,7 @@ export const runPostgresBackup = async (
type: "error",
// @ts-ignore
errorMessage: error?.message || "Error message not provided",
adminId: project.adminId,
});

throw error;
Expand Down
9 changes: 7 additions & 2 deletions packages/server/src/utils/notifications/build-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { db } from "@dokploy/server/db";
import { notifications } from "@dokploy/server/db/schema";
import BuildFailedEmail from "@dokploy/server/emails/emails/build-failed";
import { renderAsync } from "@react-email/components";
import { eq } from "drizzle-orm";
import { and, eq } from "drizzle-orm";
import {
sendDiscordNotification,
sendEmailNotification,
Expand All @@ -16,6 +16,7 @@ interface Props {
applicationType: string;
errorMessage: string;
buildLink: string;
adminId: string;
}

export const sendBuildErrorNotifications = async ({
Expand All @@ -24,10 +25,14 @@ export const sendBuildErrorNotifications = async ({
applicationType,
errorMessage,
buildLink,
adminId,
}: Props) => {
const date = new Date();
const notificationList = await db.query.notifications.findMany({
where: eq(notifications.appBuildError, true),
where: and(
eq(notifications.appBuildError, true),
eq(notifications.adminId, adminId),
),
with: {
email: true,
discord: true,
Expand Down
9 changes: 7 additions & 2 deletions packages/server/src/utils/notifications/build-success.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { db } from "@dokploy/server/db";
import { notifications } from "@dokploy/server/db/schema";
import BuildSuccessEmail from "@dokploy/server/emails/emails/build-success";
import { renderAsync } from "@react-email/components";
import { eq } from "drizzle-orm";
import { and, eq } from "drizzle-orm";
import {
sendDiscordNotification,
sendEmailNotification,
Expand All @@ -15,17 +15,22 @@ interface Props {
applicationName: string;
applicationType: string;
buildLink: string;
adminId: string;
}

export const sendBuildSuccessNotifications = async ({
projectName,
applicationName,
applicationType,
buildLink,
adminId,
}: Props) => {
const date = new Date();
const notificationList = await db.query.notifications.findMany({
where: eq(notifications.appDeploy, true),
where: and(
eq(notifications.appDeploy, true),
eq(notifications.adminId, adminId),
),
with: {
email: true,
discord: true,
Expand Down
9 changes: 7 additions & 2 deletions packages/server/src/utils/notifications/database-backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { db } from "@dokploy/server/db";
import { notifications } from "@dokploy/server/db/schema";
import DatabaseBackupEmail from "@dokploy/server/emails/emails/database-backup";
import { renderAsync } from "@react-email/components";
import { eq } from "drizzle-orm";
import { and, eq } from "drizzle-orm";
import {
sendDiscordNotification,
sendEmailNotification,
Expand All @@ -16,16 +16,21 @@ export const sendDatabaseBackupNotifications = async ({
databaseType,
type,
errorMessage,
adminId,
}: {
projectName: string;
applicationName: string;
databaseType: "postgres" | "mysql" | "mongodb" | "mariadb";
type: "error" | "success";
adminId: string;
errorMessage?: string;
}) => {
const date = new Date();
const notificationList = await db.query.notifications.findMany({
where: eq(notifications.databaseBackup, true),
where: and(
eq(notifications.databaseBackup, true),
eq(notifications.adminId, adminId),
),
with: {
email: true,
discord: true,
Expand Down
8 changes: 6 additions & 2 deletions packages/server/src/utils/notifications/docker-cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { db } from "@dokploy/server/db";
import { notifications } from "@dokploy/server/db/schema";
import DockerCleanupEmail from "@dokploy/server/emails/emails/docker-cleanup";
import { renderAsync } from "@react-email/components";
import { eq } from "drizzle-orm";
import { and, eq } from "drizzle-orm";
import {
sendDiscordNotification,
sendEmailNotification,
Expand All @@ -11,11 +11,15 @@ import {
} from "./utils";

export const sendDockerCleanupNotifications = async (
adminId: string,
message = "Docker cleanup for dokploy",
) => {
const date = new Date();
const notificationList = await db.query.notifications.findMany({
where: eq(notifications.dockerCleanup, true),
where: and(
eq(notifications.dockerCleanup, true),
eq(notifications.adminId, adminId),
),
with: {
email: true,
discord: true,
Expand Down

0 comments on commit 5cd624c

Please sign in to comment.