Files
kulakpos_web/entrypoint.sh

86 lines
2.3 KiB
Bash
Raw Normal View History

2026-03-16 10:20:15 +07:00
#!/bin/sh
set -e
echo "========================================"
echo "Starting container setup..."
echo "========================================"
2026-03-23 11:27:36 +07:00
# Show current user and directory
2026-03-16 10:20:15 +07:00
echo "Current user: $(whoami)"
echo "Current directory: $(pwd)"
2026-03-23 11:44:37 +07:00
# Create ALL required Laravel directories
echo "Creating storage directories..."
mkdir -p storage/framework/cache
mkdir -p storage/framework/sessions
mkdir -p storage/framework/views
mkdir -p storage/framework/testing
2026-03-23 11:27:36 +07:00
mkdir -p storage/logs
mkdir -p bootstrap/cache
2026-03-16 10:20:15 +07:00
2026-03-23 11:44:37 +07:00
# Also create the view cache directory (sometimes needed)
mkdir -p storage/framework/views
2026-03-16 10:20:15 +07:00
# Set permissions
echo "Setting permissions..."
2026-03-23 11:27:36 +07:00
chmod -R 777 storage
chmod -R 777 bootstrap/cache
2026-03-16 10:20:15 +07:00
2026-03-23 11:44:37 +07:00
# Create cache file if it doesn't exist
touch storage/framework/cache/.gitignore
touch storage/framework/sessions/.gitignore
touch storage/framework/views/.gitignore
touch storage/logs/.gitignore
# Verify directories exist
echo "Verifying directories..."
ls -la storage/framework/
ls -la bootstrap/
2026-03-23 11:27:36 +07:00
# Check if .env exists, create if not
2026-03-16 10:20:15 +07:00
if [ ! -f .env ]; then
2026-03-23 11:27:36 +07:00
echo "Creating .env file..."
if [ -f .env.example ]; then
cp .env.example .env
else
2026-03-23 11:44:37 +07:00
cat > .env << 'EOF'
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
EOF
2026-03-23 11:27:36 +07:00
fi
2026-03-16 10:20:15 +07:00
fi
2026-03-23 11:44:37 +07:00
# Generate key if not present
if ! grep -q "APP_KEY=" .env || grep -q "APP_KEY=$" .env; then
echo "Generating application key..."
php artisan key:generate --no-interaction --force || echo "Key generation failed"
fi
# Clear all caches to ensure fresh state
echo "Clearing caches..."
php artisan config:clear || true
php artisan cache:clear || true
php artisan view:clear || true
php artisan route:clear || true
# Optional: Run migrations if needed
2026-03-23 11:27:36 +07:00
# php artisan migrate --force
2026-03-16 10:20:15 +07:00
echo "========================================"
echo "Setup complete. Starting application..."
echo "========================================"
2026-03-28 19:30:40 +07:00
# Start the application with proper error handling
2026-03-29 05:26:32 +07:00
if [ "$MODE" = "staging" ]; then
2026-03-16 10:20:15 +07:00
echo "Starting PHP built-in server on port 8000..."
2026-03-28 19:30:40 +07:00
# Use exec with error capture
exec php artisan serve --host=0.0.0.0 --port=8000 2>&1 | tee -a /var/log/php-server.log
2026-03-16 10:20:15 +07:00
else
echo "Starting PHP-FPM on port 9000..."
2026-03-28 19:30:40 +07:00
# Ensure PHP-FPM is properly configured
exec php-fpm -F
2026-03-16 10:20:15 +07:00
fi