PHP Docker images for continuous integration and running tests. These images were created for using with Gitlab CI but should work on other platforms too.
These images are built from official PHP Docker images, and additionally include:
This repository started as a fork of TetraWeb/docker, huge thanks to them for the initial work.
docker-php-ext-enable
phpcs
and phpcbf
)n
Node version manager, with npm
, yarn
and n
pre-installed/etc/msmtprc
to setup relay serverImages are available on the following registries:
ghcr.io/stayallive/php:8.3
)registry.gitlab.com/stayallive/php:8.3
)stayallive/php:8.3
)They are listed as stayallive/php
and tagged by PHP version for both linux/amd64
& linux/arm64
.
stayallive/php:8.3
(8.3.Dockerfile) (Node 20 & LTS)stayallive/php:8.2
(8.2.Dockerfile) (Node 14 & LTS)stayallive/php:8.1
(8.1.Dockerfile) (Node 14 & LTS)stayallive/php:8.0
(8.0.Dockerfile) (Node 14 & LTS)stayallive/php:7.4
(7.4.Dockerfile) (Node 14, no longer being built)stayallive/php:7.3
(7.3.Dockerfile) (Node 12, no longer being built)stayallive/php:7.2
(7.2.Dockerfile) (Node 12, no longer being built)stayallive/php:7.1
(7.1.Dockerfile) (Node 12, no longer being built)stayallive/php:7.0
(7.0.Dockerfile) (Node 12, no longer being built)Keep in mind that although there might be a tag available it doesn't mean the PHP version is still supported, see supported PHP versions for more information.
Starting with the PHP 8 images the n
Node version manager is installed.
Pre-cached is Node 14
/20
and LTS
with 14
/20
set as the default (see PHP versions list which Node version is the default). To use the LTS
version run n lts
in for example your .gitlab-ci.yml
before_script
section:
before_script:
- n lts
You can use n
to install any other Node version you need, but they will be downloaded each run and will not be pre-cached inside the image.
Some extensions are enabled by default (compiled-in) and some you have to enable when needed.
Enable the extensions below by calling docker-php-ext-enable
in for example your .gitlab-ci.yml
before_script
section:
before_script:
# We enable bcmath, gd and intl here for example but you
# can enable any extension or PECL extension listed below
- docker-php-ext-enable bcmath gd intl
WITH_XDEBUG=1
Enables xdebug extension (disabled by default)
TIMEZONE=Europe/Amsterdam
Set system and php.ini
timezone. You can also set timezone in .gitlab-ci.yml - check Example
COMPOSER_GITHUB=<YOUR_GITHUB_TOKEN>
Adds GitHub OAuth token for Composer which allows composer to get unlimited repositories from GitHub without blocking non-interactive mode with request for authorization.
You can obtain your token at https://github.com/settings/tokens (no scopes are required).
See: Composer documentation about GitHub API rate limits
php.ini
valuesEasiest way is to add your php.ini directives to /usr/local/etc/php/conf.d/[anyname].ini
.
Another way is to mount your local php.ini on container start like docker run ... -v /home/user/php.ini:/usr/local/php/etc/php.ini ...
.