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

Function deployApplication

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

Source from the content-addressed store, hash-verified

162};
163
164export const deployApplication = async ({
165 applicationId,
166 titleLog = "Manual deployment",
167 descriptionLog = "",
168}: {
169 applicationId: string;
170 titleLog: string;
171 descriptionLog: string;
172}) => {
173 const application = await findApplicationById(applicationId);
174 const serverId = application.buildServerId || application.serverId;
175 const applicationEntity = {
176 ...application,
177 serverId: serverId,
178 };
179
180 const buildLink = `${await getDokployUrl()}/dashboard/project/${application.environment.projectId}/environment/${application.environmentId}/services/application/${application.applicationId}?tab=deployments`;
181 const deployment = await createDeployment({
182 applicationId: applicationId,
183 title: titleLog,
184 description: descriptionLog,
185 });
186
187 try {
188 let command = "set -e;";
189 if (application.sourceType === "github") {
190 command += await cloneGithubRepository(applicationEntity);
191 } else if (application.sourceType === "gitlab") {
192 command += await cloneGitlabRepository(applicationEntity);
193 } else if (application.sourceType === "gitea") {
194 command += await cloneGiteaRepository(applicationEntity);
195 } else if (application.sourceType === "bitbucket") {
196 command += await cloneBitbucketRepository(applicationEntity);
197 } else if (application.sourceType === "git") {
198 command += await cloneGitRepository(applicationEntity);
199 } else if (application.sourceType === "docker") {
200 command += await buildRemoteDocker(application);
201 }
202
203 if (application.sourceType !== "docker") {
204 command += await generateApplyPatchesCommand({
205 id: application.applicationId,
206 type: "application",
207 serverId,
208 });
209 }
210
211 command += await getBuildCommand(application);
212
213 const commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`;
214 if (serverId) {
215 await execAsyncRemote(serverId, commandWithLog);
216 } else {
217 await execAsync(commandWithLog);
218 }
219
220 await mechanizeDockerContainer(application);
221 await updateDeploymentStatus(deployment.deploymentId, "done");

Callers 4

createDeploymentWorkerFunction · 0.90
deployFunction · 0.90

Calls 15

getDokployUrlFunction · 0.90
createDeploymentFunction · 0.90
cloneGithubRepositoryFunction · 0.90
cloneGitlabRepositoryFunction · 0.90
cloneGiteaRepositoryFunction · 0.90
cloneBitbucketRepositoryFunction · 0.90
cloneGitRepositoryFunction · 0.90
buildRemoteDockerFunction · 0.90
getBuildCommandFunction · 0.90
execAsyncRemoteFunction · 0.90
execAsyncFunction · 0.90

Tested by

no test coverage detected