upskill-event-manager/docs/deployment.md

8.5 KiB

Deployment Guide

This guide covers deploying the HVAC Trainer Network Events plugin to development and production environments.

Quick Start

# Deploy to development
./Users/ben/dev/upskill-event-manager/wordpress-dev/deploy.sh --config deploy-config.sh

# Deploy and run tests
./Users/ben/dev/upskill-event-manager/wordpress-dev/deploy.sh --config deploy-config.sh --run-tests

# Deploy to production
./Users/ben/dev/upskill-event-manager/wordpress-dev/deploy.sh --config deploy-config-production.sh

Plugin Dependencies

The HVAC Trainer Network Events plugin requires the following plugins:

  1. The Events Calendar (6.10.2 or higher)
  2. The Events Calendar Pro (7.4.2 or higher)
  3. Event Tickets (5.19.3 or higher)
  4. Event Tickets Plus (6.2.0 or higher)
  5. The Events Calendar: Community Events (latest version)
  6. Spectra Pro (2.0.0 or higher)
  7. Premium Starter Templates (4.4.14 or higher)
  8. Essential Blocks (5.3.2 or higher)

Important Notes:

  • Plugin versions are managed separately from deployment
  • Do not update plugins as part of deployment or testing
  • Plugin updates should be tested separately in a staging environment
  • Use the plugin management system of your hosting environment for updates

Configuration Files

Development Configuration

File: deploy-config.sh

REMOTE_HOST="upskill_wordpress"
REMOTE_USER="root"
WP_PATH="/var/www/html/"
PLUGIN_SLUG="network-events"
WP_CLI_PATH="wp"
PURGE_BREEZE_CACHE=false
USE_ROOT=true

Production Configuration

File: deploy-config-production.sh

  • Contains production-specific settings
  • Includes additional security measures
  • Requires SSH key configuration

Deployment Process

  1. Pre-deployment Checks

    • Verify dependencies
    • Run tests
    • Check file permissions
  2. Deployment Steps

    • Package plugin files
    • Transfer to target environment
    • Update WordPress configuration
    • Clear caches
  3. Post-deployment Verification

    • Check plugin activation
    • Verify functionality
    • Monitor error logs

Development Environment

Setup

# Start development environment
cd /Users/ben/dev/upskill-event-manager/wordpress-dev
./Users/ben/dev/upskill-event-manager/wordpress-dev/manage-env.sh start

# Stop development environment
./Users/ben/dev/upskill-event-manager/wordpress-dev/manage-env.sh stop

# Reset development environment
./Users/ben/dev/upskill-event-manager/wordpress-dev/manage-env.sh reset

Production Environment

Requirements

  • SSH access to production server
  • WordPress admin credentials
  • Appropriate file permissions

Deployment Steps

  1. Configure SSH access
  2. Update production configuration
  3. Run deployment script
  4. Verify deployment

Staging Environment

The staging environment on Cloudways serves as a pre-production testing platform. It includes dedicated configuration, deployment, and testing procedures.

Environment Setup

  1. Configure Environment Variables
# Required in .env file
UPSKILL_STAGING_URL=https://wordpress-974670-5399585.cloudwaysapps.com/
UPSKILL_STAGING_IP=146.190.76.204
UPSKILL_STAGING_SSH_USER=roodev
UPSKILL_STAGING_PASS=<password>
UPSKILL_STAGING_PATH=/home/974670.cloudwaysapps.com/uberrxmprk/public_html
UPSKILL_STAGING_DB_NAME=uberrxmprk
UPSKILL_STAGING_DB_USER=uberrxmprk
UPSKILL_STAGING_DB_PASSWORD=<password>
  1. Deploy Configuration
# Deploy configuration files
./bin/deploy-config-staging.sh

# Verify deployment
./bin/verify-staging.sh
  1. Configure Test Environment
# Set up test configuration
./bin/configure-staging-tests.sh

# Run initial tests
./bin/run-staging-unit-tests.sh

Deployment Process

  1. Pre-deployment
# Verify staging environment
./bin/verify-staging.sh

# Configure test environment
./bin/configure-staging-tests.sh

# Run tests before deployment
./bin/run-staging-tests.sh
  1. Deploy Plugin
# Deploy plugin files
./bin/deploy-plugin.sh --config wordpress-dev/deploy-config-staging.sh

# Verify deployment
./bin/verify-staging.sh --deployment
  1. Post-deployment
# Run tests after deployment
./bin/run-staging-tests.sh

# Check logs
./bin/verify-staging.sh --logs

Configuration Files

  1. deploy-config-staging.sh
