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