PHP-FPM + Nginx + Supervisor images for Laravel on Alpine and Debian, with optional build toolchain
7.2K
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
| Component | Role |
|---|---|
| PHP-FPM | Runs the application, with common extensions preinstalled |
| Nginx | Serves /var/www/html on port 80 and proxies PHP to FPM |
| Supervisor | Starts and manages nginx, php-fpm, cron, and optionally the Laravel scheduler and Horizon |
| Cron | Scheduled 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.
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.
Tag format:
<php version>-laravel-alpine<alpine version>[-build]<php version>-laravel-<debian codename>[-build]Latest per PHP version:
| PHP | Alpine | Debian |
|---|---|---|
| 8.5 | 8.5.10-laravel-alpine3.24, 8.5.10-laravel-alpine3.24-build | 8.5.10-laravel-trixie, 8.5.10-laravel-trixie-build |
| 8.4 | 8.4.23-laravel-alpine3.24, 8.4.23-laravel-alpine3.24-build | — |
| 8.3 | 8.3.32-laravel-alpine3.24, 8.3.32-laravel-alpine3.24-build | — |
| 8.2 | 8.2.15-laravel-alpine3.18, 8.2.15-laravel-alpine3.18-build | — |
| 7.4 | 7.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.
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.
All optional; defaults shown.
OS
| Variable | Default | Description |
|---|---|---|
TZ | — | Container timezone, e.g. Europe/Bucharest |
Laravel
| Variable | Default | Description |
|---|---|---|
LARAVEL_SCHEDULER_ENABLE | 1 | Run php artisan schedule:work under Supervisor (output goes to container logs) |
LARAVEL_HORIZON_ENABLE | 0 | Run Laravel Horizon for Redis queues under Supervisor |
PHP
| Variable | Default |
|---|---|
PHP_MAX_EXECUTION_TIME | 60 |
PHP_MEMORY_LIMIT | 128M |
PHP_UPLOAD_MAX_FILESIZE | 50M |
PHP_POST_MAX_SIZE | 50M |
OPcache
| Variable | Default |
|---|---|
PHP_OPCACHE_ENABLE | 1 |
PHP_OPCACHE_ENABLE_CLI | 1 |
PHP_OPCACHE_MEMORY_CONSUMPTION | 512 |
PHP_OPCACHE_INTERNED_STRINGS_BUFFER | 128 |
PHP_OPCACHE_MAX_ACCELERATED_FILES | 65406 |
PHP_OPCACHE_MAX_WASTED_PERCENTAGE | 15 |
PHP_OPCACHE_VALIDATE_TIMESTAMPS | 0 |
PHP_OPCACHE_SAVE_COMMENTS | 1 |
PHP_OPCACHE_VALIDATE_TIMESTAMPS=0is tuned for immutable production images: code changes are not picked up until the container restarts. Set it to1for development with mounted source code.
PHP-FPM
| Variable | Default |
|---|---|
PHP_FPM_PM_MAX_CHILDREN | 50 |
PHP_FPM_PM_START_SERVERS | 20 |
PHP_FPM_PM_MIN_SPARE_SERVER | 10 |
PHP_FPM_PM_MAX_SPARE_SERVERS | 30 |
Nginx
| Variable | Default | Description |
|---|---|---|
NGINX_FASTCGI_READ_TIMEOUT | 60s | Timeout between reads from PHP-FPM |
NGINX_CLIENT_MAX_BODY_SIZE | 50m | Max request body (keep in line with PHP_POST_MAX_SIZE) |
NGINX_SET_REAL_IP_FROM | 127.0.0.1 | Trusted proxy address(es) for the real client IP |
NGINX_WORKER_CONNECTIONS | 4096 | Connections per worker |
NGINX_WORKER_RLIMIT_NOFILE | 65535 | Open file limit per worker |
80 | HTTP (Nginx) |
/var/www/html | Application root (Nginx serves public/) |
/docker-entrypoint.d/ | Executable startup scripts, run before Supervisor starts the services |
Per-version details (exact package versions, build arguments, full extension list) are in the version folders of the GitHub repository.
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