Foundational PHP images. Multi-arch Alpine-based builds for CLI, FPM, and Supervisord.
100K+
The docker-php-base project is a system for creating and maintaining PHP Docker images.
It uses Ansible to generate Dockerfiles for multiple PHP versions (7.4, 8.0, 8.1, 8.2, 8.3, 8.4) and types (CLI, FPM, Supervisord) on Alpine Linux.
The project automates the build process using GitHub Actions, creating multi-architecture images (AMD64 and ARM64) that are tested with gossโ .
Images come pre-configured with a wide array of PHP extensions and are designed to serve as a base for PHP applications in both development and production environments.
If you like/use this package, please consider โญ๏ธ starring it. Thanks!
The images come with a variety of pre-installed PHP extensions:
| Extension | Description | Type |
|---|---|---|
| intlโ | Internationalization functions | native |
| pcntlโ | Process control | native |
| socketsโ | Socket communication functions | native |
| pdo_pgsqlโ | PostgreSQL functions | native |
| pdo_mysqlโ | MySQL functions | native |
| opcacheโ | Improves PHP performance by storing precompiled script bytecode in shared memory | native |
| zipโ | Read/write functions for ZIP archives | native |
| bcmathโ | For arbitrary precision mathematics | native |
| exifโ | Exchangeable image information | native |
| gdโ | Image processing and manipulation library | native |
| redisโ | Functions for interfacing with Redis | pecl |
| memcachedโ | Functions for interfacing with Memcached | pecl |
| decimalโ | Arbitrary precision floating-point decimal | pecl |
| amqpโ | Advanced Message Queuing Protocol (AMQP) library | pecl |
| yamlโ | YAML library | pecl |
| grpcโ | gRPC library | pecl |
| protobufโ | Protocol Buffers library | pecl |
The PHP base images are available on both Docker Hub and GitHub Container Registry (ghcr.io). You can pull the images using either of the following methods:
docker pull wayofdev/php-base:8.3-fpm-alpine-latest
docker pull ghcr.io/wayofdev/docker-php-base:8.3-fpm-alpine-latest
Replace 8.3-fpm-alpine-latest with your desired PHP version, type, and tag.
The images are available in various combinations of PHP versions, types, and architectures:
# PHP 8.1 CLI
docker pull wayofdev/php-base:8.1-cli-alpine-latest
# PHP 8.2 FPM
docker pull wayofdev/php-base:8.2-fpm-alpine-latest
# PHP 8.3 with Supervisord
docker pull wayofdev/php-base:8.3-supervisord-alpine-latest
For a complete list of available tags, please refer to the Docker Hub Tagsโ or GitHub Container Registry Packagesโ page.
To use these images as a base for your own Dockerfile:
# From Docker Hub
FROM wayofdev/php-base:8.3-fpm-alpine-latest
# Or from GitHub Container Registry
# FROM ghcr.io/wayofdev/docker-php-base:8.3-fpm-alpine-latest
# Your additional Dockerfile instructions here
# ...
This project uses a set of tools for development and testing. The Makefile provides various commands to streamline the development process.
Clone the repository:
git clone [email protected]:wayofdev/docker-php-base.git && \
cd docker-php-base
Ansible is used to generate Dockerfiles and configurations. To generate distributable Dockerfiles from Jinja template source code:
make generate
Build the default image:
make build
This command builds the image specified by the IMAGE_TEMPLATE variable in the Makefile. By default, it's set to 8.3-fpm-alpine.
Build a specific image:
make build IMAGE_TEMPLATE="8.3-fpm-alpine"
Replace 8.3-fpm-alpine with your desired PHP version, type, and OS.
Build all images:
make build IMAGE_TEMPLATE="8.1-cli-alpine"
make build IMAGE_TEMPLATE="8.1-fpm-alpine"
make build IMAGE_TEMPLATE="8.1-supervisord-alpine"
make build IMAGE_TEMPLATE="8.2-cli-alpine"
make build IMAGE_TEMPLATE="8.2-fpm-alpine"
make build IMAGE_TEMPLATE="8.2-supervisord-alpine"
make build IMAGE_TEMPLATE="8.3-cli-alpine"
make build IMAGE_TEMPLATE="8.3-fpm-alpine"
make build IMAGE_TEMPLATE="8.3-supervisord-alpine"
make build IMAGE_TEMPLATE="8.4-cli-alpine"
make build IMAGE_TEMPLATE="8.4-fpm-alpine"
make build IMAGE_TEMPLATE="8.4-supervisord-alpine"
These commands will build all supported image variants.
Ansible is used to generate distribution files. To add or remove PHP extensions, or configure the project, you can modify the src/group_vars/base.ymlโ file.
You can adjust the following PHP and OPcache settings in the group_vars/base.yml file:
settings_opcache_ini:
php_opcache_enable: 1
php_opcache_enable_cli: 1
settings_php_ini:
php_timezone: "UTC"
php_post_max_size: "16M"
php_memory_limit: "256M"
You can enable or disable PHP extensions by modifying the following sections in the group_vars/base.yml file:
ext_native_enabled:
- intl
- pcntl
- sockets
- pdo_mysql
- pdo_pgsql
- OPcache
- zip
- bcmath
- exif
- gd
ext_pecl_enabled:
- redis
- memcached
- decimal
- amqp
- yaml
- grpc
- protobuf
To add a new extension, simply add it to the appropriate list. To remove an extension, delete it from the list.
After making changes to the group_vars/base.yml file, you need to regenerate the Dockerfiles:
make generate
This command will use Ansible to process the updated configuration and generate new Dockerfiles with your custom settings.
This project uses a testing approach to ensure the quality and functionality of the Docker images. The primary testing tool is dgossโ , which allows for testing Docker containers.
You can run tests using the following commands:
Test the default image:
make test
This command tests the image specified by the IMAGE_TEMPLATE variable in the Makefile (default is 8.3-fpm-alpine).
Test a specific image:
make test IMAGE_TEMPLATE="8.3-fpm-alpine"
Replace 8.3-fpm-alpine with your desired PHP version, type, and OS.
Test all images:
make test IMAGE_TEMPLATE="8.1-cli-alpine"
make test IMAGE_TEMPLATE="8.1-fpm-alpine"
make test IMAGE_TEMPLATE="8.1-supervisord-alpine"
make test IMAGE_TEMPLATE="8.2-cli-alpine"
make test IMAGE_TEMPLATE="8.2-fpm-alpine"
make test IMAGE_TEMPLATE="8.2-supervisord-alpine"
make test IMAGE_TEMPLATE="8.3-cli-alpine"
make test IMAGE_TEMPLATE="8.3-fpm-alpine"
make test IMAGE_TEMPLATE="8.3-supervisord-alpine"
make test IMAGE_TEMPLATE="8.4-cli-alpine"
make test IMAGE_TEMPLATE="8.4-fpm-alpine"
make test IMAGE_TEMPLATE="8.4-supervisord-alpine"
The test configurations are defined in goss.yaml files, which are generated for each image variant. These files specify the tests to be run, including:
When you run the make test command, the following steps occur:
goss.yaml file against the Docker container.This project has a security policyโ .
Thank you for considering contributing to the wayofdev community! We are open to all kinds of contributions. If you want to:
You are more than welcome. Before contributing, kindly check our contribution guidelinesโ .
Content type
Image
Digest
sha256:3cd213490โฆ
Size
87.5 MB
Last updated
about 14 hours ago
docker pull wayofdev/php-base:8.4-supervisord-alpine-latestPulls:
2,059
Last week