Skip to content

DevOps & Infrastructure

Overview

This document covers infrastructure, development environment, deployment, and operations for the Wedissimo API.

Related Documentation:

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=3306

Production 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:clear

Asset Optimization

bash
# Production asset build
npm run build

# Asset versioning
# Handled automatically by Vite

Environment 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 settings
  • config/database.php: Database connections
  • config/mail.php: Email configuration
  • config/services.php: Third-party services
  • config/scout.php: Typesense search configuration

Secrets Management

Development:

  • Local .env file

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 gcloud CLI
  • 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=80

Database 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=true

Google 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-west2

Troubleshooting

Common Issues

Container Won't Start:

bash
# Check logs
docker compose logs wedissimo-api

# Rebuild container
docker compose up -d --build wedissimo-api

Database Connection Issues:

bash
# Verify PostgreSQL is running
docker compose ps wedissimo-pg

# Test connection
docker compose exec wedissimo-pg psql -U postgres -d testing

Permission 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/cache

Security 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

Wedissimo API Documentation