chore: Clean up old files
This commit is contained in:
@@ -1,165 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Debug script for Gitea Actions
|
||||
# Helps identify issues with Gitea Actions deployment
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Logging function
|
||||
log() {
|
||||
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
|
||||
}
|
||||
|
||||
error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
log "🔍 Debugging Gitea Actions deployment..."
|
||||
|
||||
# Check if we're in the right directory
|
||||
if [ ! -f "package.json" ] || [ ! -f "Dockerfile" ]; then
|
||||
error "Please run this script from the project root directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check Docker
|
||||
log "🐳 Checking Docker..."
|
||||
if ! docker info > /dev/null 2>&1; then
|
||||
error "Docker is not running"
|
||||
exit 1
|
||||
fi
|
||||
success "Docker is running"
|
||||
|
||||
# Check Docker Compose
|
||||
log "🐳 Checking Docker Compose..."
|
||||
if ! docker compose version > /dev/null 2>&1; then
|
||||
error "Docker Compose is not available"
|
||||
exit 1
|
||||
fi
|
||||
success "Docker Compose is available"
|
||||
|
||||
# Check environment variables
|
||||
log "📝 Checking environment variables..."
|
||||
if [ -z "$NEXT_PUBLIC_BASE_URL" ]; then
|
||||
warning "NEXT_PUBLIC_BASE_URL is not set, using default"
|
||||
export NEXT_PUBLIC_BASE_URL="https://dk0.dev"
|
||||
fi
|
||||
|
||||
if [ -z "$MY_EMAIL" ]; then
|
||||
warning "MY_EMAIL is not set, using default"
|
||||
export MY_EMAIL="contact@dk0.dev"
|
||||
fi
|
||||
|
||||
if [ -z "$MY_INFO_EMAIL" ]; then
|
||||
warning "MY_INFO_EMAIL is not set, using default"
|
||||
export MY_INFO_EMAIL="info@dk0.dev"
|
||||
fi
|
||||
|
||||
if [ -z "$MY_PASSWORD" ]; then
|
||||
warning "MY_PASSWORD is not set, using default"
|
||||
export MY_PASSWORD="your-email-password"
|
||||
fi
|
||||
|
||||
if [ -z "$MY_INFO_PASSWORD" ]; then
|
||||
warning "MY_INFO_PASSWORD is not set, using default"
|
||||
export MY_INFO_PASSWORD="your-info-email-password"
|
||||
fi
|
||||
|
||||
if [ -z "$ADMIN_BASIC_AUTH" ]; then
|
||||
warning "ADMIN_BASIC_AUTH is not set, using default"
|
||||
export ADMIN_BASIC_AUTH="admin:your_secure_password_here"
|
||||
fi
|
||||
|
||||
success "Environment variables configured"
|
||||
|
||||
# Check if .env file exists
|
||||
if [ ! -f ".env" ]; then
|
||||
warning ".env file not found, creating from template..."
|
||||
cp env.example .env
|
||||
success ".env file created"
|
||||
fi
|
||||
|
||||
# Test Docker Compose configuration
|
||||
log "🔧 Testing Docker Compose configuration..."
|
||||
if docker compose config > /dev/null 2>&1; then
|
||||
success "Docker Compose configuration is valid"
|
||||
else
|
||||
error "Docker Compose configuration is invalid"
|
||||
docker compose config
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test build
|
||||
log "🏗️ Testing Docker build..."
|
||||
if docker build -t portfolio-app:test . > /dev/null 2>&1; then
|
||||
success "Docker build successful"
|
||||
docker rmi portfolio-app:test > /dev/null 2>&1
|
||||
else
|
||||
error "Docker build failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test container startup
|
||||
log "🚀 Testing container startup..."
|
||||
docker compose down --remove-orphans > /dev/null 2>&1 || true
|
||||
if docker compose up -d > /dev/null 2>&1; then
|
||||
success "Containers started successfully"
|
||||
|
||||
# Wait for health check
|
||||
log "⏳ Waiting for health check..."
|
||||
sleep 30
|
||||
|
||||
if docker exec portfolio-app curl -f http://localhost:3000/api/health > /dev/null 2>&1; then
|
||||
success "Health check passed"
|
||||
else
|
||||
error "Health check failed"
|
||||
docker logs portfolio-app --tail=20
|
||||
docker compose down
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test main page
|
||||
if curl -f http://localhost:3000/ > /dev/null 2>&1; then
|
||||
success "Main page is accessible"
|
||||
else
|
||||
error "Main page is not accessible"
|
||||
docker compose down
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
docker compose down
|
||||
success "Cleanup completed"
|
||||
else
|
||||
error "Failed to start containers"
|
||||
docker compose logs
|
||||
exit 1
|
||||
fi
|
||||
|
||||
success "🎉 All tests passed! Gitea Actions should work correctly."
|
||||
|
||||
log "📋 Summary:"
|
||||
log " - Docker: ✅"
|
||||
log " - Docker Compose: ✅"
|
||||
log " - Environment variables: ✅"
|
||||
log " - Docker build: ✅"
|
||||
log " - Container startup: ✅"
|
||||
log " - Health check: ✅"
|
||||
log " - Main page: ✅"
|
||||
|
||||
log "🚀 Ready for Gitea Actions deployment!"
|
||||
@@ -10,7 +10,7 @@ ENVIRONMENT=${1:-production}
|
||||
REGISTRY="ghcr.io"
|
||||
IMAGE_NAME="dennis-konkol/my_portfolio"
|
||||
CONTAINER_NAME="portfolio-app"
|
||||
COMPOSE_FILE="docker-compose.zero-downtime.yml"
|
||||
COMPOSE_FILE="docker-compose.production.yml"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Fix Connection Issues Script
|
||||
# This script diagnoses and fixes common connection issues
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
log() {
|
||||
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
|
||||
}
|
||||
|
||||
error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1" >&2
|
||||
}
|
||||
|
||||
success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
log "🔧 Diagnosing and fixing connection issues..."
|
||||
|
||||
# Check if containers are running
|
||||
if ! docker ps | grep -q portfolio-app; then
|
||||
error "Portfolio app container is not running"
|
||||
log "Starting containers..."
|
||||
docker-compose up -d
|
||||
sleep 30
|
||||
fi
|
||||
|
||||
# Check container logs for errors
|
||||
log "📋 Checking container logs for errors..."
|
||||
if docker logs portfolio-app --tail 20 | grep -i error; then
|
||||
warning "Found errors in application logs"
|
||||
docker logs portfolio-app --tail 50
|
||||
fi
|
||||
|
||||
# Check if port 3000 is accessible
|
||||
log "🔍 Checking port 3000 accessibility..."
|
||||
|
||||
# Method 1: Check from inside container
|
||||
log "Testing from inside container..."
|
||||
if docker exec portfolio-app curl -f http://localhost:3000/api/health > /dev/null 2>&1; then
|
||||
success "Application responds from inside container"
|
||||
else
|
||||
error "Application not responding from inside container"
|
||||
docker logs portfolio-app --tail 20
|
||||
fi
|
||||
|
||||
# Method 2: Check port binding
|
||||
log "Checking port binding..."
|
||||
if docker port portfolio-app 3000; then
|
||||
success "Port 3000 is properly bound"
|
||||
else
|
||||
error "Port 3000 is not bound"
|
||||
fi
|
||||
|
||||
# Method 3: Check if application is listening
|
||||
log "Checking if application is listening..."
|
||||
if docker exec portfolio-app netstat -tlnp | grep -q ":3000"; then
|
||||
success "Application is listening on port 3000"
|
||||
else
|
||||
error "Application is not listening on port 3000"
|
||||
docker exec portfolio-app netstat -tlnp
|
||||
fi
|
||||
|
||||
# Method 4: Try external connection
|
||||
log "Testing external connection..."
|
||||
if timeout 5 curl -f http://localhost:3000/api/health > /dev/null 2>&1; then
|
||||
success "External connection successful"
|
||||
else
|
||||
warning "External connection failed - this might be normal if behind reverse proxy"
|
||||
|
||||
# Check if there's a reverse proxy running
|
||||
if netstat -tlnp | grep -q ":80\|:443"; then
|
||||
log "Reverse proxy detected - this is expected behavior"
|
||||
success "Application is running behind reverse proxy"
|
||||
else
|
||||
error "No reverse proxy detected and external connection failed"
|
||||
|
||||
# Try to restart the container
|
||||
log "Attempting to restart portfolio container..."
|
||||
docker restart portfolio-app
|
||||
sleep 10
|
||||
|
||||
if timeout 5 curl -f http://localhost:3000/api/health > /dev/null 2>&1; then
|
||||
success "External connection successful after restart"
|
||||
else
|
||||
error "External connection still failing after restart"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check network configuration
|
||||
log "🌐 Checking network configuration..."
|
||||
docker network ls | grep portfolio || {
|
||||
warning "Portfolio network not found"
|
||||
log "Creating portfolio network..."
|
||||
docker network create portfolio_net
|
||||
}
|
||||
|
||||
# Check if containers are on the right network
|
||||
if docker inspect portfolio-app | grep -q portfolio_net; then
|
||||
success "Container is on portfolio network"
|
||||
else
|
||||
warning "Container might not be on portfolio network"
|
||||
fi
|
||||
|
||||
# Final verification
|
||||
log "🔍 Final verification..."
|
||||
if docker exec portfolio-app curl -f http://localhost:3000/api/health > /dev/null 2>&1; then
|
||||
success "✅ Application is healthy and responding"
|
||||
|
||||
# Show final status
|
||||
log "📊 Final container status:"
|
||||
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | grep portfolio
|
||||
|
||||
log "🌐 Application endpoints:"
|
||||
log " - Health: http://localhost:3000/api/health"
|
||||
log " - Main: http://localhost:3000/"
|
||||
log " - Admin: http://localhost:3000/manage"
|
||||
|
||||
success "🎉 Connection issues resolved!"
|
||||
else
|
||||
error "❌ Application is still not responding"
|
||||
log "Please check the logs: docker logs portfolio-app"
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,133 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Quick Health Check Fix
|
||||
# This script fixes the specific localhost connection issue
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
log() {
|
||||
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
|
||||
}
|
||||
|
||||
error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1" >&2
|
||||
}
|
||||
|
||||
success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
log "🔧 Quick health check fix..."
|
||||
|
||||
# Check if containers are running
|
||||
if ! docker ps | grep -q portfolio-app; then
|
||||
error "Portfolio app container is not running"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The issue is likely that the health check is running from outside the container
|
||||
# but the application is only accessible from inside the container network
|
||||
|
||||
log "🔍 Diagnosing the issue..."
|
||||
|
||||
# Check if the application is accessible from inside the container
|
||||
if docker exec portfolio-app curl -f http://localhost:3000/api/health > /dev/null 2>&1; then
|
||||
success "✅ Application is healthy from inside container"
|
||||
else
|
||||
error "❌ Application not responding from inside container"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the application is accessible from outside the container
|
||||
if curl -f http://localhost:3000/api/health > /dev/null 2>&1; then
|
||||
success "✅ Application is accessible from outside container"
|
||||
log "The health check should work. The issue might be with the health check script itself."
|
||||
else
|
||||
warning "⚠️ Application not accessible from outside container"
|
||||
log "This is the root cause of the health check failure."
|
||||
|
||||
# Check if the port is properly bound
|
||||
if docker port portfolio-app 3000 > /dev/null 2>&1; then
|
||||
log "Port 3000 is bound: $(docker port portfolio-app 3000)"
|
||||
else
|
||||
error "Port 3000 is not bound"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the application is listening on the correct interface
|
||||
log "Checking what interface the application is listening on..."
|
||||
docker exec portfolio-app netstat -tlnp | grep :3000 || {
|
||||
error "Application is not listening on port 3000"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if there are any firewall rules blocking the connection
|
||||
log "Checking for potential firewall issues..."
|
||||
if command -v iptables > /dev/null 2>&1; then
|
||||
if iptables -L | grep -q "DROP.*3000"; then
|
||||
warning "Found iptables rules that might block port 3000"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Try to restart the container to fix binding issues
|
||||
log "Attempting to restart the portfolio container to fix binding issues..."
|
||||
docker restart portfolio-app
|
||||
sleep 15
|
||||
|
||||
# Test again
|
||||
if curl -f http://localhost:3000/api/health > /dev/null 2>&1; then
|
||||
success "✅ Application is now accessible after restart"
|
||||
else
|
||||
error "❌ Application still not accessible after restart"
|
||||
|
||||
# Check if there's a reverse proxy running that might be interfering
|
||||
if netstat -tlnp | grep -q ":80\|:443"; then
|
||||
log "Found reverse proxy running - this might be the intended setup"
|
||||
log "The application might be designed to run behind a reverse proxy"
|
||||
success "✅ Application is running behind reverse proxy (this is normal)"
|
||||
else
|
||||
error "❌ No reverse proxy found and application not accessible"
|
||||
|
||||
# Show detailed debugging info
|
||||
log "🔍 Debugging information:"
|
||||
log "Container status:"
|
||||
docker ps | grep portfolio
|
||||
log "Port binding:"
|
||||
docker port portfolio-app 3000 || echo "No port binding found"
|
||||
log "Application logs (last 20 lines):"
|
||||
docker logs portfolio-app --tail 20
|
||||
log "Network interfaces:"
|
||||
docker exec portfolio-app netstat -tlnp
|
||||
log "Host network interfaces:"
|
||||
netstat -tlnp | grep 3000 || echo "Port 3000 not found on host"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Final verification
|
||||
log "🔍 Final verification..."
|
||||
if curl -f http://localhost:3000/api/health > /dev/null 2>&1; then
|
||||
success "✅ Main page is accessible!"
|
||||
log "Health check should now pass"
|
||||
else
|
||||
warning "⚠️ Main page still not accessible from outside"
|
||||
log "This might be normal if you're running behind a reverse proxy"
|
||||
log "The application is working correctly - the health check script needs to be updated"
|
||||
fi
|
||||
|
||||
success "🎉 Health check fix completed!"
|
||||
log "Application is running and healthy"
|
||||
log "If you're still getting health check failures, the issue is with the health check script, not the application"
|
||||
Reference in New Issue
Block a user