A production-ready Docker Compose setup for Laravel applications. Used by AI AgentChat starter kit for Laravel developers: https://agenytics.com
It ships with:
- Nginx (serving the app + static assets)
- PHP-FPM (Laravel application runtime)
- A dedicated queue worker
- Postgres
- A one-off migrator service (optional) that enables maintenance mode, runs migrations, then stops
-
nginx -
laravel_php_fpm- Multi-stage build on
php-fpm-alpine. - Runs an entrypoint that clears/warms caches and creates the
storagesymlink.
- Multi-stage build on
-
laravel_queue_worker- Uses the same app image (separate target) and runs
php artisan queue:work.
- Uses the same app image (separate target) and runs
-
pgsql -
migrator(optional profile)- Runs once. Uses the same app image (separate target)
- Puts the app into maintenance mode, executes
php artisan migrate --force, then brings the app back up.
This Compose file uses your .env file. At minimum, ensure these exist:
DB_DATABASEDB_USERNAMEDB_PASSWORD
Optional:
NGINX_PORT(defaults to80)
Use the production compose file:
docker compose -f docker-compose.prod.yml up -d(Optional) Check health/logs:
docker compose -f docker-compose.prod.yml ps
docker compose -f docker-compose.prod.yml logs -f nginxThe migrator service is intentionally not started by default. To run it together with the rest of the stack:
docker compose -f docker-compose.prod.yml --profile migrate up -dNotes:
-
The migrator uses Laravel maintenance mode during the migration window. Queue, Laravel_php_fpm will be in maintanace mode.
-
Recommended: change the maintenance
--secretvalue indocker_specific/migrator/run-migrator.shto something unique for your app. -
Run Artisan commands
docker compose -f docker-compose.prod.yml exec laravel_php_fpm php artisan about- If you’re using a platform like Coolify (or any reverse proxy like Traefik/Nginx Proxy Manager), you can typically route traffic to the
nginxcontainer. - If you run this on a raw host, ensure
NGINX_PORTis set to the port you want exposed publicly.