Sign inSign up

stsdockerhub/php

By stsdockerhub

•Updated 11 days ago

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

Image
Languages & frameworks
Web servers
0

8.0K

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. Alpine images are built on the official php:*-fpm-alpine images; the Debian (trixie) variant compiles PHP from source on debian:trixie-slim.

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


⁠What's inside

ComponentRole
PHP-FPMRuns the application, with common extensions preinstalled
NginxServes the application from /var/www/html/public on port 80 and passes PHP to PHP-FPM
SupervisorStarts and manages nginx, php-fpm, the Laravel scheduler (on by default) and Horizon (opt-in)

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.11-laravel-alpine3.24, 8.5.11-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—

Recent tags are multi-architecture (linux/amd64, linux/arm64): docker pull picks the right one. Older patch releases remain available on the Tags⁠ page; the exact package versions of each 8.5 Alpine release are listed in its GitHub release⁠.

PHP 8.2 and 7.4 are end-of-life upstream and kept for legacy applications only. They run the scheduler through cron and take a different set of environment variables than the ones below.

⁠Quick start: multi-stage Laravel image

ARG PHP_TAG=8.5.11-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=docker --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 --env-file .env 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

For PHP 8.3 and newer. All optional; defaults shown.

OS

VariableDefaultDescription
TZEurope/BucharestContainer timezone

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

VariableDefaultDescription
PHP_MAX_EXECUTION_TIME60Seconds
PHP_MEMORY_LIMIT128MOn PHP 8.5, ini_set('memory_limit', …) can still raise it at runtime
PHP_UPLOAD_MAX_FILESIZE50M
PHP_POST_MAX_SIZE50M0 disables the limit

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, paths and health check

80HTTP (Nginx)
/var/www/htmlApplication root; Nginx serves public/
/docker-entrypoint.d/Executable *.sh startup scripts, run in order before Supervisor starts the services; a failing script stops the container

The images (PHP 8.3 and newer) declare a Docker HEALTHCHECK that requests /ping through Nginx to PHP-FPM every 30 seconds, so the container turns unhealthy if either is down. /ping answers only requests from inside the container.

Each image is labelled with its version, git commit and build date: docker inspect -f '{{json .Config.Labels}}' stsdockerhub/php:<tag> (8.5 Alpine releases onward).

⁠Documentation

Build arguments and the full extension list of each image are in the version folders of the GitHub repository⁠; exact package versions are in the image README (manually published images) or the GitHub release⁠ (8.5 Alpine).

Tag summary

Content type

Image

Digest

sha256:5108e9cc7…

Size

154.2 MB

Last updated

11 days ago

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