diff --git a/packages/server/src/services/application.ts b/packages/server/src/services/application.ts index 3bab17488..c9c0bb765 100644 --- a/packages/server/src/services/application.ts +++ b/packages/server/src/services/application.ts @@ -287,6 +287,7 @@ export const rebuildApplication = async ({ descriptionLog: string; }) => { const application = await findApplicationById(applicationId); + const serverId = application.buildServerId || application.serverId; const buildLink = `${await getDokployUrl()}/dashboard/project/${application.environment.projectId}/environment/${application.environmentId}/services/application/${application.applicationId}?tab=deployments`; const deployment = await createDeployment({ @@ -300,8 +301,8 @@ export const rebuildApplication = async ({ // Check case for docker only command += getBuildCommand(application); const commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`; - if (application.serverId) { - await execAsyncRemote(application.serverId, commandWithLog); + if (serverId) { + await execAsyncRemote(serverId, commandWithLog); } else { await execAsync(commandWithLog); } @@ -340,8 +341,8 @@ export const rebuildApplication = async ({ } command += `echo "\nError occurred ❌, check the logs for details." >> ${deployment.logPath};`; - if (application.serverId) { - await execAsyncRemote(application.serverId, command); + if (serverId) { + await execAsyncRemote(serverId, command); } else { await execAsync(command); }