Merge branch 'canary' into 379-preview-deployment

This commit is contained in:
Mauricio Siu
2024-12-07 21:28:34 -06:00
parent 841b264257
commit 5058d9b47d
57 changed files with 933 additions and 754 deletions

View File

@@ -192,6 +192,7 @@ export const applications = pgTable("application", {
.notNull()
.default("idle"),
buildType: buildType("buildType").notNull().default("nixpacks"),
herokuVersion: text("herokuVersion").default("24"),
publishDirectory: text("publishDirectory"),
createdAt: text("createdAt")
.notNull()
@@ -384,6 +385,7 @@ const createSchema = createInsertSchema(applications, {
"nixpacks",
"static",
]),
herokuVersion: z.string().optional(),
publishDirectory: z.string().optional(),
owner: z.string(),
healthCheckSwarm: HealthCheckSwarmSchema.nullable(),
@@ -432,6 +434,7 @@ export const apiSaveBuildType = createSchema
dockerfile: true,
dockerContextPath: true,
dockerBuildStage: true,
herokuVersion: true,
})
.required()
.merge(createSchema.pick({ publishDirectory: true }));

View File

@@ -468,6 +468,36 @@ export const removeCompose = async (compose: Compose) => {
return true;
};
export const startCompose = async (composeId: string) => {
const compose = await findComposeById(composeId);
try {
const { COMPOSE_PATH } = paths(!!compose.serverId);
if (compose.composeType === "docker-compose") {
if (compose.serverId) {
await execAsyncRemote(
compose.serverId,
`cd ${join(COMPOSE_PATH, compose.appName, "code")} && docker compose -p ${compose.appName} up -d`,
);
} else {
await execAsync(`docker compose -p ${compose.appName} up -d`, {
cwd: join(COMPOSE_PATH, compose.appName, "code"),
});
}
}
await updateCompose(composeId, {
composeStatus: "done",
});
} catch (error) {
await updateCompose(composeId, {
composeStatus: "idle",
});
throw error;
}
return true;
};
export const stopCompose = async (composeId: string) => {
const compose = await findComposeById(composeId);
try {

View File

@@ -22,7 +22,7 @@ export const buildHeroku = async (
"--path",
buildAppDirectory,
"--builder",
"heroku/builder:24",
`heroku/builder:${application.herokuVersion || "24"}`,
];
for (const env of envVariables) {
@@ -58,7 +58,7 @@ export const getHerokuCommand = (
"--path",
buildAppDirectory,
"--builder",
"heroku/builder:24",
`heroku/builder:${application.herokuVersion || "24"}`,
];
for (const env of envVariables) {

View File

@@ -59,31 +59,46 @@ export const sendBuildErrorNotifications = async ({
if (discord) {
await sendDiscordNotification(discord, {
title: "⚠️ Build Failed",
color: 0xff0000,
title: "> `⚠️` - Build Failed",
color: 0xed4245,
fields: [
{
name: "Project",
name: "`🛠️`・Project",
value: projectName,
inline: true,
},
{
name: "Application",
name: "`⚙️`・Application",
value: applicationName,
inline: true,
},
{
name: "Type",
name: "`❔`・Type",
value: applicationType,
inline: true,
},
{
name: "Error",
value: errorMessage,
name: "`📅`・Date",
value: date.toLocaleDateString(),
inline: true,
},
{
name: "Build Link",
value: buildLink,
name: "`⌚`・Time",
value: date.toLocaleTimeString(),
inline: true,
},
{
name: "`❓`・Type",
value: "Failed",
inline: true,
},
{
name: "`⚠️`・Error Message",
value: `\`\`\`${errorMessage}\`\`\``,
},
{
name: "`🧷`・Build Link",
value: `[Click here to access build link](${buildLink})`,
},
],
timestamp: date.toISOString(),

View File

@@ -57,27 +57,42 @@ export const sendBuildSuccessNotifications = async ({
if (discord) {
await sendDiscordNotification(discord, {
title: " Build Success",
color: 0x00ff00,
title: "> `✅` - Build Success",
color: 0x57f287,
fields: [
{
name: "Project",
name: "`🛠️`・Project",
value: projectName,
inline: true,
},
{
name: "Application",
name: "`⚙️`・Application",
value: applicationName,
inline: true,
},
{
name: "Type",
name: "`❔`・Application Type",
value: applicationType,
inline: true,
},
{
name: "Build Link",
value: buildLink,
name: "`📅`・Date",
value: date.toLocaleDateString(),
inline: true,
},
{
name: "`⌚`・Time",
value: date.toLocaleTimeString(),
inline: true,
},
{
name: "`❓`・Type",
value: "Successful",
inline: true,
},
{
name: "`🧷`・Build Link",
value: `[Click here to access build link](${buildLink})`,
},
],
timestamp: date.toISOString(),

View File

@@ -64,39 +64,47 @@ export const sendDatabaseBackupNotifications = async ({
await sendDiscordNotification(discord, {
title:
type === "success"
? " Database Backup Successful"
: " Database Backup Failed",
color: type === "success" ? 0x00ff00 : 0xff0000,
? "> `✅` - Database Backup Successful"
: "> `❌` - Database Backup Failed",
color: type === "success" ? 0x57f287 : 0xed4245,
fields: [
{
name: "Project",
name: "`🛠️`・Project",
value: projectName,
inline: true,
},
{
name: "Application",
name: "`⚙️`・Application",
value: applicationName,
inline: true,
},
{
name: "Type",
name: "`❔`・Database",
value: databaseType,
inline: true,
},
{
name: "Time",
value: date.toLocaleString(),
name: "`📅`・Date",
value: date.toLocaleDateString(),
inline: true,
},
{
name: "Type",
value: type,
name: "`⌚`・Time",
value: date.toLocaleTimeString(),
inline: true,
},
{
name: "`❓`・Type",
value: type
.replace("error", "Failed")
.replace("success", "Successful"),
inline: true,
},
...(type === "error" && errorMessage
? [
{
name: "Error Message",
value: errorMessage,
name: "`⚠️`・Error Message",
value: `\`\`\`${errorMessage}\`\`\``,
},
]
: []),

View File

@@ -45,12 +45,27 @@ export const sendDockerCleanupNotifications = async (
if (discord) {
await sendDiscordNotification(discord, {
title: " Docker Cleanup",
color: 0x00ff00,
title: "> `✅` - Docker Cleanup",
color: 0x57f287,
fields: [
{
name: "Message",
value: message,
name: "`📅`・Date",
value: date.toLocaleDateString(),
inline: true,
},
{
name: "`⌚`・Time",
value: date.toLocaleTimeString(),
inline: true,
},
{
name: "`❓`・Type",
value: "Successful",
inline: true,
},
{
name: "`📜`・Message",
value: `\`\`\`${message}\`\`\``,
},
],
timestamp: date.toISOString(),

View File

@@ -34,12 +34,22 @@ export const sendDokployRestartNotifications = async () => {
if (discord) {
await sendDiscordNotification(discord, {
title: " Dokploy Server Restarted",
color: 0x00ff00,
title: "> `✅` - Dokploy Server Restarted",
color: 0x57f287,
fields: [
{
name: "Time",
value: date.toLocaleString(),
name: "`📅`・Date",
value: date.toLocaleDateString(),
inline: true,
},
{
name: "`⌚`・Time",
value: date.toLocaleTimeString(),
inline: true,
},
{
name: "`❓`・Type",
value: "Successful",
inline: true,
},
],