MCPcopy
hub / github.com/Dokploy/dokploy / rebuildApplication

Function rebuildApplication

packages/server/src/services/application.ts:282–346  ·  view source on GitHub ↗
({
	applicationId,
	titleLog = "Rebuild deployment",
	descriptionLog = "",
}: {
	applicationId: string;
	titleLog: string;
	descriptionLog: string;
})

Source from the content-addressed store, hash-verified

280};
281
282export const rebuildApplication = async ({
283 applicationId,
284 titleLog = "Rebuild deployment",
285 descriptionLog = "",
286}: {
287 applicationId: string;
288 titleLog: string;
289 descriptionLog: string;
290}) => {
291 const application = await findApplicationById(applicationId);
292 const serverId = application.buildServerId || application.serverId;
293 const buildLink = `${await getDokployUrl()}/dashboard/project/${application.environment.projectId}/environment/${application.environmentId}/services/application/${application.applicationId}?tab=deployments`;
294
295 const deployment = await createDeployment({
296 applicationId: applicationId,
297 title: titleLog,
298 description: descriptionLog,
299 });
300
301 try {
302 let command = "set -e;";
303 // Check case for docker only
304 command += await getBuildCommand(application);
305 const commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`;
306 if (serverId) {
307 await execAsyncRemote(serverId, commandWithLog);
308 } else {
309 await execAsync(commandWithLog);
310 }
311 await mechanizeDockerContainer(application);
312 await updateDeploymentStatus(deployment.deploymentId, "done");
313 await updateApplicationStatus(applicationId, "done");
314
315 await sendBuildSuccessNotifications({
316 projectName: application.environment.project.name,
317 applicationName: application.name,
318 applicationType: "application",
319 buildLink,
320 organizationId: application.environment.project.organizationId,
321 domains: application.domains,
322 environmentName: application.environment.name,
323 });
324 } catch (error) {
325 let command = "";
326
327 // Only log details for non-ExecError errors
328 if (!(error instanceof ExecError)) {
329 const message = error instanceof Error ? error.message : String(error);
330 const encodedMessage = encodeBase64(message);
331 command += `echo "${encodedMessage}" | base64 -d >> "${deployment.logPath}";`;
332 }
333
334 command += `echo "\nError occurred ❌, check the logs for details." >> ${deployment.logPath};`;
335 if (serverId) {
336 await execAsyncRemote(serverId, command);
337 } else {
338 await execAsync(command);
339 }

Callers 2

createDeploymentWorkerFunction · 0.90
deployFunction · 0.90

Calls 11

getDokployUrlFunction · 0.90
createDeploymentFunction · 0.90
getBuildCommandFunction · 0.90
execAsyncRemoteFunction · 0.90
execAsyncFunction · 0.90
mechanizeDockerContainerFunction · 0.90
updateDeploymentStatusFunction · 0.90
encodeBase64Function · 0.90
findApplicationByIdFunction · 0.85
updateApplicationStatusFunction · 0.85

Tested by

no test coverage detected