REMOTE_HOST="${UPSKILL_STAGING_IP}"
REMOTE_USER="${UPSKILL_STAGING_SSH_USER}"
REMOTE_PATH_BASE="/home/974670.cloudwaysapps.com/uberrxmprk/public_html"
PLUGIN_SLUG="hvac-community-events"
REMOTE_PLUGIN_PATH="${REMOTE_PATH_BASE}/wp-content/plugins/${PLUGIN_SLUG}/"
LOCAL_PLUGIN_PATH="../wp-content/plugins/${PLUGIN_SLUG}/"
  1. wp-tests-config-staging.php
define('DB_NAME', 'uberrxmprk');
define('DB_USER', 'uberrxmprk');
define('DB_PASSWORD', 'vRVr7GJCAZ');
define('DB_HOST', 'localhost');
define('ABSPATH', '/home/974670.cloudwaysapps.com/uberrxmprk/public_html/');

Staging-Specific Tools

  1. Configuration
  • deploy-config-staging.sh: Deployment configuration
  • configure-staging-tests.sh: Test environment setup
  • wp-tests-config-staging.php: WordPress test configuration
  1. Deployment
  • deploy-plugin.sh: Deploy plugin files
  • deploy-config-staging.sh: Deploy configuration files
  1. Testing
  • run-staging-unit-tests.sh: Run unit tests
  • run-staging-tests.sh: Run all test suites
  1. Verification
  • verify-staging.sh: Environment verification
  • sync-staging.sh: Data synchronization

Staging Environment Maintenance

  1. Regular Tasks
  • Run tests weekly
  • Monitor error logs
  • Update test data
  • Verify plugin functionality
  1. Data Management
# Sync data from staging
./bin/sync-staging.sh

# Deploy fresh test data
./bin/deploy-config-staging.sh --test-data
  1. Monitoring
# Check logs
./bin/verify-staging.sh --logs

# Monitor performance
./bin/verify-staging.sh --performance

Troubleshooting

Development Environment Issues

  1. Permission Errors

    # Fix permissions
    ./Users/ben/dev/upskill-event-manager/manage-env.sh fix-permissions
    
  2. Cache Issues

    # Clear WordPress cache
    wp cache flush
    
  3. Plugin Activation Issues

    # Check plugin status
    wp plugin list
    

Staging Environment Issues

  1. SSH Connection Issues

    # Test SSH connection
    sshpass -p "$UPSKILL_STAGING_PASS" ssh "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "echo 'Connection test'"
    
    # Check SSH configuration
    ./bin/verify-staging.sh --ssh
    
    # Verify credentials
    env | grep UPSKILL_STAGING
    
  2. Test Environment Issues

    # Reconfigure test environment
    ./bin/configure-staging-tests.sh
    
    # Check test configuration
    ./bin/verify-staging.sh --test-env
    
    # View test logs
    ./bin/verify-staging.sh --logs
    
  3. Database Connection Issues

    # Test database connection
    mysql -h "$UPSKILL_STAGING_IP" -u "$UPSKILL_STAGING_DB_USER" -p"$UPSKILL_STAGING_DB_PASSWORD" "$UPSKILL_STAGING_DB_NAME" -e "SELECT 1"
    
    # Verify database configuration
    ./bin/verify-staging.sh --database
    
    # Check database permissions
    ./bin/verify-staging.sh --permissions
    
  4. Deployment Issues

    # Check deployment status
    ./bin/verify-staging.sh --deployment
    
    # Verify file permissions
    ./bin/verify-staging.sh --permissions
    
    # Check plugin status
    ./bin/verify-staging.sh --plugin
    
  5. Test Failures

    # Run specific test
    ./bin/run-staging-unit-tests.sh --filter=test_name
    
    # Debug test environment
    ./bin/verify-staging.sh --test-env
    
    # View detailed test output
    ./bin/run-staging-unit-tests.sh --debug
    
  6. Performance Issues

    # Check server resources
    ./bin/verify-staging.sh --performance
    
    # Monitor PHP processes
    ./bin/verify-staging.sh --processes
    
    # View error logs
    ./bin/verify-staging.sh --logs
    

Rollback Procedure

If deployment fails:

  1. Restore from backup
  2. Revert plugin files
  3. Clear caches
  4. Verify functionality

Maintenance

Regular Tasks

  1. Update dependencies
  2. Run tests
  3. Monitor error logs
  4. Backup data

Backup Management

# Create backup
./Users/ben/dev/upskill-event-manager/wordpress-dev/manage-env.sh backup

# Restore from backup
./Users/ben/dev/upskill-event-manager/wordpress-dev/manage-env.sh restore

Security Considerations

  1. Configuration Security

    • Use environment variables
    • Secure sensitive data
    • Restrict file permissions
  2. Access Control

    • Limit SSH access
    • Use strong passwords
    • Enable two-factor authentication
  3. Monitoring

    • Check error logs
    • Monitor file changes
    • Track plugin activity