DevOps & Infrastructure
Overview
This document covers infrastructure, development environment, deployment, and operations for the Wedissimo API.
Related Documentation:
- CI/CD Pipeline - Automated testing and deployment
- Testing - Test execution and coverage
- Development Environment - Local development setup
- Typesense Monitoring - Search engine monitoring setup
- Google Cloud Setup - GCloud CLI and Cloud SQL proxy configuration
Production Deployment
Google Cloud Run
Platform Configuration
- Platform: Google Cloud Run
- Deployment Method: Docker container-based
- Orchestration: Google Cloud Build
- Regions: europe-west2 (London)
Environment Variables
Critical environment variables for deployment:
bash
APP_ENV=production
APP_DEBUG=false
APP_KEY=<generated-key>
DB_CONNECTION=pgsql
DB_HOST=/cloudsql/<instance-connection-name>
DB_DATABASE=<database-name>
DB_USERNAME=<database-user>
DB_PASSWORD=<database-password>
MAIL_MAILER=smtp
SCOUT_DRIVER=typesense
TYPESENSE_API_KEY=<typesense-key>Cloud SQL Connection
bash
# Using Unix socket (recommended for Cloud Run)
DB_HOST=/cloudsql/<project>:<region>:<instance>
# Connection via Cloud SQL Proxy (development)
DB_HOST=127.0.0.1
DB_PORT=3306Production Optimization
Laravel Optimizations
bash
# Configuration caching
php artisan config:cache
# Route caching
php artisan route:cache
# View compilation
php artisan view:cache
# Clear optimization (for updates)
php artisan optimize:clearAsset Optimization
bash
# Production asset build
npm run build
# Asset versioning
# Handled automatically by ViteEnvironment Management
Environment Files
.env.example: Template for environment configuration.env.testing: Testing environment configuration.env: Local development (not in version control)
Configuration Management
Key Configuration Files:
config/app.php: Application settingsconfig/database.php: Database connectionsconfig/mail.php: Email configurationconfig/services.php: Third-party servicesconfig/scout.php: Typesense search configuration
Secrets Management
Development:
- Local
.envfile
Production:
- Google Cloud Secret Manager
- Cloud Run service environment variables
- Never commit secrets to repository
CI/CD:
- GitHub Actions secrets
Monitoring & Debugging
Application Monitoring
- Laravel Telescope: Development debugging (enabled in local/staging)
- Bugsnag: Error tracking and reporting (production)
- Google Cloud Monitoring: Platform-level monitoring
- Google Cloud Logging: Centralized log management
Logging Strategy
- Log Channels: Configured in
config/logging.php - Error Tracking: Bugsnag integration for production errors
- Debug Information: Laravel Telescope for development
- Stack Driver: Google Cloud Logging for production
Performance Monitoring
- Query Monitoring: Telescope query tracking in development
- Performance Metrics: Enlightn analysis
- Resource Usage: Google Cloud Monitoring metrics
- APM: Application Performance Monitoring via Bugsnag
Backup & Recovery
Database Backups
- Google Cloud SQL: Automated daily backups
- Manual Backups: Available via
gcloudCLI - Point-in-time Recovery: Up to 7 days (configurable)
- Backup Retention: 30 days (configurable)
bash
# Create manual backup
gcloud sql backups create --instance=<instance-name>
# List backups
gcloud sql backups list --instance=<instance-name>
# Restore from backup
gcloud sql backups restore <backup-id> --backup-instance=<instance-name>Code Backup
- Git Repository: Primary code backup
- Multiple Remotes: Origin and deployment remotes
- Branching Strategy: Feature branches for safety
Scaling Considerations
Horizontal Scaling
Cloud Run Auto-scaling:
- Minimum instances: 1 (or 0 for staging)
- Maximum instances: 10 (configurable)
- Concurrent requests: 80 per instance
- CPU allocation: Only during request processing
bash
# Configure scaling
gcloud run services update wedissimo-api \
--min-instances=1 \
--max-instances=10 \
--concurrency=80Database Scaling:
- Vertical: Increase machine type via Cloud SQL
- Read Replicas: For read-heavy workloads
- Connection Pooling: PgBouncer for connection management
Queue Processing:
- Cloud Run Jobs: Scheduled task execution
- Queue Workers: Dedicated Cloud Run services for queue processing
Performance Optimization
Caching:
- Redis: Session and cache storage
- Google Cloud Memorystore: Managed Redis service
- OPcache: PHP opcode caching (enabled in production)
CDN:
- Google Cloud CDN: Asset delivery optimization
- Cloud Storage: Static asset hosting
Database Optimization:
- Query Optimization: Eloquent eager loading
- Indexing: Proper database indexes
- PostGIS Spatial Indexes: For geographic queries
Infrastructure as Code
Docker Compose Overrides
Use override files for environment-specific configurations:
yaml
# docker-compose.override.yml (gitignored)
services:
wedissimo-api:
environment:
- APP_DEBUG=trueGoogle Cloud Configuration
gcloud CLI Setup:
bash
# Initialize gcloud
gcloud init
# Set project
gcloud config set project <project-id>
# Set region
gcloud config set run/region europe-west2Troubleshooting
Common Issues
Container Won't Start:
bash
# Check logs
docker compose logs wedissimo-api
# Rebuild container
docker compose up -d --build wedissimo-apiDatabase Connection Issues:
bash
# Verify PostgreSQL is running
docker compose ps wedissimo-pg
# Test connection
docker compose exec wedissimo-pg psql -U postgres -d testingPermission Issues:
bash
# Fix storage permissions
docker compose exec wedissimo-api chmod -R 775 storage bootstrap/cache
docker compose exec wedissimo-api chown -R www-data:www-data storage bootstrap/cacheSecurity Best Practices
- Keep all dependencies up to date
- Use Google Cloud Secret Manager for production secrets
- Enable Cloud Armor for DDoS protection
- Configure Cloud SQL to deny public IP access
- Use VPC for private network communication
- Enable Cloud Audit Logs for compliance
- Regular security scans with Enlightn
Future Infrastructure Enhancements
Planned Improvements
- Kubernetes Migration: For more complex orchestration needs
- Multi-Region Deployment: Geographic redundancy
- Advanced Monitoring: Custom dashboards and alerts
- Infrastructure as Code: Terraform for full infrastructure management
- Blue-Green Deployments: Zero-downtime deployment strategy