Files
michaelschiemer/deployment
Michael Schiemer c8b47e647d feat(Docker): Upgrade to PHP 8.5.0RC3 with native ext-uri support
BREAKING CHANGE: Requires PHP 8.5.0RC3

Changes:
- Update Docker base image from php:8.4-fpm to php:8.5.0RC3-fpm
- Enable ext-uri for native WHATWG URL parsing support
- Update composer.json PHP requirement from ^8.4 to ^8.5
- Add ext-uri as required extension in composer.json
- Move URL classes from Url.php85/ to Url/ directory (now compatible)
- Remove temporary PHP 8.4 compatibility workarounds

Benefits:
- Native URL parsing with Uri\WhatWg\Url class
- Better performance for URL operations
- Future-proof with latest PHP features
- Eliminates PHP version compatibility issues
2025-10-27 09:31:28 +01:00
..

Custom PHP Framework Deployment System

Complete deployment automation system for the Custom PHP Framework with infrastructure provisioning and application deployment.

Project Information

🚀 Quick Start

# First-time setup
./setup.sh

# Deploy to staging
make deploy-staging

# Deploy to production
make deploy-production

Architecture

The deployment system uses a hybrid approach combining:

  • Ansible for infrastructure provisioning (security, Docker, Nginx, SSL)
  • Docker Compose for application deployment (PHP 8.4, database, assets)
  • Automation Scripts for orchestrated deployment workflows

Directory Structure

deployment/
├── deploy.sh                   # Main deployment orchestrator
├── setup.sh                    # First-time environment setup
├── Makefile                    # Convenient deployment commands
├── docs/                       # Documentation
│   ├── QUICKSTART.md          # Quick start guide
│   ├── ENVIRONMENTS.md        # Environment configuration
│   └── TROUBLESHOOTING.md     # Troubleshooting guide
├── infrastructure/             # Ansible infrastructure provisioning
│   ├── inventories/           # Environment-specific inventories
│   │   ├── development/       # Development inventory
│   │   ├── staging/           # Staging inventory
│   │   └── production/        # Production inventory
│   ├── roles/                 # Reusable Ansible roles
│   │   ├── base-security/     # Security hardening
│   │   ├── docker-runtime/    # Docker and PHP 8.4 setup
│   │   ├── nginx-proxy/       # Nginx reverse proxy with SSL
│   │   └── monitoring/        # System monitoring
│   ├── playbooks/             # Infrastructure playbooks
│   ├── group_vars/            # Environment variables
│   └── site.yml               # Main infrastructure playbook
└── applications/              # Docker Compose application deployment
    ├── docker-compose.*.yml   # Environment overlays
    ├── environments/          # Environment configurations
    │   ├── .env.production.template  # Production settings template
    │   └── .env.staging.template     # Staging settings template
    └── scripts/               # Application deployment scripts
        ├── deploy-app.sh      # Main application deployment script
        └── health-check.sh    # Post-deployment health validation

Features

🔒 Security First

  • Automated security hardening with fail2ban and UFW firewall
  • SSL certificates with Let's Encrypt integration
  • IP-based authentication for admin routes
  • OWASP security event logging
  • Secure password generation and management

Performance Optimized

  • PHP 8.4 with OPcache and performance tuning
  • Nginx reverse proxy with optimization
  • Database connection pooling and query optimization
  • Asset optimization with Vite build system
  • Health checks and monitoring

🛠️ Developer Friendly

  • One-command deployment with make deploy-staging
  • Dry-run mode for testing deployments
  • Comprehensive logging and error handling
  • Database backups and rollback capabilities
  • Multi-environment support

🌍 Production Ready

  • Zero-downtime deployments
  • Automated database migrations
  • Health checks and validation
  • Emergency stop/restart procedures
  • Monitoring and alerting setup

Available Commands

Main Deployment Commands

make deploy-staging           # Deploy to staging
make deploy-production        # Deploy to production
make deploy-dry ENV=production # Dry run deployment
make infrastructure ENV=staging # Deploy only infrastructure
make application ENV=staging  # Deploy only application

Management Commands

make status ENV=staging       # Check deployment status
make health ENV=production    # Run health checks
make logs ENV=staging         # View application logs
make backup ENV=production    # Create database backup
make restore ENV=production   # Restore from backup

Configuration Commands

make init-config             # Initialize configuration files
make edit-config ENV=staging # Edit environment configuration
make validate-config ENV=prod # Validate configuration
make show-config ENV=staging # Show safe configuration values

Emergency Commands

make emergency-stop ENV=staging    # Emergency stop all services
make emergency-restart ENV=prod    # Emergency restart services
make rollback ENV=production       # Emergency rollback

Environment Configuration

The system supports three environments:

  • Development: Local development with relaxed security
  • Staging: Pre-production testing with production-like settings
  • Production: Live production with maximum security and performance

Each environment has its own:

  • Docker Compose overlay configuration
  • Environment variables file
  • Ansible inventory
  • SSL certificate configuration

Deployment Flow

  1. Validation: Prerequisites, configuration, and test validation
  2. Infrastructure: Ansible deploys security, Docker, Nginx, SSL
  3. Application: Docker Compose deploys PHP app, database, assets
  4. Health Checks: Comprehensive deployment validation

Safety Features

  • Production Confirmations: Double confirmation for production deployments
  • Automated Backups: Database backups before deployment
  • Dry Run Mode: Test deployments without making changes
  • Health Validation: Verify deployment success before completion
  • Rollback Capability: Emergency rollback procedures
  • Error Handling: Comprehensive error handling and logging

Getting Started

  1. First-Time Setup:

    ./setup.sh
    
  2. Configure Environments:

    make init-config
    make edit-config ENV=staging
    
  3. Test Deployment:

    make deploy-dry ENV=staging
    
  4. Deploy to Staging:

    make deploy-staging
    
  5. Deploy to Production:

    make deploy-production
    

Documentation

Migration from Old System

The old deployment configurations have been preserved in .deployment-backup/ for reference. The new system provides:

  • Improved Security: Modern security practices and automated hardening
  • Better Organization: Clear separation between infrastructure and application
  • Enhanced Automation: One-command deployments with comprehensive validation
  • Multi-Environment: Proper staging and production environment management
  • Modern Stack: PHP 8.4, latest Docker practices, and optimized configurations

Support

For deployment issues or questions:

  1. Check the Troubleshooting Guide
  2. Run diagnostics: make status ENV=your-environment
  3. Review logs: make logs ENV=your-environment
  4. Test with dry-run: make deploy-dry ENV=your-environment

Domain: michaelschiemer.de | Email: kontakt@michaelschiemer.de | PHP: 8.4