refactor: update application deployment logic to utilize environment context for project name and organization ID, enhancing clarity and consistency across services

This commit is contained in:
Mauricio Siu
2025-09-01 22:51:35 -06:00
parent de3c845ab0
commit 3e7eff11cd
3 changed files with 13 additions and 22 deletions
+8 -8
View File
@@ -231,11 +231,11 @@ export const deployApplication = async ({
} }
await sendBuildSuccessNotifications({ await sendBuildSuccessNotifications({
projectName: application.project.name, projectName: application.environment.project.name,
applicationName: application.name, applicationName: application.name,
applicationType: "application", applicationType: "application",
buildLink, buildLink,
organizationId: application.project.organizationId, organizationId: application.environment.project.organizationId,
domains: application.domains, domains: application.domains,
}); });
} catch (error) { } catch (error) {
@@ -243,13 +243,13 @@ export const deployApplication = async ({
await updateApplicationStatus(applicationId, "error"); await updateApplicationStatus(applicationId, "error");
await sendBuildErrorNotifications({ await sendBuildErrorNotifications({
projectName: application.project.name, projectName: application.environment.project.name,
applicationName: application.name, applicationName: application.name,
applicationType: "application", applicationType: "application",
// @ts-ignore // @ts-ignore
errorMessage: error?.message || "Error building", errorMessage: error?.message || "Error building",
buildLink, buildLink,
organizationId: application.project.organizationId, organizationId: application.environment.project.organizationId,
}); });
throw error; throw error;
@@ -367,11 +367,11 @@ export const deployRemoteApplication = async ({
} }
await sendBuildSuccessNotifications({ await sendBuildSuccessNotifications({
projectName: application.project.name, projectName: application.environment.project.name,
applicationName: application.name, applicationName: application.name,
applicationType: "application", applicationType: "application",
buildLink, buildLink,
organizationId: application.project.organizationId, organizationId: application.environment.project.organizationId,
domains: application.domains, domains: application.domains,
}); });
} catch (error) { } catch (error) {
@@ -391,12 +391,12 @@ export const deployRemoteApplication = async ({
await updateApplicationStatus(applicationId, "error"); await updateApplicationStatus(applicationId, "error");
await sendBuildErrorNotifications({ await sendBuildErrorNotifications({
projectName: application.project.name, projectName: application.environment.project.name,
applicationName: application.name, applicationName: application.name,
applicationType: "application", applicationType: "application",
errorMessage: `Please check the logs for details: ${errorMessage}`, errorMessage: `Please check the logs for details: ${errorMessage}`,
buildLink, buildLink,
organizationId: application.project.organizationId, organizationId: application.environment.project.organizationId,
}); });
throw error; throw error;
+3 -12
View File
@@ -17,22 +17,13 @@ import { buildNixpacks, getNixpacksCommand } from "./nixpacks";
import { buildPaketo, getPaketoCommand } from "./paketo"; import { buildPaketo, getPaketoCommand } from "./paketo";
import { buildRailpack, getRailpackCommand } from "./railpack"; import { buildRailpack, getRailpackCommand } from "./railpack";
import { buildStatic, getStaticCommand } from "./static"; import { buildStatic, getStaticCommand } from "./static";
import { findApplicationById } from "@dokploy/server/services/application";
// NIXPACKS codeDirectory = where is the path of the code directory // NIXPACKS codeDirectory = where is the path of the code directory
// HEROKU codeDirectory = where is the path of the code directory // HEROKU codeDirectory = where is the path of the code directory
// PAKETO codeDirectory = where is the path of the code directory // PAKETO codeDirectory = where is the path of the code directory
// DOCKERFILE codeDirectory = where is the exact path of the (Dockerfile) // DOCKERFILE codeDirectory = where is the exact path of the (Dockerfile)
export type ApplicationNested = InferResultType< export type ApplicationNested = Awaited<ReturnType<typeof findApplicationById>>;
"applications",
{
mounts: true;
security: true;
redirects: true;
ports: true;
registry: true;
project: true;
}
>;
export const buildApplication = async ( export const buildApplication = async (
application: ApplicationNested, application: ApplicationNested,
@@ -148,7 +139,7 @@ export const mechanizeDockerContainer = async (
const filesMount = generateFileMounts(appName, application); const filesMount = generateFileMounts(appName, application);
const envVariables = prepareEnvironmentVariables( const envVariables = prepareEnvironmentVariables(
env, env,
application.project.env, application.environment.project.env,
); );
const image = getImageName(application); const image = getImageName(application);
@@ -26,7 +26,7 @@ export const buildRailpack = async (
const buildAppDirectory = getBuildAppDirectory(application); const buildAppDirectory = getBuildAppDirectory(application);
const envVariables = prepareEnvironmentVariables( const envVariables = prepareEnvironmentVariables(
env, env,
application.project.env, application.environment.project.env,
); );
try { try {
@@ -123,7 +123,7 @@ export const getRailpackCommand = (
const buildAppDirectory = getBuildAppDirectory(application); const buildAppDirectory = getBuildAppDirectory(application);
const envVariables = prepareEnvironmentVariables( const envVariables = prepareEnvironmentVariables(
env, env,
application.project.env, application.environment.project.env,
); );
// Prepare command // Prepare command