From 9dc6a1b9e8c284cceb55a33d39e6260a348c173b Mon Sep 17 00:00:00 2001 From: le0m Date: Mon, 27 Jul 2026 12:04:29 +0200 Subject: [PATCH 1/3] add image with open-telemetry PHP extension --- .github/workflows/publish.8.yml | 13 ++++ .github/workflows/publish.latest.yml | 13 ++++ .github/workflows/test.8.yml | 16 +++++ .github/workflows/test.latest.yml | 16 +++++ README.md | 5 ++ otel/Dockerfile | 6 ++ otel/Makefile | 80 ++++++++++++++++++++++++ otel/README.md | 93 ++++++++++++++++++++++++++++ 8 files changed, 242 insertions(+) create mode 100644 otel/Dockerfile create mode 100644 otel/Makefile create mode 100644 otel/README.md diff --git a/.github/workflows/publish.8.yml b/.github/workflows/publish.8.yml index 626a971..ba14ff8 100644 --- a/.github/workflows/publish.8.yml +++ b/.github/workflows/publish.8.yml @@ -101,3 +101,16 @@ jobs: chialab/php-xhprof:${{ matrix.version }}${{ matrix.flavor }} ghcr.io/chialab/php-xhprof:${{ matrix.version }}${{ matrix.flavor }} push: true + + - name: Build OTel image and push to registry + uses: docker/build-push-action@v5 + with: + platforms: linux/amd64,linux/arm64 + cache-to: type=inline + context: ./otel + build-args: | + BASE_IMAGE=ghcr.io/chialab/php:${{ matrix.version }}${{ matrix.flavor }} + tags: | + chialab/php-otel:${{ matrix.version }}${{ matrix.flavor }} + ghcr.io/chialab/php-otel:${{ matrix.version }}${{ matrix.flavor }} + push: true diff --git a/.github/workflows/publish.latest.yml b/.github/workflows/publish.latest.yml index 1f96e6f..6ca6e7f 100644 --- a/.github/workflows/publish.latest.yml +++ b/.github/workflows/publish.latest.yml @@ -100,3 +100,16 @@ jobs: chialab/php-xhprof:${{ matrix.version }} ghcr.io/chialab/php-xhprof:${{ matrix.version }} push: true + + - name: Build OTel image and push to registry + uses: docker/build-push-action@v5 + with: + platforms: linux/amd64,linux/arm64 + cache-to: type=inline + context: ./otel + build-args: | + BASE_IMAGE=ghcr.io/chialab/php:${{ matrix.version }} + tags: | + chialab/php-otel:${{ matrix.version }} + ghcr.io/chialab/php-otel:${{ matrix.version }} + push: true diff --git a/.github/workflows/test.8.yml b/.github/workflows/test.8.yml index bf39b1b..dcfade8 100644 --- a/.github/workflows/test.8.yml +++ b/.github/workflows/test.8.yml @@ -98,3 +98,19 @@ jobs: REGISTRY: localhost:5000/ VERSION: ${{ matrix.version }}${{ matrix.flavor }} run: 'docker pull localhost:5000/chialab/php-xhprof:${{ matrix.version }}${{ matrix.flavor }} && make -C xhprof test' + + - name: Build OTel image for testing + uses: docker/build-push-action@v5 + with: + cache-to: type=inline + context: ./otel + build-args: | + BASE_IMAGE=localhost:5000/chialab/php:${{ matrix.version }}${{ matrix.flavor }} + tags: localhost:5000/chialab/php-otel:${{ matrix.version }}${{ matrix.flavor }} + push: true + + - name: Test OTel image + env: + REGISTRY: localhost:5000/ + VERSION: ${{ matrix.version }}${{ matrix.flavor }} + run: 'docker pull localhost:5000/chialab/php-otel:${{ matrix.version }}${{ matrix.flavor }} && make -C otel test' diff --git a/.github/workflows/test.latest.yml b/.github/workflows/test.latest.yml index 27c0d0b..1f26956 100644 --- a/.github/workflows/test.latest.yml +++ b/.github/workflows/test.latest.yml @@ -97,3 +97,19 @@ jobs: REGISTRY: localhost:5000/ VERSION: ${{ matrix.version }} run: 'docker pull localhost:5000/chialab/php-xhprof:${{ matrix.version }} && make -C xhprof test' + + - name: Build OTel image for testing + uses: docker/build-push-action@v5 + with: + cache-to: type=inline + context: ./otel + build-args: | + BASE_IMAGE=localhost:5000/chialab/php:${{ matrix.version }} + tags: localhost:5000/chialab/php-otel:${{ matrix.version }} + push: true + + - name: Test OTel image + env: + REGISTRY: localhost:5000/ + VERSION: ${{ matrix.version }} + run: 'docker pull localhost:5000/chialab/php-otel:${{ matrix.version }} && make -C otel test' diff --git a/README.md b/README.md index 2eadef2..fef962f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ An automated build is set up, so they should be always up-to-date with the Docke For development environments, you might want to choose an [image with XDebug installed](https://hub.docker.com/r/chialab/php-dev/), or [one with XHProf](https://hub.docker.com/r/chialab/php-xhprof/), or another [with PCOV installed](https://hub.docker.com/r/chialab/php-pcov/), instead. +If you use Open Telemetry in your project, you may be interested in an [image with the OTel PHP extension](https://hub.docker.com/r/chialab/php-otel/). + If you are really desperate and need PHP 5.6 with support for MySQL 8.x, check the [php-compat](https://hub.docker.com/r/chialab/php-compat/) image. ## Available tags @@ -49,6 +51,9 @@ If you are really desperate and need PHP 5.6 with support for MySQL 8.x, check t - `8.4` - `8.4-apache` - `8.4-fpm` +- `8.5` +- `8.5-apache` +- `8.5-fpm` As you might have guessed, all tags are built on top of the corresponding tag of the official image. Not all tags are supported in order to easen maintenance. diff --git a/otel/Dockerfile b/otel/Dockerfile new file mode 100644 index 0000000..58f9aa0 --- /dev/null +++ b/otel/Dockerfile @@ -0,0 +1,6 @@ +ARG BASE_IMAGE=chialab/php:latest +FROM ${BASE_IMAGE} +LABEL maintainer="dev@chialab.io" + +# Install OpenTelemetry. +RUN install-php-extensions protobuf opentelemetry-php/ext-opentelemetry@1.3.1 diff --git a/otel/Makefile b/otel/Makefile new file mode 100644 index 0000000..7e63c46 --- /dev/null +++ b/otel/Makefile @@ -0,0 +1,80 @@ +SHELL := /bin/bash +ALL: build +.PHONY: build test push + +PARENT_IMAGE := chialab/php +IMAGE := chialab/php-otel +VERSION ?= latest +PHP_VERSION = $(firstword $(subst -, ,$(VERSION))) +PHP_MAJOR := $(shell echo $(PHP_VERSION) | grep -oE '^[0-9]+') +ifneq ($(PHP_MAJOR),) +ifeq ($(shell [ $(PHP_MAJOR) -lt 8 ] && echo yes),yes) +$(error PHP_VERSION '$(PHP_VERSION)' is not supported: this image requires PHP >= 8.0) +endif +endif + +# Extensions. +EXTENSIONS := \ + amqp \ + bcmath \ + bz2 \ + calendar \ + event \ + exif \ + gd \ + gettext \ + iconv \ + imagick \ + intl \ + ldap \ + mbstring \ + memcached \ + mysqli \ + OPcache \ + opentelemetry \ + pdo_mysql \ + pdo_pgsql \ + pgsql \ + redis \ + soap \ + xsl \ + zip \ + sockets + +build: + @echo " =====> Building $(REGISTRY)$(IMAGE):$(VERSION)..." + docker image build --quiet --build-arg 'BASE_IMAGE=$(PARENT_IMAGE):$(VERSION)' -t $(REGISTRY)$(IMAGE):$(VERSION) . + +test: + @echo -e "=====> Testing loaded extensions... \c" + @if [[ -z `docker image ls $(REGISTRY)$(IMAGE) | grep "\s$(VERSION)\s"` ]]; then \ + echo 'FAIL [Missing image!!!]'; \ + exit 1; \ + fi + @IMAGE_PHP_VERSION=`docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) sh -c '/bin/echo $$PHP_VERSION' | cut -d '.' -f 1,2`; \ + if [[ "$(PHP_VERSION)" != "latest" && "$(PHP_VERSION)" != "alpine" && "$${IMAGE_PHP_VERSION}" != "$(PHP_VERSION)" ]]; then \ + echo "FAIL [wrong PHP version: expected $(PHP_VERSION), got $${IMAGE_PHP_VERSION}]"; \ + exit 1; \ + fi + @modules=`docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) php -m`; \ + for ext in $(EXTENSIONS); do \ + if [[ "$${modules}" != *"$${ext}"* ]]; then \ + echo "FAIL [$${ext}]"; \ + exit 1; \ + fi \ + done + @if [[ "$(VERSION)" == *'-apache' ]]; then \ + apache=`docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) apache2ctl -M 2> /dev/null`; \ + if [[ "$${apache}" != *'rewrite_module'* ]]; then \ + echo 'FAIL [mod_rewrite]'; \ + exit 1; \ + fi \ + fi + @if [[ -z `docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) composer --version 2> /dev/null | grep '^Composer version 2\.[0-9][0-9]*'` ]]; then \ + echo 'FAIL [Composer]'; \ + exit 1; \ + fi + @echo 'OK' + +push: + docker image push $(REGISTRY)$(IMAGE):$(VERSION) diff --git a/otel/README.md b/otel/README.md new file mode 100644 index 0000000..778e6ee --- /dev/null +++ b/otel/README.md @@ -0,0 +1,93 @@ +

+ + Docker PHP Images logo + +

+ +

+ Docker PHP images +

+ +

+ GitHub Workflow Status + Source link + Authors link + Docker Pulls + License +

+ +--- + +Docker images built on top of the [official PHP images](https://hub.docker.com/r/_/php/) with the addition of some common and useful extensions, installed with [mlocati/docker-php-extension-installer](https://github.com/mlocati/docker-php-extension-installer), and are meant for *continuout integration purposes*. You can find these images on the [Docker Hub](https://hub.docker.com/r/chialab/php-otel/) (and if you're reading this file, you're probably already there). + +An automated build is set up, so they should be always up-to-date with the Dockerfiles in the [GitHub repository](https://github.com/chialab/docker-php). Also, every time an official PHP image is updated, a rebuild is triggered, so that you will always find the latest security patches installed in these images. + +## Available tags +- `latest` +- `8.0` +- `8.0-apache` +- `8.0-fpm` +- `8.1` +- `8.1-apache` +- `8.1-fpm` +- `8.2` +- `8.2-apache` +- `8.2-fpm` +- `8.3` +- `8.3-apache` +- `8.3-fpm` +- `8.4` +- `8.4-apache` +- `8.4-fpm` + +As you might have guessed, all tags are built on top of the corresponding tag of the official image. Not all tags are supported in order to easen maintenance. + +## Installed extensions +The following modules and extensions have been enabled, +in addition to those you can already find in the [official PHP image](https://hub.docker.com/r/_/php/): + +- `amqp` +- `bcmath` +- `bz2` +- `calendar` +- `event` +- `exif` +- `gd` +- `gettext` +- `iconv` +- `imagick` +- `intl` +- `ldap` +- `mbstring` +- `mcrypt` (_only PHP ≤ 7.1_) +- `memcached` +- `mysql` (_only PHP 5.x_) +- `mysqli` +- `opentelemetry` +- `pdo_mysql` +- `pdo_pgsql` +- `pgsql` +- `redis` +- `soap` +- `sockets` +- `xsl` +- `Zend OPcache` +- `zip` + +You will probably not need all this stuff. Even if having some extra extensions loaded ain't a big issue in most cases (especially in a development environment), you will very likely want to checkout this repository, remove unwanted extensions from the `Dockerfile`, and build your own image — for sometimes removing is easier than adding. 😉 + +## Composer +[Composer](https://getcomposer.org) is installed globally in all images. Please, refer to their documentation for usage hints. +Since 2020/11/01 both version 1 and 2 are installed, available through `composer1` and `composer2` commands respectively (`composer` in now a symlink to `composer2`). +[Prestissimo (composer plugin)](https://github.com/hirak/prestissimo) is installed globally in all images, for use with Composer version 1. It's a plugin that downloads packages in parallel to speed up the installation process of Composer packages. + +## Contributing +If you find an issue, or have a special wish not yet fulfilled, please [open an issue on GitHub](https://github.com/chialab/docker-php/issues) providing as many details as you can (the more you are specific about your problem, the easier it is for us to fix it). + +Pull requests are welcome, too! 😁 Please, run `make build` and `make test` before attempting a pull request. Also, it would be nice if you could stick to the [best practices for writing Dockerfiles](https://docs.docker.com/articles/dockerfile_best-practices/). + +--- + +## License + +Docker PHP Images is released under the [MIT](https://github.com/chialab/docker-php/blob/master/LICENSE) license. From f047a6c2c3af0eaf3ecd4d287e446f7c696dd567 Mon Sep 17 00:00:00 2001 From: le0m Date: Mon, 27 Jul 2026 13:06:36 +0200 Subject: [PATCH 2/3] fix debian stretch --- Dockerfile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fb372e7..3839a9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,7 +51,16 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update -q \ 5.6.*) PHP_EXTENSIONS="$PHP_EXTENSIONS mcrypt mysql";; \ 7.0.*|7.1.*) PHP_EXTENSIONS="$PHP_EXTENSIONS mcrypt";; \ esac \ - && install-php-extensions $PHP_EXTENSIONS \ + # On PHP Debian 9 (Stretch) amqp has a dependency on libssh-dev, which pulls in + # libssl1.0-dev, which conflicts with the libssl-dev version (1.1.0) needed by the + # other extensions. Installing amqp on its own so that install-php-extensions + # purges libssl1.0-dev before libssl-dev is installed for the rest. + && if [ "${PHP_VERSION%%.*}" = "7" ]; then \ + install-php-extensions amqp \ + && install-php-extensions $(echo "$PHP_EXTENSIONS" | sed 's/amqp//'); \ + else \ + install-php-extensions $PHP_EXTENSIONS; \ + fi \ && if command -v a2enmod; then a2enmod rewrite; fi # Install Composer. From 06718958ba6e0e1f2be8a88af57ce62e8e39ff9c Mon Sep 17 00:00:00 2001 From: le0m Date: Mon, 27 Jul 2026 13:52:08 +0200 Subject: [PATCH 3/3] fix otel version for PHP 8.0 --- otel/Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/otel/Dockerfile b/otel/Dockerfile index 58f9aa0..4ad18fd 100644 --- a/otel/Dockerfile +++ b/otel/Dockerfile @@ -2,5 +2,8 @@ ARG BASE_IMAGE=chialab/php:latest FROM ${BASE_IMAGE} LABEL maintainer="dev@chialab.io" -# Install OpenTelemetry. -RUN install-php-extensions protobuf opentelemetry-php/ext-opentelemetry@1.3.1 +RUN if [ "$(echo "$PHP_VERSION" | cut -d. -f1,2)" = "8.0" ]; then \ + install-php-extensions protobuf opentelemetry-php/ext-opentelemetry@1.1.3; \ + else \ + install-php-extensions protobuf opentelemetry-php/ext-opentelemetry@1.3.1; \ + fi