🚀 Improve local deployment script with enhanced error handling, health checks, and logging
This commit is contained in:
@@ -208,7 +208,11 @@ async function deployLocal(config) {
|
|||||||
console.log('\n🐳 Deploying to local Docker...');
|
console.log('\n🐳 Deploying to local Docker...');
|
||||||
|
|
||||||
// Create modified docker-compose
|
// Create modified docker-compose
|
||||||
const modifiedCompose = createModifiedDockerCompose(config.port, config.sslPort, config.backendPort);
|
const modifiedCompose = createModifiedDockerCompose(
|
||||||
|
config.port,
|
||||||
|
config.sslPort,
|
||||||
|
config.backendPort
|
||||||
|
);
|
||||||
const tmpComposePath = path.join(SOURCE_DIR, 'docker-compose.tmp.yml');
|
const tmpComposePath = path.join(SOURCE_DIR, 'docker-compose.tmp.yml');
|
||||||
fs.writeFileSync(tmpComposePath, modifiedCompose);
|
fs.writeFileSync(tmpComposePath, modifiedCompose);
|
||||||
|
|
||||||
@@ -216,17 +220,28 @@ async function deployLocal(config) {
|
|||||||
// Stop existing
|
// Stop existing
|
||||||
console.log(' 🛑 Stopping existing containers...');
|
console.log(' 🛑 Stopping existing containers...');
|
||||||
try {
|
try {
|
||||||
execSync(`docker compose -f "${tmpComposePath}" down --remove-orphans`, { cwd: SOURCE_DIR, stdio: 'inherit' });
|
execSync(`docker compose -f "${tmpComposePath}" down --remove-orphans`, {
|
||||||
|
cwd: SOURCE_DIR,
|
||||||
|
stdio: 'inherit'
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Ignore if file doesn't exist yet or other issues on down
|
// Ignore if file doesn't exist yet or other issues on down
|
||||||
try {
|
try {
|
||||||
execSync(`docker compose -f docker-compose.production.yml down --remove-orphans`, { cwd: SOURCE_DIR, stdio: 'inherit' });
|
execSync(
|
||||||
} catch (e2) { /* ignore */ }
|
`docker compose -f docker-compose.production.yml down --remove-orphans`,
|
||||||
|
{ cwd: SOURCE_DIR, stdio: 'inherit' }
|
||||||
|
);
|
||||||
|
} catch (e2) {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Up
|
// Up
|
||||||
console.log(' 🚀 Starting containers...');
|
console.log(' 🚀 Starting containers...');
|
||||||
execSync(`docker compose -f "${tmpComposePath}" up -d --build`, { cwd: SOURCE_DIR, stdio: 'inherit' });
|
execSync(`docker compose -f "${tmpComposePath}" up -d --build`, {
|
||||||
|
cwd: SOURCE_DIR,
|
||||||
|
stdio: 'inherit'
|
||||||
|
});
|
||||||
|
|
||||||
// Health Check
|
// Health Check
|
||||||
console.log('\n🏥 Performing health checks...');
|
console.log('\n🏥 Performing health checks...');
|
||||||
@@ -243,9 +258,9 @@ async function deployLocal(config) {
|
|||||||
|
|
||||||
console.log(`\n🎉 Local Deployment successful!`);
|
console.log(`\n🎉 Local Deployment successful!`);
|
||||||
console.log(`🌐 Frontend: http://localhost:${config.port}`);
|
console.log(`🌐 Frontend: http://localhost:${config.port}`);
|
||||||
if (config.sslPort) console.log(`🔒 HTTPS: https://localhost:${config.sslPort}`);
|
if (config.sslPort)
|
||||||
|
console.log(`🔒 HTTPS: https://localhost:${config.sslPort}`);
|
||||||
console.log(`🔌 Backend: http://localhost:${config.backendPort}`);
|
console.log(`🔌 Backend: http://localhost:${config.backendPort}`);
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('❌ Local deployment failed:', e.message);
|
console.error('❌ Local deployment failed:', e.message);
|
||||||
// Clean up tmp file? Maybe keep for debugging if failed
|
// Clean up tmp file? Maybe keep for debugging if failed
|
||||||
|
|||||||
Reference in New Issue
Block a user