fix: use Dokploy API status check instead of HTTP health check
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 16s

The portal container cannot reach deployed stacks via external URL.
Now checks applicationStatus via Dokploy API instead.
This commit is contained in:
2026-01-10 11:56:15 +01:00
parent 9f2ee66f19
commit 7e95e9f310

View File

@@ -347,53 +347,32 @@ export class ProductionDeployer {
): Promise<void> { ): Promise<void> {
state.phase = 'verifying_health'; state.phase = 'verifying_health';
state.progress = 95; state.progress = 95;
state.message = 'Verifying application health'; state.message = 'Verifying application status via Dokploy';
if (!state.url) { if (!state.resources.applicationId) {
throw new Error('Application URL not available'); throw new Error('Application ID not available');
} }
const timeout = config.healthCheckTimeout || 120000; const timeout = config.healthCheckTimeout || 60000;
const interval = config.healthCheckInterval || 5000; const interval = config.healthCheckInterval || 3000;
const startTime = Date.now(); const startTime = Date.now();
const endpoints = ['/', '/health', '/api'];
while (Date.now() - startTime < timeout) { while (Date.now() - startTime < timeout) {
for (const endpoint of endpoints) {
try { try {
const checkUrl = `${state.url}${endpoint}`; const app = await this.client.getApplication(state.resources.applicationId);
const controller = new AbortController(); const appStatus = app.applicationStatus;
const timeoutId = setTimeout(() => controller.abort(), 5000); console.log(`Application status: ${appStatus}`);
const response = await fetch(checkUrl, { if (appStatus === 'done') {
method: 'GET', state.message = 'Application deployed successfully';
signal: controller.signal,
});
clearTimeout(timeoutId);
console.log(`Health check ${checkUrl} returned ${response.status}`);
state.message = 'Application is responding';
return; return;
}
if (appStatus === 'error') {
throw new Error('Application deployment failed in Dokploy');
}
} catch (error) { } catch (error) {
const errorMsg = error instanceof Error ? error.message : String(error); console.log(`Status check failed: ${error}`);
if (
errorMsg.includes('certificate') ||
errorMsg.includes('SSL') ||
errorMsg.includes('TLS') ||
errorMsg.includes('CERT') ||
errorMsg.includes('unable to verify') ||
errorMsg.includes('self signed') ||
errorMsg.includes('self-signed')
) {
console.log(`Health check SSL error (treating as alive): ${errorMsg}`);
state.message = 'Application is responding (SSL provisioning)';
return;
}
console.log(`Health check failed: ${errorMsg}`);
}
} }
const elapsed = Math.round((Date.now() - startTime) / 1000); const elapsed = Math.round((Date.now() - startTime) / 1000);
@@ -403,7 +382,7 @@ export class ProductionDeployer {
await this.sleep(interval); await this.sleep(interval);
} }
throw new Error('Health check timeout - application did not become healthy'); throw new Error('Health check timeout - application did not become ready');
} }
private async rollback(state: DeploymentState): Promise<void> { private async rollback(state: DeploymentState): Promise<void> {