This project is a Dagger module for building custom PHP packages and container images.
It automates the process of downloading PHP source code, building Debian packages (.deb), and assembling
multi-platform container images pushed to Docker Hub.
The primary goal is to provide a reproducible and scalable way to generate PHP containers based on Debian distributions for each major/minor version of PHP from 7.0+ upwards. The aim is for PHP module development/debuging purposes.
Key goals:
- all versions build for a single consistent Debian distribution (currently Bookworm)
- scheduled rebuild every week on to refresh each version to ensure up to date container images
- build both NTS and ZTS versions
- build for both amd64 and arm64 architectures
- Dagger CLI
- Docker or a compatible container runtime
Download PHP source archive:
dagger call \
--distribution bookworm --version 8.5.1 \
download-php-source \
export --path work/php-8.5.1.tar.gzBuild packages, defaulting architecture to the current architecture:
dagger call \
--distribution bookworm --version 8.5.1 \
build-php-packages --source-archive work/php-8.5.1.tar.gz \
export --path build/php-8.5.1Build ZTS version
dagger call \
--distribution bookworm --version 8.5.1+zts \
build-php-packages --source-archive work/php-8.5.1.tar.gz \
export --path build/php-8.5.1Cross compile to multiple architectures
dagger call \
--distribution bookworm --version 8.5.1 \
build-php-packages --source-archive work/php-8.5.1.tar.gz --architectures="amd64,arm64" \
export --path build/php-8.5.1Cache bursting:
dagger call \
--distribution bookworm --version 8.5.1 --burst-cache=true \
build-php-packages --source-archive work/php-8.5.1.tar.gz \
export --path build/php-8.5.1Build container images:
dagger call \
--distribution bookworm --version 8.5.1 \
build-php-image --package-directory=build/php-8.5.1 --push=trueBuild multiple architectures of container images (the current architecture will always be added if not included and will be built first):
dagger call \
--distribution bookworm --version 8.5.1 \
build-php-image --package-directory=build/php-8.5.1 --push=true --architectures="amd64,arm64"