Sign inSign up

stsdockerhub/php

By stsdockerhub

•Updated 4 days ago

PHP-FPM + Nginx + Supervisor images for Laravel on Alpine and Debian, with optional build toolchain

Image
Languages & frameworks
Web servers
0

7.2K

stsdockerhub/php repository overview

⁠PHP-FPM + Nginx for Laravel (Alpine & Debian)

Lightweight, production-ready PHP images for running Laravel (and other PHP applications) behind Nginx, in a single container. Built on the official php:*-fpm images, on Alpine Linux, with a Debian (trixie) variant also available.

Source and docs: https://github.com/tgivslife/laravel-alpine⁠


⁠What's inside

ComponentRole
PHP-FPMRuns the application, with common extensions preinstalled
NginxServes /var/www/html on port 80 and proxies PHP to FPM
SupervisorStarts and manages nginx, php-fpm, cron, and optionally the Laravel scheduler and Horizon
CronScheduled tasks

PHP extensions include bcmath, curl, exif, gd, intl, mbstring, mysqli, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, pcntl, redis, sockets, sodium, zip and Zend OPcache. Run php -m inside a container for the full list of a given tag.

⁠Runtime and build variants

Every runtime tag has a matching -build tag that adds a build toolchain: Composer, Node.js, npm and Git. Use -build to install dependencies and compile assets, and the slim runtime tag to run the result.

⁠Tags

Tag format:

  • Alpine: <php version>-laravel-alpine<alpine version>[-build]
  • Debian: <php version>-laravel-<debian codename>[-build]

Latest per PHP version:

PHPAlpineDebian
8.58.5.10-laravel-alpine3.24, 8.5.10-laravel-alpine3.24-build8.5.10-laravel-trixie, 8.5.10-laravel-trixie-build
8.48.4.23-laravel-alpine3.24, 8.4.23-laravel-alpine3.24-build—
8.38.3.32-laravel-alpine3.24, 8.3.32-laravel-alpine3.24-build—
8.28.2.15-laravel-alpine3.18, 8.2.15-laravel-alpine3.18-build—
7.47.4.33-laravel-alpine3.16, 7.4.33-laravel-alpine3.16-build—

Older patch releases remain available on the Tags⁠ page. PHP 8.2 and 7.4 are end-of-life upstream and kept for legacy applications only.

⁠Quick start: multi-stage Laravel image

ARG PHP_TAG=8.5.10-laravel-alpine3.24

FROM stsdockerhub/php:${PHP_TAG}-build AS build
WORKDIR /var/www/html
COPY . .
RUN composer install --no-dev --optimize-autoloader \
 && npm ci \
 && npm run build \
 && tar --owner=www-data --group=www-data \
        --exclude=.git --exclude=node_modules -czf /tmp/app.tar.gz .

FROM stsdockerhub/php:${PHP_TAG}
WORKDIR /var/www/html
COPY --from=build /tmp/app.tar.gz .
RUN tar -xf app.tar.gz && rm app.tar.gz

# Optional: startup hooks (migrations, cache warm-up, …)
COPY docker/docker-entrypoint.d /docker-entrypoint.d/
RUN chmod +x /docker-entrypoint.d/*
docker build -t my-laravel-app .
docker run -p 8080:80 -e LARAVEL_SCHEDULER_ENABLE=1 my-laravel-app

The application is then served at http://localhost:8080/⁠.

A complete sample application (Laravel + Vue starter kit, with scheduler and Horizon test jobs) is in example-app⁠.

⁠Environment variables

All optional; defaults shown.

OS

VariableDefaultDescription
TZ—Container timezone, e.g. Europe/Bucharest

Laravel

VariableDefaultDescription
LARAVEL_SCHEDULER_ENABLE1Run php artisan schedule:work under Supervisor (output goes to container logs)
LARAVEL_HORIZON_ENABLE0Run Laravel Horizon for Redis queues under Supervisor

PHP

VariableDefault
PHP_MAX_EXECUTION_TIME60
PHP_MEMORY_LIMIT128M
PHP_UPLOAD_MAX_FILESIZE50M
PHP_POST_MAX_SIZE50M

OPcache

VariableDefault
PHP_OPCACHE_ENABLE1
PHP_OPCACHE_ENABLE_CLI1
PHP_OPCACHE_MEMORY_CONSUMPTION512
PHP_OPCACHE_INTERNED_STRINGS_BUFFER128
PHP_OPCACHE_MAX_ACCELERATED_FILES65406
PHP_OPCACHE_MAX_WASTED_PERCENTAGE15
PHP_OPCACHE_VALIDATE_TIMESTAMPS0
PHP_OPCACHE_SAVE_COMMENTS1

PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 is tuned for immutable production images: code changes are not picked up until the container restarts. Set it to 1 for development with mounted source code.

PHP-FPM

VariableDefault
PHP_FPM_PM_MAX_CHILDREN50
PHP_FPM_PM_START_SERVERS20
PHP_FPM_PM_MIN_SPARE_SERVER10
PHP_FPM_PM_MAX_SPARE_SERVERS30

Nginx

VariableDefaultDescription
NGINX_FASTCGI_READ_TIMEOUT60sTimeout between reads from PHP-FPM
NGINX_CLIENT_MAX_BODY_SIZE50mMax request body (keep in line with PHP_POST_MAX_SIZE)
NGINX_SET_REAL_IP_FROM127.0.0.1Trusted proxy address(es) for the real client IP
NGINX_WORKER_CONNECTIONS4096Connections per worker
NGINX_WORKER_RLIMIT_NOFILE65535Open file limit per worker

⁠Ports and paths

80HTTP (Nginx)
/var/www/htmlApplication root (Nginx serves public/)
/docker-entrypoint.d/Executable startup scripts, run before Supervisor starts the services

⁠Documentation

Per-version details (exact package versions, build arguments, full extension list) are in the version folders of the GitHub repository⁠.

Tag summary

Content type

Image

Digest

sha256:53de0b33a…

Size

151.1 MB

Last updated

4 days ago

docker pull stsdockerhub/php:8.5.10-laravel-trixie-build