deploying works!
This commit is contained in:
@@ -87,6 +87,18 @@ function initializeSteps() {
|
||||
</div>
|
||||
`;
|
||||
stepsContainer.appendChild(dockerComposeStep);
|
||||
|
||||
// Add Portainer stack deployment step
|
||||
const stackDeployStep = document.createElement('div');
|
||||
stackDeployStep.className = 'step-item';
|
||||
stackDeployStep.innerHTML = `
|
||||
<div class="step-icon"><i class="fab fa-docker"></i></div>
|
||||
<div class="step-content">
|
||||
<h5>Deploying Stack</h5>
|
||||
<p class="step-status">Launching your application stack...</p>
|
||||
</div>
|
||||
`;
|
||||
stepsContainer.appendChild(stackDeployStep);
|
||||
}
|
||||
|
||||
async function startLaunch(data) {
|
||||
@@ -226,6 +238,58 @@ async function startLaunch(data) {
|
||||
};
|
||||
dockerComposeStep.querySelector('.step-content').appendChild(downloadButton);
|
||||
|
||||
// Step 7: Deploy Stack
|
||||
await updateStep(7, 'Deploying Stack', 'Launching your application stack...');
|
||||
const stackResult = await deployStack(dockerComposeResult.content, data.instanceName, data.port);
|
||||
|
||||
if (!stackResult.success) {
|
||||
throw new Error(stackResult.error || 'Failed to deploy stack');
|
||||
}
|
||||
|
||||
// Update the step to show success
|
||||
const stackDeployStep = document.querySelectorAll('.step-item')[6];
|
||||
stackDeployStep.classList.remove('active');
|
||||
stackDeployStep.classList.add('completed');
|
||||
stackDeployStep.querySelector('.step-status').textContent = 'Successfully deployed stack';
|
||||
|
||||
// Add stack details
|
||||
const stackDetails = document.createElement('div');
|
||||
stackDetails.className = 'mt-3';
|
||||
stackDetails.innerHTML = `
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title mb-3">Stack Deployment Results</h6>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Property</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Stack Name</td>
|
||||
<td>${stackResult.data.name}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Stack ID</td>
|
||||
<td>${stackResult.data.id}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Status</td>
|
||||
<td>
|
||||
<span class="badge bg-success">Deployed</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
stackDeployStep.querySelector('.step-content').appendChild(stackDetails);
|
||||
|
||||
} catch (error) {
|
||||
showError(error.message);
|
||||
}
|
||||
@@ -912,4 +976,48 @@ async function downloadDockerCompose(repo, branch) {
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Add new function to deploy stack
|
||||
async function deployStack(dockerComposeContent, stackName, port) {
|
||||
try {
|
||||
const response = await fetch('/api/admin/deploy-stack', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name: `docupulse_${port}`,
|
||||
StackFileContent: dockerComposeContent,
|
||||
Env: [
|
||||
{
|
||||
name: 'PORT',
|
||||
value: port.toString()
|
||||
},
|
||||
{
|
||||
name: 'ISMASTER',
|
||||
value: 'false'
|
||||
}
|
||||
]
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(error.error || 'Failed to deploy stack');
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return {
|
||||
success: true,
|
||||
data: result
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error deploying stack:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user