Skip to main content

Building the image

Docker PHP Image uses buildah to build a compatible OCI container image.

The image is compatible to all platforms, and it is capable to run on docker, podman, kubernetes and any other compatible with the OCI specification.

Preparing the environment

Requirements:

  • Python 3.x
  • buildah

There is no necessary have docker installed, however you need to have the buildah on your machine.

If you are using an ubuntu/debian system you can use the provided script install-buildah-ubuntu.sh to install it.

Command to build

usage: build.py [-h] [--debug] [--build-base]
[--build-cli] [--build-fpm]
[--build-fpm-apache] [--build-fpm-nginx]
[--push]
version

You can build one image only, but you need to make sure you have the base on your machine.

The configuration file

The configuration for each environment is in the folder config and it is a yaml file like this:

# The base image to use
image: alpine:edge

# (Optional) If we are getting packages from other resources define here
repositories:
- https://dl-cdn.alpinelinux.org/alpine/edge/testing

# The PHP Version
version:
major: 8
minor: 0

# List of extensions to be installed
extensions:
- (NAME)
- (NAME)

# The PECL extensions to be installed
pecl:
- name: xdebug # required
version: 2.5.5 # optional - if not set get the latest
install: False # optional - do not call pecl install
zend: True # optional - if true, add as zend extension
config: # optional - if set add extra config to php.ini
- xdebug.remote_port=9001 # for this extension

# Composer packages to be installed
composer:
packages:
- phpunit/phpunit:*
- squizlabs/php_codesniffer:*
- phpmd/phpmd:@stable
links:
- phpunit
- phpcs
- phpbcbf
- phpmd

# Temporary Packages to be used to build the PECL packages
peclBuildPackages:
- autoconf
- build-base

# Permanent packages to be installed in the image
additionalPackages:
- libssl1.1
- libcrypto1.1

Example

Build the images

docker run -it --privileged -v /tmp/z:/var/lib/containers -v $PWD:/work -w /work byjg/k8s-ci:latest bash
pip install -r requirements.txt
python3 ./build.py 8.2 --arch amd64 --build-base --build-fpm --build-nginx --debug

Check images

buildah images
buildah rmi ...