Sign inSign up

vinhphon/php

By vinhphon

•Updated over 1 year ago

The smallest possible size is achievable with installed extensions.

Image
2

3.1K

vinhphon/php repository overview

The PHP Docker Alpine images support PHP 5.6->8.x and can be used to build Dockerfiles for PHP cli and fpm. By installing the necessary extensions, it's possible to achieve the smallest possible size.

⁠Features

  • PHP extensions installed via the mlocati/docker-php-extension-installer⁠ tool, allowing you to easily add php extensions with redundant lib, keep layer smallest.
  • Run as non-root user for improved security. (www UID=1000/GID=1000)
  • Rootless crontab for running cron jobs without requiring root privileges on cli images
  • Enable cron and installed extensions via env PHP_EXTENSIONS and CRONTAB
  • Trick to run enable extensions without download alpine packages.

⁠Usage

Supported extensions from mlocati/docker-php-extension-installer⁠

1. Built images on docker hub with tags (arm64/amd64):

  • main: vinhphon/php:{version}-cli, vinhphon/php:{version}-fpm
  • dev: vinhphon/php:{version}-dev-cli, vinhphon/php:{version}-dev-fpm

Installed extension is enabled as by default, you can change enabled by changing env

docker run -e PHP_EXTENSIONS="..." -e CRONTAB="..." --rm vinhphon/php:8.2-cli php -m

2. Rebuild images Clone GitHub repository⁠, then go to cli/fpm folder execute:

    docker build -t your-image-tag \
    --build-arg SOURCE_ROOT="your working dir" \
    --build-arg VERSION="php version" \
    --build-arg EXTENSIONS="extensions, seperate by space" \
    --build-arg COMPOSER_VERSION="composer version (cli)" \
    --build-arg CRONTAB="composer version (cli)" \
    --build-arg UID="userID" \
    --build-arg GID="groupID" .

3. Extend built images:

In case you want to add more extension with faster build time, you can ref "dev" branch or refer Dockerfile.cli.extend.sample⁠, Dockerfile.fpm.extend.sample⁠

Then you can use rebuild command on #1 for.

⁠Built images php extensions

* 5.6 -> 7.1: bcmath bz2 calendar exif gd gettext intl mysqli mcrypt opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl

* 7.2 -> 8.x: bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl

⁠Contributing

Contributions are always welcome! If you'd like to contribute, please open an issue or pull request on the GitHub repository⁠.

⁠License

This project is licensed under the MIT License.

Tag summary

Content type

Image

Digest

sha256:3d799a714…

Size

74.7 MB

Last updated

over 1 year ago

docker pull vinhphon/php:8.4-cli