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

Function getBuildComposeCommand

packages/server/src/utils/builders/compose.ts:18–68  ·  view source on GitHub ↗
(compose: ComposeNested)

Source from the content-addressed store, hash-verified

16>;
17
18export const getBuildComposeCommand = async (compose: ComposeNested) => {
19 const { COMPOSE_PATH } = paths(!!compose.serverId);
20 const { sourceType, appName, mounts, composeType, domains } = compose;
21 const command = createCommand(compose);
22 const envCommand = getCreateEnvFileCommand(compose);
23 const projectPath = join(COMPOSE_PATH, compose.appName, "code");
24 const exportEnvCommand = getExportEnvCommand(compose);
25
26 const newCompose = await writeDomainsToCompose(compose, domains);
27 const logContent = `
28App Name: ${appName}
29Build Compose 🐳
30Detected: ${mounts.length} mounts 📂
31Command: docker ${command}
32Source Type: docker ${sourceType} ✅
33Compose Type: ${composeType} ✅`;
34
35 const logBox = boxen(logContent, {
36 padding: {
37 left: 1,
38 right: 1,
39 bottom: 1,
40 },
41 width: 80,
42 borderStyle: "double",
43 });
44
45 const bashCommand = `
46 set -e
47 {
48 echo "${logBox}";
49
50 ${newCompose}
51
52 ${envCommand}
53
54 cd "${projectPath}";
55
56 ${compose.isolatedDeployment ? `docker network inspect ${compose.appName} >/dev/null 2>&1 || docker network create ${compose.composeType === "stack" ? "--driver overlay" : ""} --attachable ${compose.appName}` : ""}
57 env -i PATH="$PATH" HOME="$HOME" ${exportEnvCommand} docker ${command.split(" ").join(" ")} 2>&1 || { echo "Error: ❌ Docker command failed"; exit 1; }
58 ${compose.isolatedDeployment ? `docker network connect ${compose.appName} $(docker ps --filter "name=dokploy-traefik" -q) >/dev/null 2>&1` : ""}
59
60 echo "Docker Compose Deployed: ✅";
61 } || {
62 echo "Error: ❌ Script execution failed";
63 exit 1
64 }
65 `;
66
67 return bashCommand;
68};
69
70const sanitizeCommand = (command: string) => {
71 const sanitizedCommand = command.trim();

Callers 3

deployComposeFunction · 0.90
rebuildComposeFunction · 0.90

Calls 5

pathsFunction · 0.90
writeDomainsToComposeFunction · 0.90
createCommandFunction · 0.85
getCreateEnvFileCommandFunction · 0.85
getExportEnvCommandFunction · 0.85

Tested by

no test coverage detected