Skip to Content
API v2Deployment

Deployment

Docker Image

The application is containerised using a custom Dockerfile based on a PHP 8.2 FPM image from Housr’s private ECR registry.

Container Stack

The container runs three services via Supervisor:

  1. PHP-FPM — Handles PHP request processing
  2. Nginx — Reverse proxy and static file serving (port 80)
  3. Queue Worker — Processes background jobs (configured in deploy/supervisord.conf)

Build Process

# Key steps in Dockerfile: 1. Install PHP extensions (pdo_mysql, redis, bcmath, gd, zip, opcache, soap) 2. Install Node.js 18 3. Install Nginx and Supervisor 4. Copy application code 5. Run composer install --no-dev --optimize-autoloader 6. Copy Nginx, PHP-FPM, and Supervisor configs from deploy/ 7. Set permissions for www-data

Deploy Directory

The deploy/ directory contains production configuration files:

FilePurpose
deploy/runContainer entrypoint script
deploy/nginx.confNginx configuration
deploy/deploy.confNginx site configuration
deploy/www.confPHP-FPM pool configuration
deploy/supervisord.confSupervisor process management
deploy/opcache.iniPHP OPcache settings (timestamps validation disabled for production)

Docker Compose

Development (docker-compose.yml):

  • Single service on port 8000
  • Mounts project directory as volume
  • Connects to host MySQL via host.docker.internal

Production (docker-compose.prod.yml):

  • Production-specific overrides

Environment Configuration

Production Env Vars

In addition to the standard .env variables, production requires:

  • APP_ENV=production
  • APP_DEBUG=false
  • APP_URL set to production domain
  • All third-party service credentials (HubSpot, Twilio, etc.)
  • SENTRY_LARAVEL_DSN for error tracking
  • USA=true or USA=false for region configuration

OPcache

Production uses OPcache with validate_timestamps=0 for performance. This means code changes require a container rebuild/restart.

AWS Copilot

The copilot/ directory suggests the application is deployed using AWS Copilot (ECS/Fargate). The deployment workflow:

  1. Build Docker image
  2. Push to ECR
  3. Deploy via Copilot to ECS

Region Deployments

The application is deployed as separate instances for UK and US, distinguished by the USA environment variable:

  • UK deployment: USA=false — Full feature set including bills pricing, spatial queries (MySQL 8)
  • US deployment: USA=true — US-specific features, lease terms, building details, simplified bills pricing (MySQL 5.7 compatible)

Pre-Deployment Checks

Before deploying, run the full check suite:

composer check

This runs:

  1. vendor/bin/pest — All tests pass
  2. vendor/bin/pint --test — Code style is correct
  3. vendor/bin/phpstan analyse --memory-limit=2G — No static analysis errors

Artisan Commands

Useful artisan commands for deployment/operations:

# Cache configuration for performance php artisan config:cache php artisan route:cache php artisan view:cache # Run migrations php artisan migrate --force # Clear caches php artisan cache:clear php artisan config:clear php artisan route:clear # List all registered routes php artisan route:list # List module status php artisan module:list
Last updated on