Refactor Docker setup for Laravel 5.0 compatibility and optimize deployment process
- Updated Dockerfile configurations for various environments (alpine, basic, cloudrun, minimal, simple, test) to ensure compatibility with Laravel 5.0 and PHP 5.6. - Added PHP compatibility documentation outlining mcrypt requirements and upgrade paths. - Created cloudbuild.yaml for Google Cloud Build integration to streamline deployment to Cloud Run. - Introduced docker-compose.local.yml for local development with MySQL and Redis services. - Enhanced rebuild.sh script for easier local development and migration handling. - Updated Laravel Blade views to correct asset paths. - Added start-local.sh script for quick local setup and service management.
This commit is contained in:
100
PHP_COMPATIBILITY.md
Normal file
100
PHP_COMPATIBILITY.md
Normal file
@@ -0,0 +1,100 @@
|
||||
# Laravel 5.0 and PHP Compatibility Guide
|
||||
|
||||
## Issue: mcrypt Extension Required
|
||||
|
||||
Laravel 5.0 requires the `mcrypt` PHP extension, which was:
|
||||
|
||||
- **Deprecated** in PHP 7.1
|
||||
- **Removed** in PHP 7.2+
|
||||
|
||||
## Solutions
|
||||
|
||||
### Option 1: Use PHP 5.6 (Current Implementation)
|
||||
|
||||
The `Dockerfile.minimal` has been updated to use PHP 5.6 which is the ideal match for Laravel 5.0.
|
||||
|
||||
**Pros:**
|
||||
|
||||
- Perfect compatibility with Laravel 5.0
|
||||
- Native mcrypt support
|
||||
- All packages available and tested
|
||||
- Matches original development environment
|
||||
|
||||
**Cons:**
|
||||
|
||||
- PHP 5.6 reached end-of-life in December 2018
|
||||
- Security concerns for long-term production use
|
||||
|
||||
### Option 2: Upgrade Laravel (Recommended for Production)
|
||||
Upgrade to Laravel 5.5+ which doesn't require mcrypt.
|
||||
|
||||
```bash
|
||||
# Update composer.json
|
||||
"laravel/framework": "5.8.*"
|
||||
|
||||
# Remove mcrypt dependencies and update encryption
|
||||
php artisan key:generate
|
||||
```
|
||||
|
||||
### Option 3: Use OpenSSL Instead (Laravel 5.2+)
|
||||
If upgrading Laravel, update encryption configuration:
|
||||
|
||||
```php
|
||||
// config/app.php
|
||||
'cipher' => 'AES-256-CBC',
|
||||
```
|
||||
|
||||
## Current Docker Configuration
|
||||
|
||||
The Dockerfile now uses:
|
||||
|
||||
- **Base Image**: `php:5.6-apache`
|
||||
- **mcrypt Extension**: Native support (no installation issues)
|
||||
- **Other Extensions**: All Laravel 5.0 requirements met
|
||||
- **Package Compatibility**: Perfect match for PHP 5.6
|
||||
|
||||
## Production Recommendations
|
||||
|
||||
For a production deployment, consider:
|
||||
|
||||
1. **Upgrade Laravel** to 5.8 or later (LTS)
|
||||
2. **Use PHP 7.4+** for better performance and security
|
||||
3. **Replace mcrypt** with OpenSSL encryption
|
||||
|
||||
## Quick Upgrade Path (Optional)
|
||||
|
||||
If you want to modernize the application:
|
||||
|
||||
### Step 1: Update composer.json
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"laravel/framework": "5.8.*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Step 2: Update Dockerfile to use PHP 7.4
|
||||
```dockerfile
|
||||
FROM php:7.4-apache
|
||||
# Remove mcrypt installation
|
||||
```
|
||||
|
||||
### Step 3: Update configuration
|
||||
```bash
|
||||
php artisan key:generate
|
||||
php artisan config:cache
|
||||
```
|
||||
|
||||
## Security Note
|
||||
|
||||
Since PHP 7.1 is end-of-life, monitor for security updates and consider upgrading the Laravel version for long-term production use.
|
||||
|
||||
## Testing the Current Setup
|
||||
|
||||
The current configuration should work with:
|
||||
```bash
|
||||
./start-local.sh
|
||||
```
|
||||
|
||||
This will use PHP 7.1 with mcrypt support for Laravel 5.0 compatibility.
|
||||
Reference in New Issue
Block a user