Skip to content

MuhammadQuran17/laravel_production_docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Production-ready Laravel Docker (Nginx + PHP-FPM + Queue + Postgres)

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

Services

  • nginx

  • laravel_php_fpm

    • Multi-stage build on php-fpm-alpine.
    • Runs an entrypoint that clears/warms caches and creates the storage symlink.
  • laravel_queue_worker

    • Uses the same app image (separate target) and runs php artisan queue:work.
  • 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.

Configuration

This Compose file uses your .env file. At minimum, ensure these exist:

  • DB_DATABASE
  • DB_USERNAME
  • DB_PASSWORD

Optional:

  • NGINX_PORT (defaults to 80)

Run (standard)

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 nginx

Run with migrations safely (migrator profile)

The 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 -d

Notes:

  • The migrator uses Laravel maintenance mode during the migration window. Queue, Laravel_php_fpm will be in maintanace mode.

  • Recommended: change the maintenance --secret value in docker_specific/migrator/run-migrator.sh to something unique for your app.

  • Run Artisan commands

docker compose -f docker-compose.prod.yml exec laravel_php_fpm php artisan about

Reverse proxy / hosting

  • If you’re using a platform like Coolify (or any reverse proxy like Traefik/Nginx Proxy Manager), you can typically route traffic to the nginx container.
  • If you run this on a raw host, ensure NGINX_PORT is set to the port you want exposed publicly.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors