feat: show build logs alongside pod logs in app detail page
This commit is contained in:
@@ -45,7 +45,10 @@ export class DeploymentsService {
|
||||
try {
|
||||
// Step 1: Build image
|
||||
await this.updateStatus(deploymentId, DeploymentStatus.BUILDING);
|
||||
const imageUri = await this.buildService.buildImage(app);
|
||||
const { imageUri, buildLog } = await this.buildService.buildImage(app);
|
||||
|
||||
// Save build log
|
||||
await this.deploymentsRepository.update(deploymentId, { buildLog });
|
||||
|
||||
// Step 2: Update app with new image tag
|
||||
await this.applicationsService.updateImageTag(app.id, imageUri);
|
||||
@@ -62,9 +65,13 @@ export class DeploymentsService {
|
||||
});
|
||||
} catch (error: any) {
|
||||
this.logger.error(`Deployment ${deploymentId} failed:`, error);
|
||||
|
||||
// Save build log if available (attached by build service on failure)
|
||||
const buildLog = error.buildLog || null;
|
||||
await this.deploymentsRepository.update(deploymentId, {
|
||||
status: DeploymentStatus.FAILED,
|
||||
errorMessage: error.message,
|
||||
...(buildLog ? { buildLog } : {}),
|
||||
finishedAt: new Date(),
|
||||
});
|
||||
}
|
||||
@@ -97,6 +104,27 @@ export class DeploymentsService {
|
||||
return this.kubernetesService.getPodLogs(app);
|
||||
}
|
||||
|
||||
async getBuildLogs(applicationId: string, userId: string): Promise<{ buildLog: string | null; status: string; version: string | null; createdAt: Date }> {
|
||||
// Verify user access
|
||||
await this.applicationsService.findOne(applicationId, userId);
|
||||
|
||||
const latest = await this.deploymentsRepository.findOne({
|
||||
where: { applicationId },
|
||||
order: { createdAt: 'DESC' },
|
||||
});
|
||||
|
||||
if (!latest) {
|
||||
return { buildLog: null, status: 'no_deployment', version: null, createdAt: new Date() };
|
||||
}
|
||||
|
||||
return {
|
||||
buildLog: latest.buildLog || null,
|
||||
status: latest.status,
|
||||
version: latest.version,
|
||||
createdAt: latest.createdAt,
|
||||
};
|
||||
}
|
||||
|
||||
async stopDeployment(applicationId: string, userId: string): Promise<Deployment | null> {
|
||||
const app = await this.applicationsService.findOne(applicationId, userId);
|
||||
await this.kubernetesService.scaleDeployment(app, 0);
|
||||
|
||||
Reference in New Issue
Block a user