Sign inSign up

lampelk/php-cli

By lampelk

•Updated 4 days ago

PHP 8.5.12 CLI for Symfony workers, consumers & cron in production: intl, gd, redis, amqp & more.

Image
0

1.4K

lampelk/php-cli repository overview

⁠lampelk/php-cli

A production PHP CLI image for running Symfony (and other PHP) console commands, message consumers, workers and scheduled jobs. It's built on the official php:8.5.12-cli⁠ image (Debian 13 trixie) and has the same extensions and configuration as lampelk/php-fpm⁠, so web and worker containers behave the same.

For local tooling (Composer, Symfony CLI, Xdebug), use lampelk/php-cli-dev⁠.

⁠Tags

TagDescription
latestCurrent stable build (PHP 8.5.12). Rebuilt on every change and for each PHP security release.

Any other tag is a pre-release build of work in progress. Don't use one in production.

latest moves. For reproducible deploys, pin the image by digest, for example image@sha256:…. Then bump the digest when a new build is published.

⁠Usage

Run a one-off command against your app:

docker run --rm -v "${PWD}:/var/www/html" lampelk/php-cli:latest php bin/console about
⁠As a base image for a worker
FROM composer:latest AS composer

FROM lampelk/php-cli:latest
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
COPY . /var/www/html
RUN composer install --no-dev --optimize-autoloader --no-interaction

CMD ["php", "bin/console", "messenger:consume", "async", "--time-limit=3600"]

The working directory is /var/www/html. pcntl is enabled, so Symfony Messenger workers shut down cleanly on SIGTERM.

⁠PHP extensions

ExtensionNotes
amqpRabbitMQ / Amazon MQ. The Amazon Root CA is at /var/certs/amazon-root-ca.pem
apcu
gdWith FreeType, JPEG and WebP support
intl
memcached
mysqli, pdo_mysql
opcacheEnabled
pcntl
redis
xsl
zip

The upstream defaults (curl, mbstring, openssl, sodium, pdo_sqlite, xml, …) are also included. Run php -m inside the container for the full list.

Build tools and -dev headers are kept in the image, so you can add more extensions in your own Dockerfile with docker-php-ext-install or pecl install.

⁠Configuration

SettingValue
memory_limit512M
expose_phpOff
session.upload_progress.enabled0
fatal_error_backtraces0

To override settings, add your own .ini to /usr/local/etc/php/conf.d/, for example:

RUN echo 'memory_limit = 1G' > /usr/local/etc/php/conf.d/zz-app.ini

⁠Security updates

These images are rebuilt from the official PHP⁠ and nginx⁠ images. Each build picks up the latest upstream and Debian security fixes, and the PHP version is bumped for every PHP security release. To get a fix, pull and redeploy. Running containers are not updated automatically.

ImagePurpose
lampelk/php-fpm⁠PHP-FPM for web apps in production
lampelk/php-cli⁠PHP CLI for workers, consumers and cron in production
lampelk/php-fpm-dev⁠php-fpm + Xdebug, Composer and Symfony CLI for local development
lampelk/php-cli-dev⁠php-cli + Xdebug, Composer and Symfony CLI for local development
lampelk/nginx⁠Hardened nginx to sit in front of php-fpm

⁠License

Released under the MIT License.

Tag summary

Content type

Image

Digest

sha256:196acf987…

Size

252.5 MB

Last updated

4 days ago

docker pull lampelk/php-cli