Skip to content

Latest commit

 

History

History
206 lines (160 loc) · 5.61 KB

README.md

File metadata and controls

206 lines (160 loc) · 5.61 KB
title Example Applications
description Production-ready Docker Compose setups for common PHP application patterns
weight 1

Example Applications

Copy-paste ready Docker Compose configurations for common use cases.

All processes managed by Cbox Init - NO command overrides!

Quick Reference

Example Use Case Services
PHP Basic Plain PHP without framework PHP-FPM, Nginx
Laravel Basic Simple Laravel app PHP-FPM, Nginx, MySQL
Laravel Horizon Queue dashboard Horizon, Scheduler, MySQL, Redis
Laravel Production Deploy ready Resource limits, Horizon
Reverb WebSockets Real-time features Reverb, Queue, MySQL, Redis
Symfony Basic Symfony app Messenger, PostgreSQL
WordPress CMS setup PHP, MySQL
API Only REST/GraphQL API PHP, PostgreSQL, Redis
Development Local dev Xdebug, Vite HMR, MailHog
Multi-Tenant SaaS Central DB + Tenant DBs
Microservices Distributed services Gateway + Service containers
Static Assets Pre-built frontend PHP only, no Node runtime

CI & Health Check Templates

Template Description
Health Checks Docker Compose override with built-in health checks for app/MySQL/Redis
GitHub Actions Workflow file that pulls Cbox images, waits for health checks, and runs php artisan test

How to Use

  1. Copy the example folder to your project
  2. Adjust docker-compose.yml for your needs
  3. Run docker compose up -d
# Example: Start Laravel basic setup
cp -r examples/laravel-basic/* ./
docker compose up -d

Cbox Init Process Management

All examples use environment variables to control processes - NEVER override command: for PHP containers!

# Correct - Use environment variables
services:
  app:
    image: ghcr.io/cboxdk/php-baseimages/php-fpm-nginx:8.3-bookworm-v1
    environment:
      LARAVEL_QUEUE: "true"       # Enables queue workers
      LARAVEL_SCHEDULER: "true"   # Enables scheduler
      LARAVEL_HORIZON: "true"     # Enables Horizon (replaces QUEUE)
      LARAVEL_REVERB: "true"      # Enables Reverb WebSocket server

# WRONG - Don't override command
services:
  worker:
    image: ghcr.io/cboxdk/php-baseimages/php-fpm-nginx:8.3-bookworm-v1
    command: php artisan queue:work  # DON'T DO THIS!

Webroot Configuration

Cbox images default to /var/www/html/public for frameworks like Laravel/Symfony.

For apps without public/ folder (WordPress, plain PHP), set WEBROOT:

services:
  app:
    image: ghcr.io/cboxdk/php-baseimages/php-fpm-nginx:8.3-bookworm-v1
    environment:
      WEBROOT: /var/www/html  # Serve from root, not public/
App Type WEBROOT Setting
Laravel, Symfony Default (/var/www/html/public)
WordPress, plain PHP WEBROOT: /var/www/html

Choosing an Example

By Framework

  • Laravel: laravel-basic, laravel-horizon, laravel-production, reverb-websockets
  • Symfony: symfony-basic
  • WordPress: wordpress
  • Plain PHP: php-basic, api-only

By Environment

  • Development: development (Xdebug, hot reload, exposed ports)
  • Production: laravel-production (optimized, resource limits)
  • Testing: Use any with APP_ENV=testing

By Architecture

  • Monolith: laravel-basic, symfony-basic
  • Queue-heavy: laravel-horizon
  • Real-time: reverb-websockets
  • Multi-tenant SaaS: multi-tenant
  • Microservices: microservices

Volume Strategies

Development (bind mount)

volumes:
  - ./:/var/www/html  # Your code synced to container

Production (named volumes)

volumes:
  - app_storage:/var/www/html/storage
  - app_cache:/var/www/html/bootstrap/cache

volumes:
  app_storage:
  app_cache:

Mixed (common pattern)

volumes:
  - ./:/var/www/html                    # Code (bind mount)
  - mysql_data:/var/lib/mysql           # Database (named volume)

Common Patterns

Enable Queue Workers

services:
  app:
    image: ghcr.io/cboxdk/php-baseimages/php-fpm-nginx:8.3-bookworm-v1
    environment:
      LARAVEL_QUEUE: "true"
      REDIS_HOST: redis
      QUEUE_CONNECTION: redis

Enable Horizon (Production Queues)

services:
  app:
    image: ghcr.io/cboxdk/php-baseimages/php-fpm-nginx:8.3-bookworm-v1
    environment:
      LARAVEL_HORIZON: "true"     # Use instead of LARAVEL_QUEUE
      REDIS_HOST: redis

Enable Scheduler

services:
  app:
    image: ghcr.io/cboxdk/php-baseimages/php-fpm-nginx:8.3-bookworm-v1
    environment:
      LARAVEL_SCHEDULER: "true"

Enable Reverb WebSockets

services:
  app:
    image: ghcr.io/cboxdk/php-baseimages/php-fpm-nginx:8.3-bookworm-v1
    ports:
      - "8080:80"
      - "8085:8085"
    environment:
      LARAVEL_REVERB: "true"
      REVERB_HOST: 0.0.0.0
      REVERB_PORT: 8085

Customization

All examples use Cbox images. Swap versions as needed:

# Use different PHP version
image: ghcr.io/cboxdk/php-baseimages/php-fpm-nginx:8.5-bookworm-v1

# Use different tier
image: ghcr.io/cboxdk/php-baseimages/php-fpm-nginx:8.5-bookworm-slim-v1
image: ghcr.io/cboxdk/php-baseimages/php-fpm-nginx:8.5-bookworm-chromium-v1

Need Help?

  • Check the README in each example folder
  • See documentation for detailed guides
  • Open an issue on GitHub