mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
- Introduced a new boolean column `cleanCache` in the application schema to manage cache cleaning behavior. - Updated the application form to include a toggle for `cleanCache`, allowing users to enable or disable cache cleaning. - Enhanced application deployment logic to utilize the `cleanCache` setting, affecting build commands across various builders (Docker, Heroku, Nixpacks, Paketo, Railpack). - Implemented success and error notifications for cache updates in the UI.
87 lines
1.8 KiB
TypeScript
87 lines
1.8 KiB
TypeScript
import type { WriteStream } from "node:fs";
|
|
import type { ApplicationNested } from ".";
|
|
import { prepareEnvironmentVariables } from "../docker/utils";
|
|
import { getBuildAppDirectory } from "../filesystem/directory";
|
|
import { spawnAsync } from "../process/spawnAsync";
|
|
|
|
export const buildPaketo = async (
|
|
application: ApplicationNested,
|
|
writeStream: WriteStream,
|
|
) => {
|
|
const { env, appName, cleanCache } = application;
|
|
const buildAppDirectory = getBuildAppDirectory(application);
|
|
const envVariables = prepareEnvironmentVariables(
|
|
env,
|
|
application.project.env,
|
|
);
|
|
try {
|
|
const args = [
|
|
"build",
|
|
appName,
|
|
"--path",
|
|
buildAppDirectory,
|
|
"--builder",
|
|
"paketobuildpacks/builder-jammy-full",
|
|
];
|
|
|
|
if (cleanCache) {
|
|
args.push("--clear-cache");
|
|
}
|
|
|
|
for (const env of envVariables) {
|
|
args.push("--env", env);
|
|
}
|
|
|
|
await spawnAsync("pack", args, (data) => {
|
|
if (writeStream.writable) {
|
|
writeStream.write(data);
|
|
}
|
|
});
|
|
return true;
|
|
} catch (e) {
|
|
throw e;
|
|
}
|
|
};
|
|
|
|
export const getPaketoCommand = (
|
|
application: ApplicationNested,
|
|
logPath: string,
|
|
) => {
|
|
const { env, appName, cleanCache } = application;
|
|
|
|
const buildAppDirectory = getBuildAppDirectory(application);
|
|
const envVariables = prepareEnvironmentVariables(
|
|
env,
|
|
application.project.env,
|
|
);
|
|
|
|
const args = [
|
|
"build",
|
|
appName,
|
|
"--path",
|
|
buildAppDirectory,
|
|
"--builder",
|
|
"paketobuildpacks/builder-jammy-full",
|
|
];
|
|
|
|
if (cleanCache) {
|
|
args.push("--clear-cache");
|
|
}
|
|
|
|
for (const env of envVariables) {
|
|
args.push("--env", `'${env}'`);
|
|
}
|
|
|
|
const command = `pack ${args.join(" ")}`;
|
|
const bashCommand = `
|
|
echo "Starting Paketo build..." >> ${logPath};
|
|
${command} >> ${logPath} 2>> ${logPath} || {
|
|
echo "❌ Paketo build failed" >> ${logPath};
|
|
exit 1;
|
|
}
|
|
echo "✅ Paketo build completed." >> ${logPath};
|
|
`;
|
|
|
|
return bashCommand;
|
|
};
|