Skip to content
Snippets Groups Projects
Commit 08b410d4 authored by Burhan Akbar's avatar Burhan Akbar
Browse files

Deployment checks App Works

parent 88d5a500
No related branches found
No related tags found
No related merge requests found
......@@ -92,17 +92,26 @@ pipeline {
scp src/main/resources/01_schema.sql ${APP_VM}:~/healthcare/src/main/resources/
scp src/main/resources/02_data.sql ${APP_VM}:~/healthcare/src/main/resources/
"""
// Run Docker Compose commands on App VM
// Run Docker Compose commands on App VM with error checking and health probe
sh """
ssh ${APP_VM} '
set -e; # Exit immediately if a command exits with a non-zero status.
cd ~/healthcare &&
/usr/local/bin/docker-compose down -v --remove-orphans || echo "Compose down failed or had nothing to do."
docker system prune -f || echo "Prune failed."
echo "Bringing down existing services and volumes..."
/usr/local/bin/docker-compose down -v --remove-orphans
echo "Pruning unused Docker objects..."
docker system prune -af # Use -a to remove all unused images, not just dangling ones
echo "Building and starting services..."
# Keep password hardcoded in docker-compose.yml for now
/usr/local/bin/docker-compose -f docker-compose.yml up -d --build || echo "Compose up command failed."
/usr/local/bin/docker-compose -f docker-compose.yml build --pull # Add --pull to ensure base images are updated
/usr/local/bin/docker-compose -f docker-compose.yml up -d
echo "Waiting briefly for application to start..."
sleep 5 # Optional: Give the app a few seconds to initialize before probing
echo "Checking application health..."
curl -f http://localhost:8081/actuator/health # Fail the step if health check fails
echo "Application is healthy!"
'
"""
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment