feat: Add production troubleshooting tools and remove eye icon from ActivityFeed
All checks were successful
Production Deployment (Zero Downtime) / deploy-production (push) Successful in 12m1s
All checks were successful
Production Deployment (Zero Downtime) / deploy-production (push) Successful in 12m1s
- 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
This commit is contained in:
158
scripts/diagnose-production.sh
Executable file
158
scripts/diagnose-production.sh
Executable file
@@ -0,0 +1,158 @@
|
||||
#!/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
|
||||
118
scripts/fix-production.sh
Executable file
118
scripts/fix-production.sh
Executable file
@@ -0,0 +1,118 @@
|
||||
#!/bin/bash
|
||||
# Quick fix script for production issues
|
||||
# Ensures proxy network exists and container is properly connected
|
||||
|
||||
set -e
|
||||
|
||||
echo "🔧 Production Fix Script"
|
||||
echo "======================="
|
||||
echo ""
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
COMPOSE_FILE="docker-compose.production.yml"
|
||||
|
||||
# Check if proxy network exists
|
||||
echo "🌐 Checking proxy network..."
|
||||
if docker network ls | grep -q "proxy"; then
|
||||
echo -e "${GREEN}✅ 'proxy' network exists${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ 'proxy' network does not exist. Creating...${NC}"
|
||||
docker network create proxy || {
|
||||
echo -e "${RED}❌ Failed to create proxy network${NC}"
|
||||
echo "This might be because Nginx Proxy Manager hasn't created it yet."
|
||||
echo "Please ensure Nginx Proxy Manager is running and has created the 'proxy' network."
|
||||
exit 1
|
||||
}
|
||||
echo -e "${GREEN}✅ 'proxy' network created${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Check if container is running
|
||||
echo "📦 Checking container status..."
|
||||
CONTAINER_ID=$(docker ps -q -f "name=portfolio-app")
|
||||
if [ -z "$CONTAINER_ID" ]; then
|
||||
echo -e "${RED}❌ Container is not running${NC}"
|
||||
echo "Starting container..."
|
||||
docker compose -f $COMPOSE_FILE up -d
|
||||
echo "Waiting for container to start..."
|
||||
sleep 10
|
||||
else
|
||||
echo -e "${GREEN}✅ Container is running${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Check if container is connected to proxy network
|
||||
echo "🔗 Checking network connectivity..."
|
||||
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 "Connecting container to proxy network..."
|
||||
|
||||
# Stop container
|
||||
docker compose -f $COMPOSE_FILE stop portfolio
|
||||
|
||||
# Connect to proxy network
|
||||
docker network connect proxy portfolio-app || {
|
||||
echo -e "${RED}❌ Failed to connect container to proxy network${NC}"
|
||||
echo "Trying to recreate container..."
|
||||
docker compose -f $COMPOSE_FILE up -d --force-recreate
|
||||
}
|
||||
|
||||
# Start container
|
||||
docker compose -f $COMPOSE_FILE start portfolio
|
||||
|
||||
echo -e "${GREEN}✅ Container recreated and connected to proxy network${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Wait for health check
|
||||
echo "⏳ Waiting for container to be healthy..."
|
||||
for i in {1..30}; do
|
||||
HEALTH=$(docker inspect portfolio-app --format='{{.State.Health.Status}}' 2>/dev/null || echo "starting")
|
||||
if [ "$HEALTH" == "healthy" ]; then
|
||||
echo -e "${GREEN}✅ Container is healthy${NC}"
|
||||
break
|
||||
fi
|
||||
if [ $i -eq 30 ]; then
|
||||
echo -e "${YELLOW}⚠️ Container health check timeout${NC}"
|
||||
echo "Container logs:"
|
||||
docker logs portfolio-app --tail=30
|
||||
else
|
||||
echo "Waiting... ($i/30)"
|
||||
sleep 2
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
|
||||
# Test API endpoints
|
||||
echo "🧪 Testing API endpoints..."
|
||||
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 is working${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Health endpoint is not working${NC}"
|
||||
echo "Container logs:"
|
||||
docker logs portfolio-app --tail=50
|
||||
exit 1
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Summary
|
||||
echo "📊 Summary:"
|
||||
echo "---------"
|
||||
echo -e "${GREEN}✅ Production fix completed${NC}"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "1. Verify Nginx Proxy Manager configuration:"
|
||||
echo " - Forward Hostname/IP: portfolio-app"
|
||||
echo " - Forward Port: 3000"
|
||||
echo " - Ensure 'proxy' network is selected"
|
||||
echo ""
|
||||
echo "2. Test the website: https://dk0.dev"
|
||||
echo ""
|
||||
echo "3. If still having issues, run: ./scripts/diagnose-production.sh"
|
||||
Reference in New Issue
Block a user