inisium / laravel-compose
Generate a production Dockerfile and docker-compose.yaml (serversideup/php, Coolify-ready) for a Laravel application.
Requires
- php: ^8.3
- illuminate/console: ^12.0||^13.0
- illuminate/filesystem: ^12.0||^13.0
- illuminate/support: ^12.0||^13.0
- illuminate/view: ^12.0||^13.0
- laravel/prompts: ^0.3
Requires (Dev)
- larastan/larastan: ^3.9
- laravel/pint: ^1.29
- orchestra/testbench: ^10.0||^11.0
- pestphp/pest: ^4.6||^5.0
- pestphp/pest-plugin-laravel: ^4.1||^5.0
- pestphp/pest-plugin-type-coverage: ^4.0||^5.0
- phpstan/extension-installer: ^1.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Generate a production Dockerfile and docker-compose.yaml (serversideup/php, Coolify-ready) for a Laravel application.
What it generates
Dockerfile: multi-stage build.base:serversideup/phpfpm-nginx(Debian trixie, pinned version) with the PHP extensions you need.build: Composer install, plus the front-end build (pnpm or npm) when the project has apackage.json.runtime: the application with production PHP, opcache, php-fpm and nginx settings, running aswww-dataon port 8080.
.dockerignoredocker-compose.yaml: one image for every service, told apart by their command.app: nginx + php-fpm.queue(optional): severalqueue:workprocesses under supervisord.scheduler(optional):schedule:work.nightwatch-agent(optional): the Laravel Nightwatch agent.- Environment variables are shared through an
x-laravel-envanchor.
docker/supervisord.confanddocker/supervisor/queue-worker.conf, when queue workers are enabled.
Requirements
- PHP 8.3+
- Laravel 12 or 13
- Front end (optional) managed by pnpm or npm. Projects using yarn or bun are rejected.
Installation
composer require --dev inisium/laravel-compose
Usage
Run the command and answer the prompts:
php artisan compose:install
Or run it non-interactively:
php artisan compose:install --no-interaction \
--workers=4 \
--extensions=gd --extensions=intl \
--exclude-workspace=@acme/mobile \
--force
Options
| Option | Default | Description |
|---|---|---|
--name |
APP_NAME from .env.example, else the directory name |
Application name, used as the APP_NAME and MAIL_FROM_NAME fallback. |
--extensions=* |
bcmath, intl and every ext-* required in composer.json |
PHP extensions installed on top of the image ones. Built-in extensions are dropped. |
--workers |
4 |
Number of queue workers. 0 skips the queue service and supervisor. |
--upload-max |
30 |
Maximum uploaded file size, in MB (PHP and nginx limits). |
--exclude-workspace=* |
none | pnpm workspace (package name) excluded from the web build. Only its package.json is copied, so pnpm can validate the lockfile. |
--without-scheduler |
scheduler on | Do not generate the scheduler service. |
--without-nightwatch |
on when laravel/nightwatch is required |
Do not generate the Nightwatch agent. |
--without-s3 |
on when league/flysystem-aws-s3-v3 is required |
Do not declare the AWS_* variables. |
--force |
off | Overwrite existing files without confirmation. |
What is detected
- PHP version from the
require.phpconstraint ofcomposer.json(^8.4→8.4). APP_NAME,APP_LOCALEand everyVITE_*variable from.env.example.VITE_*variables become build args.- Package manager from the lockfile (
pnpm-lock.yamlorpackage-lock.json), plus.npmrc. - pnpm workspaces from
pnpm-workspace.yaml.
Customising the stubs
Publish the stubs:
php artisan vendor:publish --tag=compose-stubs
They land in stubs/compose/. Each file there takes precedence over the package one, file by file, so you can keep only the stubs you change.
Stubs are Blade templates rendered with Blade::render(). Use {!! !!} only: {{ }} would HTML-escape the output.
After generating
Add your application-specific environment variables to x-laravel-env in docker-compose.yaml: Coolify only forwards declared variables to the containers.
Testing
composer test
License
MIT. See LICENSE.md.