(compose: ComposeNested)
| 97 | }; |
| 98 | |
| 99 | export 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 ` |
| 127 | touch ${envFilePath}; |
| 128 | echo "${encodedContent}" | base64 -d > "${envFilePath}"; |
| 129 | `; |
| 130 | }; |
| 131 | |
| 132 | const getExportEnvCommand = (compose: ComposeNested) => { |
| 133 | if (compose.composeType !== "stack") return ""; |
no test coverage detected