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.
- Most extensions are compiled and ready for loading with
docker-php-ext-enable
- Git client from official debian repo
- Latest binaries of Composer, PHPUnit and PHP Code Sniffer (
phpcs
andphpcbf
) - Node.js v12, v14 or v20 by default using the
n
Node version manager, withnpm
,yarn
andn
pre-installed - sendmail command via msmtp, configured as relay to localhost. Check
/etc/msmtprc
to setup relay server
Images are available on the following registries:
- GitHub Container Registry (pull using
ghcr.io/stayallive/php:8.3
) - GitLab Container Registry (pull using
registry.gitlab.com/stayallive/php:8.3
) - Docker Hub (pull using
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.
List of compiled-in extensions (enabled by default)
- ctype
- curl
- date
- dom
- fileinfo
- filter
- ftp
- hash
- iconv
- json
- libxml
- mbstring
- mysqlnd
- openssl
- pcre
- pdo
- pdo_sqlite
- phar
- posix
- readline
- reflection
- session
- simplexml
- sodium
- spl
- sqlite3
- standard
- tokenizer
- xml
- xmlreader
- xmlwriter
- zlib
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
Available extensions
- bcmath
- bz2
- calendar
- dba
- exif
- ffi
- ftp
- gd
- gettext
- gmp
- imap
- intl
- ldap
- mysqli
- opcache
- pcntl
- pdo
- pdo_dblib
- pdo_mysql
- pdo_pgsql
- pgsql
- pspell
- shmop
- snmp
- soap
- sockets
- sysvmsg
- sysvsem
- sysvshm
- tidy
- xsl
- zip
Available PECL extensions
- amqp
- igbinary
- imagick
- mongodb
- redis
- xdebug (not available for PHP 8.2 yet)
Enables xdebug extension (disabled by default)
Set system and php.ini
timezone. You can also set timezone in .gitlab-ci.yml - check Example
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
Easiest 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 ...
.