Skip to content

A set of highly configurable PHP-FPM images based on PHP Alpine version, enriched with composer

License

Notifications You must be signed in to change notification settings

yannoff/docker-php-fpm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yannoff/docker-php-fpm

Home for yannoff/php-fpm dockerhub repository sources.

A PHP-FPM docker image based on Alpine, with composer and offenbach installed.

Available tags

(1) Those PHP versions have now reached their EOL.
(2) yamltools version frozen to 1.3.3 (see yamltools#0abfdf7).

Usage

Building custom images

Dynamic builds allow for flexible, fine-tuned and featherweight images.
The recommended way is to use the repository URL as build context.

Example: Integration in a docker-compose stack

  • PHP version 8.0
  • gd and imap extensions
  • patch extra package install
  • Europe/Rome as timezone
  • laravel/installer as a composer global package
  • preview version of composer
# docker-compose.yaml
fpm:
    build:
        context: https://github.com/yannoff/docker-php-fpm.git#:8.0
        args:
            TZ: Europe/Rome
            PHP_EXTS: gd imap
            APK_EXTRA: patch
            PHP_LIBS: laravel/installer
            COMPOSER_VERSION: preview

Alternatively, building from the command-line:

docker                                     \
    build                                  \
    -t php8.0                              \
    --build-arg TZ="Europe/Rome"           \
    --build-arg PHP_EXTS="gd imap"         \
    --build-arg APK_EXTRA=patch            \
    --build-arg PHP_LIBS=laravel/installer \
    --build-arg COMPOSER_VERSION=preview   \
    git@github.com:yannoff/docker-php-fpm.git#:8.0

Build arguments reference

The following build arguments are available:

Build arg Description Defaults
TZ The timezone to use for the container UTC
PHP_EXTS PHP extensions to be installed at build time (3) pdo_mysql pdo_pgsql intl opcache bcmath
APK_BASE Base alpine packages to be installed at build time bash git vim
APK_EXTRA Extra alpine packages to be installed at build time -
PHP_LIBS PHP libraries to be installed as composer global dependencies -
COMPOSER_VERSION Major composer version to be installed 2

(3) See the mlocati/docker-php-extension-installer repository for the full list of supported extensions.

Using base images

On the other hand, the base pre-compiled images from dockerhub may be convenient to run php or composer commands on the fly, providing a minimal PHP ecosystem.

Example: Creating a new laravel empty project

docker                  \
    run                 \
    --rm                \
    -it                 \
    -u $UID:$GID        \
    -w /src             \
    -v $PWD:/src        \
    yannoff/php-fpm:8.0 \
    composer create-project --ignore-platform-reqs laravel/laravel acme

Since the base image may not contain all of the required PHP extensions, the --ignore-platform-reqs switch is recommended

Pre-compiled images defaults

Pre-compiled images are built with the following default values:

Build arg Value
TZ Europe/Paris
PHP_EXTS intl opcache
APK_BASE bash git vim
COMPOSER_VERSION 2

Credits

Licensed under the MIT License.

This project uses the awesome mlocati/docker-php-extension-installer script for PHP extensions install.

About

A set of highly configurable PHP-FPM images based on PHP Alpine version, enriched with composer

Topics

Resources

License

Stars

Watchers

Forks