fix: Gitea Traefik routing and connection pool optimization
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 10m14s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Has been skipped
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Security Vulnerability Scan / Check for Dependency Changes (push) Failing after 11m25s
Security Vulnerability Scan / Composer Security Audit (push) Has been cancelled
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 10m14s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Has been skipped
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Security Vulnerability Scan / Check for Dependency Changes (push) Failing after 11m25s
Security Vulnerability Scan / Composer Security Audit (push) Has been cancelled
- Remove middleware reference from Gitea Traefik labels (caused routing issues) - Optimize Gitea connection pool settings (MAX_IDLE_CONNS=30, authentication_timeout=180s) - Add explicit service reference in Traefik labels - Fix intermittent 504 timeouts by improving PostgreSQL connection handling Fixes Gitea unreachability via git.michaelschiemer.de
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
# Don't use 'set -e' globally - we'll handle errors explicitly for critical operations
|
||||
# This allows non-critical operations (like permission changes) to fail without crashing the container
|
||||
|
||||
echo "=========================================="
|
||||
echo "🚀 Container Entrypoint Starting"
|
||||
echo "=========================================="
|
||||
echo "Command: $@"
|
||||
echo "Working directory: $(pwd)"
|
||||
echo "User: $(whoami)"
|
||||
echo ""
|
||||
|
||||
echo "🔐 Loading secrets..."
|
||||
|
||||
@@ -109,20 +118,134 @@ echo ""
|
||||
echo "📊 Environment variables:"
|
||||
env | grep -E "DB_|APP_" | grep -Ev "(PASSWORD|KEY|SECRET)" || true
|
||||
|
||||
echo ""
|
||||
echo "📂 Checking application directory structure..."
|
||||
if [ -d "/var/www/html" ]; then
|
||||
echo "✅ /var/www/html exists"
|
||||
echo " Contents: $(ls -la /var/www/html 2>/dev/null | head -5 | wc -l) items"
|
||||
if [ -f "/var/www/html/composer.json" ]; then
|
||||
echo "✅ composer.json found"
|
||||
else
|
||||
echo "⚠️ Warning: composer.json not found in /var/www/html"
|
||||
fi
|
||||
if [ -f "/var/www/html/public/index.php" ] || [ -f "/var/www/html/index.php" ]; then
|
||||
echo "✅ Application entry point found"
|
||||
else
|
||||
echo "⚠️ Warning: Application entry point (index.php) not found"
|
||||
fi
|
||||
else
|
||||
echo "❌ ERROR: /var/www/html does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🛠️ Adjusting filesystem permissions..."
|
||||
chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache 2>/dev/null || true
|
||||
find /var/www/html/storage /var/www/html/bootstrap/cache -type d -exec chmod 775 {} \; 2>/dev/null || true
|
||||
find /var/www/html/storage /var/www/html/bootstrap/cache -type f -exec chmod 664 {} \; 2>/dev/null || true
|
||||
|
||||
# Non-critical operations - don't fail if these don't work
|
||||
if ! chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache 2>/dev/null; then
|
||||
echo "⚠️ Warning: Failed to change ownership of storage/cache directories (may be volume mounts)"
|
||||
fi
|
||||
|
||||
if ! find /var/www/html/storage /var/www/html/bootstrap/cache -type d -exec chmod 775 {} \; 2>/dev/null; then
|
||||
echo "⚠️ Warning: Failed to set directory permissions"
|
||||
fi
|
||||
|
||||
if ! find /var/www/html/storage /var/www/html/bootstrap/cache -type f -exec chmod 664 {} \; 2>/dev/null; then
|
||||
echo "⚠️ Warning: Failed to set file permissions"
|
||||
fi
|
||||
|
||||
# Verify required directories exist
|
||||
echo ""
|
||||
echo "📁 Verifying required directories..."
|
||||
REQUIRED_DIRS=(
|
||||
"/var/www/html"
|
||||
"/var/www/html/storage"
|
||||
"/var/www/html/bootstrap"
|
||||
"/var/www/html/bootstrap/cache"
|
||||
)
|
||||
|
||||
for dir in "${REQUIRED_DIRS[@]}"; do
|
||||
if [ ! -d "$dir" ]; then
|
||||
echo "⚠️ Warning: Required directory $dir does not exist, creating..."
|
||||
mkdir -p "$dir" 2>/dev/null || echo "❌ Failed to create $dir"
|
||||
fi
|
||||
done
|
||||
|
||||
# Start PHP-FPM in background (inherits all environment variables)
|
||||
echo ""
|
||||
echo "🚀 Starting PHP-FPM..."
|
||||
php-fpm &
|
||||
|
||||
# Wait for PHP-FPM to be ready
|
||||
sleep 2
|
||||
# Check if PHP-FPM binary exists
|
||||
if ! command -v php-fpm &> /dev/null; then
|
||||
echo "❌ ERROR: php-fpm command not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start PHP-FPM and capture its PID
|
||||
php-fpm &
|
||||
PHP_FPM_PID=$!
|
||||
|
||||
# Wait for PHP-FPM to be ready and verify it's running
|
||||
echo "⏳ Waiting for PHP-FPM to start..."
|
||||
MAX_WAIT=10
|
||||
WAIT_COUNT=0
|
||||
while [ $WAIT_COUNT -lt $MAX_WAIT ]; do
|
||||
if kill -0 $PHP_FPM_PID 2>/dev/null; then
|
||||
# Check if PHP-FPM is listening on the socket
|
||||
if [ -S /var/run/php/php-fpm.sock ] || [ -S /run/php/php-fpm.sock ] || netstat -tuln 2>/dev/null | grep -q ":9000"; then
|
||||
echo "✅ PHP-FPM is running (PID: $PHP_FPM_PID)"
|
||||
break
|
||||
fi
|
||||
else
|
||||
echo "❌ ERROR: PHP-FPM process died immediately after startup!"
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
WAIT_COUNT=$((WAIT_COUNT + 1))
|
||||
done
|
||||
|
||||
if [ $WAIT_COUNT -ge $MAX_WAIT ]; then
|
||||
echo "⚠️ Warning: PHP-FPM may not be fully ready after ${MAX_WAIT}s, but continuing..."
|
||||
echo " This may indicate a configuration issue. Check PHP-FPM logs if problems occur."
|
||||
fi
|
||||
|
||||
# Log PHP-FPM status
|
||||
echo ""
|
||||
echo "📋 PHP-FPM Status:"
|
||||
if kill -0 $PHP_FPM_PID 2>/dev/null; then
|
||||
echo " Process: Running (PID: $PHP_FPM_PID)"
|
||||
if [ -S /var/run/php/php-fpm.sock ]; then
|
||||
echo " Socket: /var/run/php/php-fpm.sock (exists)"
|
||||
elif [ -S /run/php/php-fpm.sock ]; then
|
||||
echo " Socket: /run/php/php-fpm.sock (exists)"
|
||||
elif netstat -tuln 2>/dev/null | grep -q ":9000"; then
|
||||
echo " Socket: TCP port 9000 (listening)"
|
||||
else
|
||||
echo " Socket: Not found (may be using different configuration)"
|
||||
fi
|
||||
else
|
||||
echo " Process: Not running (PID check failed)"
|
||||
fi
|
||||
|
||||
# Verify nginx binary exists
|
||||
if ! command -v nginx &> /dev/null; then
|
||||
echo "❌ ERROR: nginx command not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test nginx configuration before starting
|
||||
echo ""
|
||||
echo "🔍 Testing nginx configuration..."
|
||||
if ! nginx -t 2>&1; then
|
||||
echo "❌ ERROR: nginx configuration test failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start nginx in foreground (inherits all environment variables)
|
||||
echo ""
|
||||
echo "🚀 Starting nginx..."
|
||||
echo "=========================================="
|
||||
echo "✅ All startup checks passed"
|
||||
echo "🚀 Services starting..."
|
||||
echo "=========================================="
|
||||
exec nginx -g 'daemon off;'
|
||||
|
||||
Reference in New Issue
Block a user