mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-26 01:25:22 +02:00
- Added `prepareEnvironmentVariablesForShell` function to properly escape environment variables for shell usage. - Updated various builders (Docker, Heroku, Nixpacks, Paketo, Railpack) to utilize the new function for improved handling of special characters in environment variables. - Introduced tests to validate the handling of environment variables with various special characters, ensuring robustness in shell command execution. - Added `shell-quote` dependency to manage quoting of shell arguments effectively.
44 lines
1003 B
TypeScript
44 lines
1003 B
TypeScript
import { prepareEnvironmentVariablesForShell } from "../docker/utils";
|
|
import { getBuildAppDirectory } from "../filesystem/directory";
|
|
import type { ApplicationNested } from ".";
|
|
|
|
export const getHerokuCommand = (application: ApplicationNested) => {
|
|
const { env, appName, cleanCache } = application;
|
|
|
|
const buildAppDirectory = getBuildAppDirectory(application);
|
|
const envVariables = prepareEnvironmentVariablesForShell(
|
|
env,
|
|
application.environment.project.env,
|
|
application.environment.env,
|
|
);
|
|
|
|
const args = [
|
|
"build",
|
|
appName,
|
|
"--path",
|
|
buildAppDirectory,
|
|
"--builder",
|
|
`heroku/builder:${application.herokuVersion || "24"}`,
|
|
];
|
|
|
|
if (cleanCache) {
|
|
args.push("--clear-cache");
|
|
}
|
|
|
|
for (const env of envVariables) {
|
|
args.push("--env", env);
|
|
}
|
|
|
|
const command = `pack ${args.join(" ")}`;
|
|
const bashCommand = `
|
|
echo "Starting heroku build..." ;
|
|
${command} || {
|
|
echo "❌ Heroku build failed" ;
|
|
exit 1;
|
|
}
|
|
echo "✅ Heroku build completed." ;
|
|
`;
|
|
|
|
return bashCommand;
|
|
};
|