Files
portfolio/scripts/diagnose-production.sh
denshooter b487f4ba75
All checks were successful
Production Deployment (Zero Downtime) / deploy-production (push) Successful in 12m1s
feat: Add production troubleshooting tools and remove eye icon from ActivityFeed
- Add diagnose-production.sh script for comprehensive production diagnostics
- Add fix-production.sh script for automatic production issue resolution
- Add PRODUCTION_TROUBLESHOOTING.md documentation with step-by-step guides
- Remove eye icon from ActivityFeed header (keep only X button for minimize)
- Improve error handling and network connectivity checks
2026-01-09 20:20:08 +01:00

159 lines
5.8 KiB
Bash
Executable File

#!/bin/bash
# Production diagnosis script
# Checks container status, network connectivity, and API endpoints
set -e
echo "🔍 Production Diagnosis Script"
echo "=============================="
echo ""
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check if docker is running
if ! docker info > /dev/null 2>&1; then
echo -e "${RED}❌ Docker is not running${NC}"
exit 1
fi
echo -e "${GREEN}✅ Docker is running${NC}"
echo ""
# Check container status
echo "📦 Container Status:"
echo "-------------------"
CONTAINER_ID=$(docker ps -q -f "name=portfolio-app")
if [ -z "$CONTAINER_ID" ]; then
echo -e "${RED}❌ portfolio-app container is not running${NC}"
echo ""
echo "Checking for stopped containers:"
docker ps -a -f "name=portfolio-app" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
exit 1
else
echo -e "${GREEN}✅ Container is running (ID: ${CONTAINER_ID})${NC}"
docker ps -f "name=portfolio-app" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}\t{{.Health}}"
fi
echo ""
# Check container health
echo "🏥 Container Health:"
echo "-------------------"
HEALTH=$(docker inspect portfolio-app --format='{{.State.Health.Status}}' 2>/dev/null || echo "no-healthcheck")
STATUS=$(docker inspect portfolio-app --format='{{.State.Status}}' 2>/dev/null || echo "unknown")
echo "Status: $STATUS"
echo "Health: $HEALTH"
echo ""
# Check networks
echo "🌐 Network Connectivity:"
echo "----------------------"
if docker network ls | grep -q "proxy"; then
echo -e "${GREEN}✅ 'proxy' network exists${NC}"
if docker inspect portfolio-app --format='{{range $net, $conf := .NetworkSettings.Networks}}{{$net}} {{end}}' | grep -q "proxy"; then
echo -e "${GREEN}✅ Container is connected to 'proxy' network${NC}"
else
echo -e "${YELLOW}⚠️ Container is NOT connected to 'proxy' network${NC}"
echo "Connected networks:"
docker inspect portfolio-app --format='{{range $net, $conf := .NetworkSettings.Networks}}{{$net}} {{end}}'
fi
else
echo -e "${RED}❌ 'proxy' network does not exist${NC}"
echo "Creating proxy network..."
docker network create proxy || echo "Failed to create network (may already exist)"
fi
echo ""
# Check port mapping
echo "🔌 Port Mapping:"
echo "---------------"
PORT_MAPPING=$(docker port portfolio-app 2>/dev/null | grep 3000 || echo "No port mapping found")
if [ -n "$PORT_MAPPING" ]; then
echo -e "${GREEN}✅ Port mapping: $PORT_MAPPING${NC}"
else
echo -e "${RED}❌ No port mapping found for port 3000${NC}"
fi
echo ""
# Test from inside container
echo "🧪 Testing from inside container:"
echo "-------------------------------"
if docker exec portfolio-app curl -f -s --max-time 5 http://localhost:3000/api/health > /dev/null 2>&1; then
echo -e "${GREEN}✅ Health endpoint responds from inside container${NC}"
docker exec portfolio-app curl -s http://localhost:3000/api/health | head -5
else
echo -e "${RED}❌ Health endpoint does not respond from inside container${NC}"
echo "Container logs (last 20 lines):"
docker logs portfolio-app --tail=20
fi
echo ""
# Test from host
echo "🧪 Testing from host:"
echo "-------------------"
if curl -f -s --max-time 5 http://localhost:3000/api/health > /dev/null 2>&1; then
echo -e "${GREEN}✅ Health endpoint responds from host${NC}"
curl -s http://localhost:3000/api/health | head -5
else
echo -e "${RED}❌ Health endpoint does not respond from host${NC}"
echo "This is normal if the container is only accessible via proxy network"
fi
echo ""
# Check environment variables
echo "🔐 Environment Variables:"
echo "------------------------"
echo "N8N_WEBHOOK_URL: $(docker exec portfolio-app printenv N8N_WEBHOOK_URL 2>/dev/null | grep -v '^$' || echo 'NOT SET')"
echo "N8N_SECRET_TOKEN: $(docker exec portfolio-app printenv N8N_SECRET_TOKEN 2>/dev/null | grep -v '^$' | sed 's/./*/g' || echo 'NOT SET')"
echo "N8N_API_KEY: $(docker exec portfolio-app printenv N8N_API_KEY 2>/dev/null | grep -v '^$' | sed 's/./*/g' || echo 'NOT SET')"
echo "NODE_ENV: $(docker exec portfolio-app printenv NODE_ENV 2>/dev/null || echo 'NOT SET')"
echo "NEXT_PUBLIC_BASE_URL: $(docker exec portfolio-app printenv NEXT_PUBLIC_BASE_URL 2>/dev/null || echo 'NOT SET')"
echo ""
# Check container logs for errors
echo "📋 Recent Container Logs (last 30 lines):"
echo "----------------------------------------"
docker logs portfolio-app --tail=30 2>&1 | tail -30
echo ""
# Check API endpoints
echo "🌐 Testing API Endpoints:"
echo "------------------------"
ENDPOINTS=("/api/health" "/api/n8n/status" "/api/n8n/chat")
for endpoint in "${ENDPOINTS[@]}"; do
echo -n "Testing $endpoint: "
if docker exec portfolio-app curl -f -s --max-time 5 "http://localhost:3000${endpoint}" > /dev/null 2>&1; then
echo -e "${GREEN}✅ OK${NC}"
else
echo -e "${RED}❌ FAILED${NC}"
fi
done
echo ""
# Summary
echo "📊 Summary:"
echo "---------"
if [ "$STATUS" == "running" ] && [ "$HEALTH" == "healthy" ]; then
echo -e "${GREEN}✅ Container appears to be healthy${NC}"
echo ""
echo "If you're still seeing 502 errors:"
echo "1. Check Nginx Proxy Manager configuration"
echo "2. Ensure the proxy host points to: portfolio-app:3000 (not localhost:3000)"
echo "3. Ensure the proxy network is correctly configured"
echo "4. Check Nginx Proxy Manager logs"
else
echo -e "${RED}❌ Container has issues${NC}"
echo ""
echo "Recommended actions:"
if [ "$STATUS" != "running" ]; then
echo "1. Restart the container: docker compose -f docker-compose.production.yml restart portfolio"
fi
if [ "$HEALTH" != "healthy" ]; then
echo "2. Check container logs: docker logs portfolio-app --tail=50"
echo "3. Check if the application is starting correctly"
fi
fi