Refactor pipeline script

This commit is contained in:
Murtadha 2024-07-27 21:20:21 -04:00
parent 6bb221cbce
commit b005424aa9

View file

@ -79,22 +79,18 @@ steps:
from_secret: ssh_key
port: 2332
script:
- cd /home/mnisyif/docker-containers/mnisyif/frontend
- VERSION=$(cat version.txt)
- echo "Confirming deployment for version: $VERSION"
- docker ps -a
- if ! docker ps | grep -q frontend-$VERSION; then
echo "Container failed to start"
docker logs frontend-$VERSION
exit 1
fi
- echo "Container is running, checking Nginx configuration..."
- docker exec frontend-$VERSION nginx -t || { echo "Nginx configuration test failed"; exit 1; }
- echo "Listing contents of /usr/share/nginx/html"
- docker exec frontend-$VERSION ls -la /usr/share/nginx/html
- echo "Listing contents of /usr/share/nginx/html/resumes"
- docker exec frontend-$VERSION ls -la /usr/share/nginx/html/resumes || echo "Resumes directory not found"
- echo "Checking HTTP response..."
- echo "Verifying deployment..."
# Verify the container is running
- docker ps | grep frontend || { echo "Container failed to start"; exit 1; }
# Display container logs
- docker logs frontend
# Test Nginx configuration
- docker exec frontend nginx -t
# Check Nginx process
- docker exec frontend ps aux | grep nginx
# Check contents of /usr/share/nginx/html in the container
- docker exec frontend ls -la /usr/share/nginx/html
# Perform a simple HTTP request to check if the server is responding
- curl -I http://localhost:5173 || { echo "HTTP request failed"; exit 1; }
- echo "Deployment confirmed successfully"