DevOps

/laravel-agent:deploy:setup

Configure deployment (Forge, Vapor, Docker)

Overview

The /deploy:setup command is an interactive wizard that configures deployment for your Laravel application. It supports multiple deployment platforms including Laravel Forge, Laravel Vapor, Docker, AWS Lambda with Bref, and traditional server deployments. The wizard guides you through platform selection, environment configuration, and service requirements.

Usage

/laravel-agent:deploy:setup [platform]

Examples

# Interactive wizard - prompts for all options
/laravel-agent:deploy:setup

# Laravel Forge setup for traditional VPS
/laravel-agent:deploy:setup forge

# Laravel Vapor serverless deployment
/laravel-agent:deploy:setup vapor

# Docker containerization
/laravel-agent:deploy:setup docker

# AWS Lambda with Bref
/laravel-agent:deploy:setup bref

Supported Platforms

The command supports the following deployment platforms:

Platform Use Case Key Features
Forge Traditional VPS deployment DigitalOcean, AWS EC2, managed servers
Vapor Serverless on AWS Lambda Managed by Laravel, auto-scaling
Docker Containerized deployment ECS, Kubernetes, Docker Swarm
Bref Serverless on AWS Lambda Self-managed, full control
Traditional Custom server deployment Custom scripts, manual setup

Interactive Wizard Flow

When running without arguments, the wizard walks you through the following steps:

1. Environment Check

The wizard first checks your project for existing deployment configurations:

# Checks for:
- Laravel Vapor Core package
- Bref Laravel Bridge package
- Existing Dockerfile
- Existing vapor.yml configuration

2. Platform Selection

Choose your deployment platform based on your infrastructure needs:

Which deployment platform do you want to use?
- Forge: Traditional VPS deployment (DigitalOcean, AWS EC2, etc.)
- Vapor: Serverless on AWS Lambda (managed by Laravel)
- Docker: Containerized deployment (ECS, Kubernetes, etc.)
- Bref: Serverless on AWS Lambda (self-managed)
- Traditional: Custom server deployment scripts

3. Environment Configuration

Select which environments to configure:

Which environment are you configuring?
- Production
- Staging
- Both

4. Services Selection

Specify which services your application requires:

What services does your app need?
- [ ] MySQL/PostgreSQL database
- [ ] Redis cache
- [ ] Queue workers
- [ ] Scheduled tasks
- [ ] WebSockets (Pusher/Soketi)
- [ ] File storage (S3)

Platform-Specific Configurations

Laravel Forge Setup

When configuring for Laravel Forge, the command:

  • Creates deployment script with zero-downtime deployment
  • Configures Supervisor for Laravel Horizon queue workers
  • Sets up SSL with Let's Encrypt automatic renewal
  • Configures Nginx optimization for Laravel

Laravel Vapor Setup

For serverless deployment with Laravel Vapor:

  • Creates vapor.yml configuration file
  • Installs laravel/vapor-core if not present
  • Configures database, cache, and storage services
  • Sets up queue workers with SQS
# Example vapor.yml structure
id: 12345
name: my-app
environments:
  production:
    memory: 1024
    database: my-database
    cache: my-cache
    storage: my-bucket
    queue: my-queue

Docker Setup

For containerized deployments:

  • Creates production-ready Dockerfile
  • Creates docker-compose.yml for local development
  • Configures Nginx and PHP-FPM containers
  • Sets up multi-stage builds for optimization
# Example Dockerfile structure
FROM php:8.2-fpm

# Install dependencies
RUN apt-get update && apt-get install -y \
    git curl zip unzip

# Install PHP extensions
RUN docker-php-ext-install pdo pdo_mysql

# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Copy application
COPY . /var/www/html
WORKDIR /var/www/html

# Install dependencies and optimize
RUN composer install --no-dev --optimize-autoloader
RUN php artisan config:cache
RUN php artisan route:cache
RUN php artisan view:cache

Bref (AWS Lambda) Setup

For self-managed serverless deployment:

  • Creates serverless.yml configuration
  • Installs bref/laravel-bridge if not present
  • Configures Lambda functions for web and queue workers
  • Sets up SQS for queue processing

Generated Files

Depending on the platform selected, the wizard creates or modifies:

File Platform Description
Dockerfile Docker Container image definition
docker-compose.yml Docker Multi-container orchestration
vapor.yml Vapor Laravel Vapor configuration
serverless.yml Bref Serverless Framework config
deploy.sh Traditional Deployment shell script
.env.example All Updated with deployment variables

Required Environment Variables

After configuration, the wizard lists the secrets you need to set on your deployment platform:

# Core Laravel secrets
APP_KEY=                    # Generate with: php artisan key:generate
DB_PASSWORD=               # Database password
REDIS_PASSWORD=            # Redis password (if using Redis)

# AWS credentials (for S3/Vapor/Bref)
AWS_ACCESS_KEY_ID=         # AWS access key
AWS_SECRET_ACCESS_KEY=     # AWS secret key
AWS_DEFAULT_REGION=        # AWS region (e.g., us-east-1)

# Third-party services
PUSHER_APP_KEY=            # If using WebSockets
MAIL_PASSWORD=             # Email service password

Deployment Commands

The wizard provides platform-specific deployment commands:

Forge Deployment

# Push to repository and Forge auto-deploys
git push origin main

# Or manually deploy via Forge dashboard

Vapor Deployment

# Deploy to production
vapor deploy production

# Deploy to staging
vapor deploy staging

Docker Deployment

# Build and push image
docker build -t my-app:latest .
docker push my-registry/my-app:latest

# Deploy to ECS/Kubernetes
kubectl apply -f k8s/deployment.yaml

Bref Deployment

# Deploy using Serverless Framework
serverless deploy --stage production

Post-Deployment Checklist

The wizard provides a checklist of next steps after configuration:

  1. Set environment variables on your deployment platform
  2. Configure SSL certificate (Let's Encrypt for Forge, automatic for Vapor)
  3. Set up monitoring (Laravel Telescope, New Relic, Datadog)
  4. Configure backups for database and file storage
  5. Run initial deployment using the provided commands
  6. Verify application health by checking endpoints
  7. Configure DNS to point to your deployment

Example Output

When you run the command, you'll see output similar to:

## Deployment Configured: Laravel Vapor

### Files Created/Modified
✓ vapor.yml
✓ .env.example (updated)

### Required Secrets
- APP_KEY
- DB_PASSWORD
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY

### Deploy Command
vapor deploy production

### Next Steps
1. Set environment variables in Vapor dashboard
2. Configure SSL certificate (automatic)
3. Set up monitoring with Laravel Telescope
4. Configure database backups

Best Practices

  1. Start with staging - Always test deployments in a staging environment first
  2. Use environment variables - Never commit secrets to version control
  3. Enable zero-downtime deployments - Configure health checks and rolling updates
  4. Set up monitoring - Use application performance monitoring from day one
  5. Automate backups - Configure daily database and storage backups
  6. Use CI/CD pipelines - Automate testing and deployment with GitHub Actions or GitLab CI

Related Agent

This command uses the laravel-deploy agent.

See Also