diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 1ba31e48..06296b4f 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -98,7 +98,7 @@ jobs: # Check if container is running sleep 5 - if docker ps | grep -q kulakpos_web_staging; then + if docker ps | grep kulakpos_web_staging; then echo "✅ Staging deployment successful!" docker logs --tail 20 kulakpos_web_staging else @@ -223,7 +223,7 @@ jobs: sleep 10 # Check if container is running - if docker ps | grep -q kulakpos_web_prod; then + if docker ps | grep kulakpos_web_prod; then echo "✅ Production deployment successful!" echo "" echo "Container status:" @@ -275,37 +275,39 @@ jobs: ssh kulakpos_prod << 'EOF' echo "🔍 Verifying production deployment..." - # Check container health - if docker ps --filter "name=kulakpos_web_prod" --format "{{.Status}}" | grep -q "Up"; then + # Check container status (fixed - removed -q flag) + if docker ps --filter "name=kulakpos_web_prod" --format "{{.Status}}" | grep "Up" > /dev/null 2>&1; then echo "✅ Container is running" else echo "❌ Container is not running" exit 1 fi - # Check if port 8000 is listening - if ss -tlnp | grep -q ":8000"; then + # Check if port 8000 is listening (with timeout) + if timeout 5 ss -tlnp 2>/dev/null | grep ":8000" 2>/dev/null || netstat -tlnp 2>/dev/null | grep ":8000" 2>/dev/null; then echo "✅ Application is listening on port 8000" else - echo "❌ Application is not listening on port 8000" + echo "⚠️ Port 8000 not listening, checking container process..." + docker exec kulakpos_web_prod ps aux | grep php || echo "No PHP process found" exit 1 fi - # Test application response - HTTP_CODE=$(curl -k -s -o /dev/null -w "%{http_code}" http://localhost:8000) - if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then - echo "✅ Application is responding with HTTP $HTTP_CODE" - else - echo "❌ Application returned HTTP $HTTP_CODE" - exit 1 - fi + # Test application response (with timeout and retry) + echo "Testing application response..." + for i in 1 2 3 4 5; do + if curl -f -s -o /dev/null -w "%{http_code}" http://localhost:8000 | grep "200\|302"; then + echo "✅ Application is responding" + break + elif [ $i -eq 5 ]; then + echo "❌ Application not responding after 5 attempts" + docker logs --tail 20 kulakpos_web_prod + exit 1 + fi + echo "Attempt $i/5 failed, waiting..." + sleep 2 + done - # Check if .env is properly mounted - docker exec kulakpos_web_prod test -f /var/www/html/.env && echo "✅ .env file is mounted" || echo "⚠️ .env file not found" - - echo "" echo "🎉 Production deployment verification complete!" - echo "Application is running at: https://prod-test.kulakpos.id" EOF - name: Send Deployment Notification