This commit is contained in:
Evgeniy Kan 2026-09-11 13:14:50 -04:00 committed by GitHub
commit c8299f924d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 11 deletions

View File

@ -429,10 +429,16 @@ export const deployPreviewApplication = async ({
application.buildArgs = `${application.previewBuildArgs}\nDOKPLOY_DEPLOY_URL=${previewDeployment?.domain?.host}`;
application.buildSecrets = `${application.previewBuildSecrets}\nDOKPLOY_DEPLOY_URL=${previewDeployment?.domain?.host}`;
application.rollbackActive = false;
application.buildRegistry = null;
if (
!application.buildServerId ||
application.buildServerId === application.serverId
) {
application.buildRegistry = null;
}
application.rollbackRegistry = null;
application.registry = null;
const buildServerId = application.buildServerId || application.serverId;
let command = "set -e;";
if (application.sourceType === "github") {
command += await cloneGithubRepository({
@ -443,8 +449,8 @@ export const deployPreviewApplication = async ({
command += await getBuildCommand(application);
const commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`;
if (application.serverId) {
await execAsyncRemote(application.serverId, commandWithLog);
if (buildServerId) {
await execAsyncRemote(buildServerId, commandWithLog);
} else {
await execAsync(commandWithLog);
}
@ -548,11 +554,16 @@ export const rebuildPreviewApplication = async ({
application.buildArgs = `${application.previewBuildArgs}\nDOKPLOY_DEPLOY_URL=${previewDeployment?.domain?.host}`;
application.buildSecrets = `${application.previewBuildSecrets}\nDOKPLOY_DEPLOY_URL=${previewDeployment?.domain?.host}`;
application.rollbackActive = false;
application.buildRegistry = null;
if (
!application.buildServerId ||
application.buildServerId === application.serverId
) {
application.buildRegistry = null;
}
application.rollbackRegistry = null;
application.registry = null;
const serverId = application.serverId;
const serverId = application.buildServerId || application.serverId;
let command = "set -e;";
// Only rebuild, don't clone repository
command += await getBuildCommand(application);

View File

@ -210,22 +210,23 @@ export const createDeploymentPreview = async (
const previewDeployment = await findPreviewDeploymentById(
deployment.previewDeploymentId,
);
const buildServerId =
previewDeployment?.application?.buildServerId ||
previewDeployment?.application?.serverId;
await removeLastTenDeployments(
deployment.previewDeploymentId,
"previewDeployment",
previewDeployment?.application?.serverId,
buildServerId,
);
try {
const appName = `${previewDeployment.appName}`;
const { LOGS_PATH } = paths(!!previewDeployment?.application?.serverId);
const { LOGS_PATH } = paths(!!buildServerId);
const formattedDateTime = format(new Date(), "yyyy-MM-dd:HH:mm:ss");
const fileName = `${appName}-${formattedDateTime}.log`;
const logFilePath = path.join(LOGS_PATH, appName, fileName);
if (previewDeployment?.application?.serverId) {
const server = await findServerById(
previewDeployment?.application?.serverId,
);
if (buildServerId) {
const server = await findServerById(buildServerId);
const command = `
mkdir -p ${LOGS_PATH}/${appName};
@ -249,6 +250,9 @@ export const createDeploymentPreview = async (
description: deployment.description || "",
previewDeploymentId: deployment.previewDeploymentId,
startedAt: new Date().toISOString(),
...(previewDeployment?.application?.buildServerId && {
buildServerId: previewDeployment.application.buildServerId,
}),
})
.returning();
if (deploymentCreate.length === 0 || !deploymentCreate[0]) {

View File

@ -33,6 +33,7 @@ export const findPreviewDeploymentById = async (
columns: {
applicationId: true,
serverId: true,
buildServerId: true,
},
},
},