Sign inSign up

netsas/laravel

By netsas

•Updated 4 months ago

Laravel-ready PHP 8.4 FPM Alpine image with Nginx, Supervisor and Composer

Image
API management
Machine learning & AI
Web servers
0

6.6K

netsas/laravel repository overview

⁠🚀 Netsas Laravel PHP 8.4 FPM Alpine Image

Production-ready Laravel container based on Alpine Linux.

This image provides a complete runtime environment for Laravel applications, bundling Nginx, PHP-FPM 8.4, Supervisor, Cron, Composer, and commonly used PHP extensions in a single lightweight container.

Ideal for VPS deployments, cloud instances, Docker Compose, and production environments.


⁠📦 Base Image

  • php:8.4-fpm-alpine

⁠✨ Features

  • PHP 8.4 FPM
  • Nginx
  • Supervisor
  • Cron
  • Composer
  • Redis (phpredis)
  • SSH2
  • Full ICU locale support
  • PostgreSQL support
  • MySQL support
  • Queue Workers
  • Laravel Scheduler
  • OPCache enabled
  • PCOV support for testing

⁠🔧 Included Services

The container automatically starts and manages:

ServiceDescription
NginxHTTP Web Server
PHP-FPMPHP FastCGI Process Manager
SupervisorProcess Manager
CronExecutes Laravel Scheduler
Queue WorkersProcesses Laravel Queues

Supervisor monitors every service and automatically restarts any process that exits unexpectedly.


⁠🧩 Installed PHP Extensions

  • mbstring
  • xml
  • pcntl
  • gd (FreeType, JPEG, PNG)
  • zip
  • pdo
  • pdo_mysql
  • pdo_pgsql
  • pgsql
  • bcmath
  • soap
  • opcache
  • intl
  • fileinfo
  • xsl
  • redis
  • ssh2
  • pcov

⁠🌍 ICU Full Locale Support

Includes:

  • icu
  • icu-dev
  • icu-data-full

Provides complete internationalization support for:

  • NumberFormatter
  • Collator
  • Date Formatting
  • Transliteration
  • Currency Formatting
  • Locale-aware Sorting

Perfect for multilingual Laravel applications.


⁠📁 Working Directory

/app

Your Laravel application should be mounted or copied into this directory.


⁠📦 Volume

/app

Example:

docker run \
    -v $(pwd):/app \
    netsas/laravel:latest

⁠🔌 Exposed Port

Default:

80

Configurable using:

NGINX_PORT=80

⁠🏗 Build Image

Build locally:

docker build --no-cache -t netsas/laravel:8.4-fpm-alpine .

Tag as latest:

docker tag netsas/laravel:8.4-fpm-alpine netsas/laravel:latest

Push to Docker Registry:

docker push netsas/laravel:8.4-fpm-alpine
docker push netsas/laravel:latest

⁠▶️ Run Container

docker run -d \
    --name laravel \
    -p 80:80 \
    -v $(pwd):/app \
    netsas/laravel:latest

⁠🔄 Process Management (Supervisor)

Supervisor is the container's process manager.

It automatically starts and monitors:

  • Nginx
  • PHP-FPM
  • Cron
  • Laravel Queue Workers

If any service crashes, Supervisor automatically restarts it.

No manual process management is required.


⁠⏰ Laravel Scheduler

Cron is preconfigured to execute the Laravel Scheduler every minute.

* * * * * cd /app && php artisan schedule:run >> /dev/null 2>&1

Simply define your scheduled tasks inside Laravel:

app/Console/Kernel.php

or (Laravel 11+)

routes/console.php

No additional cron configuration is necessary.


⁠📬 Laravel Queue Workers

Supervisor automatically starts queue workers when the container boots.

Default configuration:

QueueProcessesTimeoutMemory
default2120s512 MB
reports1600s1024 MB

Workers are configured to:

  • Auto restart
  • Graceful shutdown
  • Retry failed jobs
  • Memory limits
  • Queue isolation

Example:

[program:queue-default]
command=php /app/artisan queue:work \
    --queue=default \
    --sleep=3 \
    --tries=3 \
    --timeout=120 \
    --memory=512

[program:queue-reports]
command=php /app/artisan queue:work \
    --queue=reports \
    --sleep=3 \
    --tries=2 \
    --timeout=600 \
    --memory=1024

⁠🚀 Redis Support

The image includes the native phpredis extension.

Recommended Laravel configuration:

REDIS_CLIENT=phpredis

CACHE_DRIVER=redis
SESSION_DRIVER=redis
QUEUE_CONNECTION=redis

Dispatch jobs normally:

ProcessOrder::dispatch();

GenerateReport::dispatch()->onQueue('reports');

⁠🔁 Restart Queue Workers

After deploying new code, restart workers:

php artisan queue:restart

Supervisor automatically starts new worker processes after current jobs finish processing.


⁠🏛 Architecture

                HTTP Request
                     │
                     ▼
                  Nginx
                     │
                     ▼
                 PHP-FPM
                     │
                     ▼
          Laravel Application
                     │
         ┌───────────┼───────────┐
         ▼           ▼           ▼
      Redis      Database      Storage
         │
         ▼
 Queue Workers (Supervisor)

Cron
 │
 ▼
Laravel Scheduler

⁠🎯 Use Cases

  • Laravel Applications
  • REST APIs
  • GraphQL APIs
  • Microservices
  • Background Jobs
  • Queue Processing
  • Scheduled Tasks
  • PostgreSQL Applications
  • MySQL Applications
  • Redis-backed Applications
  • Docker Compose Deployments
  • VPS Deployments
  • Cloud Deployments

⁠📌 Notes

  • Lightweight Alpine-based image.
  • Optimized for production environments.
  • Includes all required Laravel runtime services.
  • Supports MySQL and PostgreSQL.
  • Native Redis support through phpredis.
  • Scheduler and Queue Workers are preconfigured.
  • Suitable for single-container deployments.
  • For large-scale distributed architectures, consider running Nginx, PHP-FPM, and Queue Workers in separate containers.

⁠📄 License

MIT License.

Tag summary

Content type

Image

Digest

sha256:c10c03fa8…

Size

77.3 MB

Last updated

4 months ago

docker pull netsas/laravel