fix production
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m9s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 15s
Build, Push and Deploy / deploy-staging (push) Successful in 38s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m9s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 15s
Build, Push and Deploy / deploy-staging (push) Successful in 38s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
This commit is contained in:
@@ -215,7 +215,7 @@ jobs:
|
|||||||
-e MODE=production \
|
-e MODE=production \
|
||||||
-e APP_ENV=production \
|
-e APP_ENV=production \
|
||||||
-e APP_DEBUG=false \
|
-e APP_DEBUG=false \
|
||||||
-e APP_URL=https://prod-test.kulakpos.id \
|
-e AUTO_MIGRATE=false \
|
||||||
kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:$IMAGE_TAG
|
kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:$IMAGE_TAG
|
||||||
|
|
||||||
# Wait for container to be ready
|
# Wait for container to be ready
|
||||||
@@ -261,6 +261,7 @@ jobs:
|
|||||||
-e MODE=production \
|
-e MODE=production \
|
||||||
-e APP_ENV=production \
|
-e APP_ENV=production \
|
||||||
-e APP_DEBUG=false \
|
-e APP_DEBUG=false \
|
||||||
|
-e AUTO_MIGRATE=false \
|
||||||
$PREVIOUS_IMAGE
|
$PREVIOUS_IMAGE
|
||||||
echo "Rollback completed"
|
echo "Rollback completed"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -9,9 +9,14 @@ echo "========================================"
|
|||||||
echo "Current user: $(whoami)"
|
echo "Current user: $(whoami)"
|
||||||
echo "Current directory: $(pwd)"
|
echo "Current directory: $(pwd)"
|
||||||
|
|
||||||
# Force debug mode for troubleshooting
|
# Set debug based on environment
|
||||||
|
if [ "$APP_ENV" = "production" ]; then
|
||||||
|
export APP_DEBUG=false
|
||||||
|
export LOG_LEVEL=error
|
||||||
|
else
|
||||||
export APP_DEBUG=true
|
export APP_DEBUG=true
|
||||||
export LOG_LEVEL=debug
|
export LOG_LEVEL=debug
|
||||||
|
fi
|
||||||
|
|
||||||
# Create ALL required Laravel directories
|
# Create ALL required Laravel directories
|
||||||
echo "Creating storage directories..."
|
echo "Creating storage directories..."
|
||||||
@@ -62,7 +67,6 @@ fi
|
|||||||
echo "Checking .env for APP_KEY..."
|
echo "Checking .env for APP_KEY..."
|
||||||
if ! grep -E "APP_KEY=.{10,}" .env; then
|
if ! grep -E "APP_KEY=.{10,}" .env; then
|
||||||
echo "APP_KEY is empty or missing. Generating..."
|
echo "APP_KEY is empty or missing. Generating..."
|
||||||
echo "Generating application key..."
|
|
||||||
# If the file doesn't have APP_KEY= at all, add it so artisan can replace it
|
# If the file doesn't have APP_KEY= at all, add it so artisan can replace it
|
||||||
if ! grep -q "APP_KEY=" .env; then
|
if ! grep -q "APP_KEY=" .env; then
|
||||||
echo "Appending APP_KEY= placeholder..."
|
echo "Appending APP_KEY= placeholder..."
|
||||||
@@ -80,7 +84,7 @@ echo "Verifying and synchronizing Composer dependencies..."
|
|||||||
# Run composer install to physically ensure all files (like laravel/prompts) are present in the volume
|
# Run composer install to physically ensure all files (like laravel/prompts) are present in the volume
|
||||||
composer install --no-interaction --optimize-autoloader
|
composer install --no-interaction --optimize-autoloader
|
||||||
|
|
||||||
# FIX: Ensure all generated/downloaded files are fully readable and executable by PHP-FPM
|
# FIX: Ensure all generated/downloaded files are fully readable and executable
|
||||||
echo "Setting correct ownership for web server..."
|
echo "Setting correct ownership for web server..."
|
||||||
chown -R www-data:www-data vendor
|
chown -R www-data:www-data vendor
|
||||||
chmod -R 755 vendor
|
chmod -R 755 vendor
|
||||||
@@ -91,13 +95,22 @@ ls -la /var/www/html/vendor/laravel/prompts/src/helpers.php
|
|||||||
php -r 'if (file_exists("/var/www/html/vendor/laravel/prompts/src/helpers.php")) { echo "✅ file_exists true\n"; }'
|
php -r 'if (file_exists("/var/www/html/vendor/laravel/prompts/src/helpers.php")) { echo "✅ file_exists true\n"; }'
|
||||||
php -r 'require "/var/www/html/vendor/laravel/prompts/src/helpers.php"; echo "✅ PHP successfully REQUIRED helpers.php\n";'
|
php -r 'require "/var/www/html/vendor/laravel/prompts/src/helpers.php"; echo "✅ PHP successfully REQUIRED helpers.php\n";'
|
||||||
|
|
||||||
# Clear all caches to ensure fresh state
|
# Run production optimizations for production environment
|
||||||
|
if [ "$APP_ENV" = "production" ] || [ "$MODE" = "production" ]; then
|
||||||
|
echo "Running production optimizations..."
|
||||||
|
php artisan config:cache
|
||||||
|
php artisan route:cache
|
||||||
|
php artisan view:cache
|
||||||
|
php artisan event:cache
|
||||||
|
else
|
||||||
|
# Clear all caches to ensure fresh state for non-production
|
||||||
echo "Clearing caches..."
|
echo "Clearing caches..."
|
||||||
php artisan config:clear || true
|
php artisan config:clear || true
|
||||||
php artisan view:clear || true
|
php artisan view:clear || true
|
||||||
php artisan route:clear || true
|
php artisan route:clear || true
|
||||||
php artisan cache:clear || true
|
php artisan cache:clear || true
|
||||||
php artisan optimize:clear || true
|
php artisan optimize:clear || true
|
||||||
|
fi
|
||||||
|
|
||||||
# Verify Vite manifest exists
|
# Verify Vite manifest exists
|
||||||
if [ -f public/build/manifest.json ]; then
|
if [ -f public/build/manifest.json ]; then
|
||||||
@@ -108,20 +121,29 @@ else
|
|||||||
ls -la public/build/ 2>/dev/null || echo "public/build directory does not exist"
|
ls -la public/build/ 2>/dev/null || echo "public/build directory does not exist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Optional: Run migrations if needed
|
# Optional: Run migrations if needed (with safety for production)
|
||||||
# php artisan migrate --force
|
if [ "$AUTO_MIGRATE" = "true" ] || [ "$APP_ENV" != "production" ]; then
|
||||||
|
echo "Running migrations..."
|
||||||
|
php artisan migrate --force
|
||||||
|
fi
|
||||||
|
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
echo "Setup complete. Starting application..."
|
echo "Setup complete. Starting application..."
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
|
|
||||||
# Start the application with proper error handling
|
# Start the application based on environment
|
||||||
if [ "$MODE" = "staging" ]; then
|
if [ "$APP_ENV" = "production" ] || [ "$MODE" = "production" ]; then
|
||||||
echo "Starting DIRECT PHP server on port 8000 (Bypassing artisan serve)..."
|
echo "Starting PHP built-in server on port 8000 (Production mode)..."
|
||||||
|
echo "Document root: /var/www/html/public"
|
||||||
|
echo "Workers: Single-threaded PHP server (use Nginx for production scaling)"
|
||||||
|
# Use direct php -S for production (optimized)
|
||||||
|
exec php -d opcache.enable=1 -d opcache.memory_consumption=128 -d opcache.max_accelerated_files=10000 -S 0.0.0.0:8000 -t public
|
||||||
|
elif [ "$MODE" = "staging" ]; then
|
||||||
|
echo "Starting PHP built-in server on port 8000 (Staging mode)..."
|
||||||
# Use direct php -S to eliminate any artisan wrapper issues
|
# Use direct php -S to eliminate any artisan wrapper issues
|
||||||
exec php -d opcache.enable=0 -S 0.0.0.0:8000 -t public server.php 2>&1 | tee -a /var/log/php-server.log
|
exec php -d opcache.enable=0 -S 0.0.0.0:8000 -t public
|
||||||
else
|
else
|
||||||
echo "Starting PHP-FPM on port 9000..."
|
echo "Starting PHP-FPM on port 9000 (Development mode)..."
|
||||||
# Ensure PHP-FPM is properly configured
|
# Ensure PHP-FPM is properly configured
|
||||||
exec php-fpm -F
|
exec php-fpm -F
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user