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

Function getCreateEnvFileCommand

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

Source from the content-addressed store, hash-verified

97};
98
99export const getCreateEnvFileCommand = (compose: ComposeNested) => {
100 const { COMPOSE_PATH } = paths(!!compose.serverId);
101 const { env, composePath, appName } = compose;
102 const composeFilePath =
103 join(COMPOSE_PATH, appName, "code", composePath) ||
104 join(COMPOSE_PATH, appName, "code", "docker-compose.yml");
105
106 const envFilePath = join(dirname(composeFilePath), ".env");
107
108 let envContent = `APP_NAME=${appName}\n`;
109 envContent += `COMPOSE_PROJECT_NAME=${appName}\n`;
110 envContent += env || "";
111 if (!envContent.includes("DOCKER_CONFIG")) {
112 envContent += "\nDOCKER_CONFIG=/root/.docker";
113 }
114
115 if (compose.randomize) {
116 envContent += `\nCOMPOSE_PREFIX=${compose.suffix}`;
117 }
118
119 const envFileContent = prepareEnvironmentVariables(
120 envContent,
121 compose.environment.project.env,
122 compose.environment.env,
123 ).join("\n");
124
125 const encodedContent = encodeBase64(envFileContent);
126 return `
127touch ${envFilePath};
128echo "${encodedContent}" | base64 -d > "${envFilePath}";
129 `;
130};
131
132const getExportEnvCommand = (compose: ComposeNested) => {
133 if (compose.composeType !== "stack") return "";

Callers 1

getBuildComposeCommandFunction · 0.85

Calls 3

pathsFunction · 0.90
encodeBase64Function · 0.90

Tested by

no test coverage detected