CakePHP Docker Setup

February 11, 2026 ยท View on GitHub

CakePHP 5.x Docker Setup made simple. Generates a complete CakePHP development environment with Docker, including authentication scaffolding, SSL, and email testing.

Prerequisites

PHP and Composer run inside Docker containers - no local install needed.

Install all prerequisites automatically:

make prerequisites

Quick Start

make setup

You'll be prompted for:

  • Domain (e.g. myapp.com) - used to derive the project name and hostname
  • Output directory (e.g. ../myapp.com) - where the project is created

The setup script will:

  1. Create a fresh CakePHP 5.x skeleton
  2. Install and configure cakephp/authentication
  3. Generate Docker infrastructure (PHP-FPM, Nginx, MySQL, MailCatcher)
  4. Generate trusted SSL certificates via mkcert
  5. Set up development and production config files
  6. Build and start all containers

What Gets Generated

ComponentDetails
PHP8.3 FPM Alpine
Web ServerNginx with HTTPS
DatabaseMySQL 8.4 (my_app/secret)
EmailMailCatcher for testing
AuthEmail/password login with admin panel

Naming Convention

From the domain, everything is auto-derived:

Inputmyapp.com
Project Namemyapp-com
Hostnamedev.myapp.com
PHP Containermyapp-com-php_app
DB Containermyapp-com-db
Nginx Containermyapp-com-nginx
MailCatcher Containermyapp-com-mailcatcher

Config Files

  • config/app_local.dev.php - Development config (Docker service hostnames, MailCatcher)
  • config/app_local.prod.php - Production config (placeholder secrets for CI/CD)
  • config/app_local.php - Symlink to app_local.dev.php (created by Docker, or copied from prod by Composer in CI/CD)

Project Make Commands

After setup, these commands are available in the generated project directory:

CommandDescription
make upStart containers
make downStop containers
make buildRebuild containers
make shellOpen PHP container shell
make cake CMD="..."Run CakePHP CLI commands
make composer CMD="..."Run Composer commands
make dbConnect to MySQL CLI
make logsTail container logs
make cleanRemove containers and volumes

GitHub Actions

Generate CI/CD deployment files for an existing project:

make gha

This creates .github/ with:

  • Deployment workflow (rsync to production server)
  • Dependabot config
  • Issue and PR templates

Required GitHub Secrets

SecretDescription
DB_HOSTProduction database host
DB_USERNAMEProduction database username
DB_PASSWORDProduction database password
DB_DATABASEProduction database name
SES_USERNAMEAWS SES SMTP username
SES_PASSWORDAWS SES SMTP password
DEPLOY_KEYSSH private key for deployment

Required GitHub Variables

VariableDescription
DEPLOY_HOSTProduction server hostname
DEPLOY_DIRDeployment directory name

Authentication

Every generated project includes a complete authentication system:

  • Email/password login at /login
  • Session-based authentication
  • Admin panel at /admin
  • User model with password hashing, soft-delete, and findActive finder
  • Base admin controller with generic CRUD operations

Docker Network

All projects share an external Docker network named dev. This is created automatically during setup if it doesn't exist. This allows multiple projects to communicate with each other if needed.

License

MIT