lucasdasilvajunior/laravel-dockerfile

Laravel package to scaffold a Dockerfile with Supervisor and schedule:work

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/lucasdasilvajunior/laravel-dockerfile

v1.0.4 2025-11-29 13:04 UTC

This package is auto-updated.

Last update: 2025-11-29 13:05:43 UTC


README

A Composer-installable Laravel package that provides a production-ready Dockerfile with Supervisor configuration for running Laravel's scheduler.

Features

  • 🐳 Production-optimized Dockerfile for Laravel applications
  • ⏰ Supervisor configuration to run php artisan schedule:work
  • 🚀 Simple Artisan command to scaffold Docker files
  • 📦 Easy installation via Composer

Requirements

  • PHP >= 8.0
  • Laravel 8.x, 9.x, 10.x, 11.x or 12.x

Installation

Install the package via Composer:

composer require lucasdasilvajunior/laravel-dockerfile

The package will be auto-discovered by Laravel.

Usage

Run the initialization command to copy the Dockerfile and Supervisor configuration to your Laravel project root:

php artisan docker:init

This command will:

  • Copy a production-ready Dockerfile to your project root
  • Copy a supervisor.conf file configured to run Laravel's scheduler

If the files already exist, you'll be prompted to confirm overwriting them.

What's Included

Dockerfile

The generated Dockerfile includes:

  • PHP 8.3-FPM base image
  • Common PHP extensions (PDO, MySQL, Zip, etc.)
  • Supervisor for process management
  • Composer for dependency management
  • Optimized for production with --no-dev and --optimize-autoloader
  • Proper permissions for Laravel storage and cache directories

Supervisor Configuration

The supervisor configuration:

  • Runs php artisan schedule:work continuously
  • Auto-restarts on failure
  • Logs output to /var/log/supervisor/laravel-schedule.log
  • Runs as www-data user

Building and Running

After running php artisan docker:init, build and run your Docker container:

# Build the Docker image
docker build -t my-laravel-app .

# Run the container
docker run -d -p 9000:9000 my-laravel-app

Customization

Feel free to modify the generated Dockerfile and supervisor.conf files to suit your specific needs:

  • Add additional PHP extensions
  • Configure additional Supervisor programs (queue workers, etc.)
  • Adjust environment variables
  • Add nginx or other services

Alternative: Using vendor:publish

You can also use Laravel's standard publishing mechanism:

php artisan vendor:publish --tag=docker-stubs

License

This package is open-source software licensed under the MIT license.

Author

Lucas Da Silva Junior - lucas.ds.developer@gmail.com