Docker base image is the basic image on which you add layers (which are basically filesystem changes) and create a final image containing your App.
Use Official PHP Docker image as parent.
Use Supervisor as manager for Webserver and PHP-FPM. Supervisord is therefore process 1.
Run container as non-privileged.
Container Entrypoint hooks available.
- Installation of Nginx.
- Installation of Apache 2.4.
- Installation of Varnish.
You must install make
, m4
.
make Dockefile
make build[-fpm|-apache|-nginx|-cli|-all][-dev] [ PHP_VERSION=<PHP Version you want to build> ] \
[ DOCKER_IMAGE_NAME=<PHP Docker Image Name you want to build> ] \
[ NODE_VERSION=<NodeJS Version> ] \
[ COMPOSER_VERSION=<Composer Version> ] \
[ AWS_CLI_VERSION=<AWS CLI Version> ] \
[ PHP_EXT_REDIS_VERSION=<PHP Extension Redis Version> ] \
[ PHP_EXT_APCU_VERSION=<PHP Extension APCu Version> ] \
[ PHP_EXT_XDEBUG_VERSION=<PHP Extension XDebug Version> ]
Default value of Docker build arguments is grabbed from the .build.env file if it is present, otherwise Docker build will use the default values available in the Dockerfile. Default values can be also overridden via the make command line.
make build-fpm PHP_VERSION=8.1.25
Provide docker image : docker.io/elasticms/base-php:8.1.25-fpm-prd
make build-fpm PHP_VERSION=8.1.25 DOCKER_IMAGE_NAME=docker.io/lambdauser/mybasephpimage
Provide docker image : docker.io/lambdauser/mybasephpimage:8.1.25-fpm-prd
make build-fpm-dev PHP_VERSION=8.1.25
Provide docker image : docker.io/elasticms/base-php:8.1.25-fpm-dev
make build-nginx-dev PHP_VERSION=8.1.25
Provide docker image : docker.io/elasticms/base-php:8.1.25-nginx-dev
make build-all PHP_VERSION=8.1.25
Provide docker images :
docker.io/elasticms/base-php:8.1.25-fpm-prd
docker.io/elasticms/base-php:8.1.25-fpm-dev
docker.io/elasticms/base-php:8.1.25-apache-prd
docker.io/elasticms/base-php:8.1.25-apache-dev
docker.io/elasticms/base-php:8.1.25-nginx-prd
docker.io/elasticms/base-php:8.1.25-nginx-dev
docker.io/elasticms/base-php:8.1.25-cli-prd
docker.io/elasticms/base-php:8.1.25-cli-dev
You must install bats
, docker
, docker-compose
and create a local network called docker_default
.
make test[-fpm|-apache|-nginx|-cli|-all][-dev] PHP_VERSION=<PHP Version you want to test>
make test PHP_VERSION=8.1.25
make test-dev PHP_VERSION=8.1.25
Releases are done via GitHub actions and uploaded on Docker Hub.
8.1.x-fpm
,8.1-fpm
,8.1.x-fpm-prd
,8.1-fpm-prd
,8.1.y-fpm-dev
,8.1-fpm-dev
8.1.x-apache
,8.1-apache
,8.1.x-apache-prd
,8.1-apache-prd
,8.1.y-apache-dev
,8.1-apache-dev
8.1.x-nginx
,8.1-nginx
,8.1.x-nginx-prd
,8.1-nginx-prd
,8.1.y-nginx-dev
,8.1-nginx-dev
8.1.x-cli
,8.1-cli
,8.1.x-cli-prd
,8.1-cli-prd
,8.1.y-cli-dev
,8.1-cli-dev
The docker.io/elasticms/base-php
images come in many flavors, each designed for a specific use case.
This image is based and use the official PHP Docker Hub image docker.io/php:8.1.x-fpm-alpine3.16
as parent.
It is configured and configurable to support any PHP application.
It use the default php.ini-production configuration files and Supervisor to help automate the Docker image.
- Supervisor
- Varnish
- PHP Extensions :
- AWS CLI
This image use base-php:<version>-fpm-prd
(see above) as parent layer.
It use the default php.ini-development configuration files.
It is strongly recommended to not use this image in production environments!
In addition to the parent layer, this variant include install :
This image use base-php:<version>-fpm-prd
(see above) as parent layer.
This variant contains Apache httpd in conjunction with PHP-FPM and uses supervisor as manager for Apache and PHP-FPM.
This image use base-php:<version>-fpm-prd
(see above) as parent layer.
This variant contains Nginx Webserver in conjunction with PHP-FPM and uses supervisor as manager for Nginx and PHP-FPM.
This variant contains the PHP CLI tool with default mods. In addition we install and configure :
This image use base-php:<version>-fpm-dev
(see above) as parent layer.
This variant contains Apache Webserver in conjunction with PHP-FPM and uses supervisor as manager for Apache and PHP-FPM.
It is strongly recommended to not use this image in production environments!
This image use base-php:<version>-fpm-dev
(see above) as parent layer.
This variant contains Nginx Webserver in conjunction with PHP-FPM and uses supervisor as manager for Nginx and PHP-FPM.
It is strongly recommended to not use this image in production environments!
This image use base-php:<version>-cli-prd
(see above) as parent layer.
In addition to the parent layer, this variant include install :
They will be removed soon, please update your dockerfiles and docker-compose.yml files ...
Deprecated Image Name | Replaced Image Name |
---|---|
docker.io/elasticms/base-php-fpm:<version> |
docker.io/elasticms/base-php:<version>-fpm[-prd] |
docker.io/elasticms/base-php-dev:<version> |
docker.io/elasticms/base-php:<version>-fpm-dev |
docker.io/elasticms/base-apache-fpm:<version> |
docker.io/elasticms/base-php:<version>-apache[-prd] |
docker.io/elasticms/base-apache-dev:<version> |
docker.io/elasticms/base-php:<version>-apache-dev |
docker.io/elasticms/base-nginx-fpm:<version> |
docker.io/elasticms/base-php:<version>-nginx[-prd] |
docker.io/elasticms/base-nginx-dev:<version> |
docker.io/elasticms/base-php:<version>-nginx-dev |
docker.io/elasticms/base-php-cli:<version> |
docker.io/elasticms/base-php:<version>-cli[-prd] |
docker.io/elasticms/base-php-cli-dev:<version> |
docker.io/elasticms/base-php:<version>-cli-dev |
Update (21/06/2023) - Starting from version v8.1.20, the images mentioned above are no longer being updated or supported.
You can change the amount of memory that PHP-FPM can use by changing / passing the environment variables PHP_FPM_MAX_CHILDREN
and PHP_FPM_REQUEST_MAX_MEMORY_IN_MEGABYTES
.
These values can be overridden automatically by the startup script if a QoS memory limit is applied and detected in your container.
However, this value can be reduced to a percentage by the configuration of the environment variable CONTAINER_HEAP_PERCENT
(default: 80 %).
Name | Default Value | Description |
---|---|---|
PHP_FPM_MAX_CHILDREN_AUTO_RESIZING |
true |
Enable auto-resizing of PHP-FPM Pool Memory settings based on container size. |
PHP_FPM_MAX_CHILDREN |
40 |
The maximum number of child processes to be created. (doc) |
PHP_FPM_REQUEST_MAX_MEMORY_IN_MEGABYTES |
16 |
The maximum amount of memory in MB that a script is allowed to allocate. (doc) |
CONTAINER_HEAP_PERCENT |
0.80 |
Percentage of total memory allowed to use by PHP-FPM. |
Name | Default Value | Description |
---|---|---|
VARNISH_ENABLED |
false |
Enable Varnish. Listen on 6081 for HTTP proto when Varnish is enabled. Management interface is available on 6082 . |
VARNISH_STORAGE_MALLOC_CUSTOM_SIZE |
200M |
Malloc is a memory based backend. Each object will be allocated from memory. If your system runs low on memory swap will be used. (doc) |
VARNISH_NCSA_LOG_FORMAT_CUSTOM |
%%h %%l %%u %%t %%D \"%%r\" %%s %%b %%{Varnish:hitmiss}x \"%%{User-agent}i\" |
The varnishncsa utility reads varnishd(1) shared memory logs and presents them in the Apache / NCSA “combined” log format. (doc) |
VARNISH_TTL_CUSTOM |
120 |
Specifies the default time to live (TTL) for cached objects. This is a shortcut for specifying the default_ttl run-time parameter. (doc) |
VARNISH_MIN_THREADS_CUSTOM |
5 |
The minimum number of worker threads in each pool. (doc) |
VARNISH_MAX_THREADS_CUSTOM |
1000 |
The maximum number of worker threads in each pool. (doc) |
VARNISH_THREAD_TIMEOUT_CUSTOM |
120 |
Thread idle threshold. (doc) |
VARNISH_VCL_CONF_CUSTOM |
/etc/varnish/default.vcl |
Use the specified file location as VCL configuration instead of the builtin default. You must provide this file or generate it at container startup. (doc) |