Docker Deployment
Laravel Coolify generates production-ready Docker configurations for your Laravel application. This page explains how it works and how to customize it.
Quick Start
Section titled “Quick Start”Run the install command to generate Docker files:
php artisan coolify:installThis creates:
Dockerfile- Multi-stage build for your applicationdocker/supervisord.conf- Process manager configurationdocker/nginx.conf- Web server configurationdocker/php.ini- PHP runtime settingsdocker/entrypoint.sh- Startup script for migrations and optimization
Pre-built Base Images
Section titled “Pre-built Base Images”By default, Laravel Coolify uses pre-built base images from GitHub Container Registry. These images have all system dependencies and PHP extensions pre-compiled, reducing build time from ~12 minutes to ~2-3 minutes.
Available Images
Section titled “Available Images”| Image | PHP | Node.js | Use Case |
|---|---|---|---|
ghcr.io/stumason/laravel-coolify-base:8.3 | 8.3 | - | API-only or Blade apps |
ghcr.io/stumason/laravel-coolify-base:8.4 | 8.4 | - | API-only or Blade apps |
ghcr.io/stumason/laravel-coolify-base:8.3-node | 8.3 | 20 LTS | Full-stack with Vite/Inertia |
ghcr.io/stumason/laravel-coolify-base:8.4-node | 8.4 | 20 LTS | Full-stack with Vite/Inertia |
Automatic Detection
Section titled “Automatic Detection”The generator automatically selects the right image variant:
- If
package.jsonexists → uses-nodevariant - Otherwise → uses standard variant
What’s Included in Base Images
Section titled “What’s Included in Base Images”System Dependencies:
- nginx, supervisor, curl, wget, zip, unzip, git
PHP Extensions:
- Database: pdo, pdo_mysql, pdo_pgsql, pgsql
- Core: mbstring, xml, bcmath, intl, opcache, pcntl, zip
- Media: gd (with freetype & jpeg)
- Cache: redis (via PECL)
What’s NOT Included:
- Chromium/Browsershot (add to your Dockerfile if needed)
- Application code (copied during deployment)
Opting Out of Base Images
Section titled “Opting Out of Base Images”If you need custom PHP extensions or want full control:
COOLIFY_USE_BASE_IMAGE=falseThis generates a Dockerfile that builds from php:x.x-fpm-bookworm directly.
Container Startup
Section titled “Container Startup”When your container starts, the entrypoint script runs automatically:
1. Database Connection Check
Section titled “1. Database Connection Check”The script waits for your database to be available before proceeding:
[1/3] Waiting for database connection... Waiting for database... (1/30s) Database connected!Configure the timeout:
COOLIFY_DB_WAIT_TIMEOUT=30 # seconds (default)2. Database Migrations
Section titled “2. Database Migrations”Migrations run automatically with --force flag:
[1/3] Running database migrations... Migrations completed successfully.If migrations fail, the container exits with an error - this prevents your app from starting with an inconsistent database state.
To disable automatic migrations:
COOLIFY_AUTO_MIGRATE=false3. Application Optimization
Section titled “3. Application Optimization”Laravel’s optimize command caches config, routes, views, and events:
[2/3] Optimizing application... Optimization completed (config, routes, views, events cached).4. Storage Link
Section titled “4. Storage Link”Ensures the storage symlink exists:
[3/3] Ensuring storage link... Storage link ready.Handling Migration Failures
Section titled “Handling Migration Failures”Since migrations run on container startup, you need a strategy for failures:
During Development
Section titled “During Development”- Fix the migration locally
- Push the fix
- Redeploy
Rollback Scenario
Section titled “Rollback Scenario”If you deploy a broken migration:
- The container will fail to start (expected behavior)
- Create a new migration to fix the issue
- Deploy the fix
- The new container will run both migrations
Auto-detected Workers
Section titled “Auto-detected Workers”The Dockerfile generator detects installed Laravel packages and configures supervisor workers:
| Package | Worker Added |
|---|---|
| Laravel Horizon | horizon process |
| Laravel Reverb | reverb:start WebSocket server |
| Scheduler | schedule:run loop |
Customization
Section titled “Customization”PHP Version
Section titled “PHP Version”COOLIFY_PHP_VERSION=8.4 # or 8.3Health Check
Section titled “Health Check”COOLIFY_HEALTH_CHECK_PATH=/up # default Laravel health endpointPHP Settings
Section titled “PHP Settings”COOLIFY_PHP_MEMORY_LIMIT=256MCOOLIFY_PHP_MAX_EXECUTION_TIME=60Upload Limits
Section titled “Upload Limits”COOLIFY_NGINX_MAX_BODY_SIZE=35MCOOLIFY_UPLOAD_MAX_FILESIZE=30MCOOLIFY_POST_MAX_SIZE=35MRegenerating Docker Files
Section titled “Regenerating Docker Files”To regenerate after configuration changes:
php artisan coolify:install --forceThen commit and deploy!
Security
Section titled “Security”Base images are rebuilt nightly via GitHub Actions to include the latest security patches. This ensures your deployments always use patched dependencies.