From 169b6bc0eddf314644519628cd3fd95ee6e78715 Mon Sep 17 00:00:00 2001 From: Bui Huy Hoang Date: Thu, 5 Nov 2026 09:43:52 +0700 Subject: [PATCH 1/2] feat: allow pinning pecl packages per versions file New optional list key pecl_packages (default: xdebug pcov). Items are a PECL name with an optional -, validated before anything is generated; the docker-php-ext-enable list is derived from the names. Generated files are unchanged when the key is not set. --- Dockerfile-01-alpine.template | 4 ++-- Dockerfile-01-debian.template | 4 ++-- generate.sh | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/Dockerfile-01-alpine.template b/Dockerfile-01-alpine.template index 5d45f32..203a7a3 100644 --- a/Dockerfile-01-alpine.template +++ b/Dockerfile-01-alpine.template @@ -1,6 +1,6 @@ RUN apk add --no-cache git RUN apk add --update linux-headers --no-cache --virtual .ext-deps autoconf gcc musl-dev make \ - && pecl install xdebug pcov \ - && docker-php-ext-enable xdebug pcov \ + && pecl install {{ pecl_install }} \ + && docker-php-ext-enable {{ pecl_enable }} \ && apk del .ext-deps diff --git a/Dockerfile-01-debian.template b/Dockerfile-01-debian.template index ab8a6b6..2508d00 100644 --- a/Dockerfile-01-debian.template +++ b/Dockerfile-01-debian.template @@ -2,5 +2,5 @@ RUN apt-get update \ && apt-get install -y git vim \ && rm -rf /var/lib/apt/lists/* -RUN pecl install xdebug pcov \ - && docker-php-ext-enable xdebug pcov +RUN pecl install {{ pecl_install }} \ + && docker-php-ext-enable {{ pecl_enable }} diff --git a/generate.sh b/generate.sh index 417f0a9..8767ad0 100755 --- a/generate.sh +++ b/generate.sh @@ -42,6 +42,32 @@ digest_suffix() { echo "@sha256:$value" } +# Print the PECL packages to install: the pecl_packages list from versions*.yml, or "xdebug pcov". +# Each item is a PECL package name with an optional -, e.g. xdebug-3.1.6. +# With --names, print the package names only (version stripped), for docker-php-ext-enable. +# +# Usage: pecl_install_list [--names] +# +pecl_install_list() { + local items + read -ra items <<< "${pecl_packages:-xdebug pcov}" + + local item out=() + for item in "${items[@]}"; do + if ! [[ "$item" =~ ^[a-z][a-z0-9_]*(-[0-9][0-9A-Za-z.]*)?$ ]]; then + echo "pecl_packages item must look like xdebug or xdebug-3.1.6, got '$item'" >&2 + return 1 + fi + if [ "$1" = --names ]; then + out+=("${item%%-*}") + else + out+=("$item") + fi + done + + echo "${out[*]}" +} + # Validate the keys of the loaded versions*.yml before anything is written or removed. # base_image is required; base_image_sha256 is required when exact_tags_only is true, # so an exact (immutable) tag is never built from an unpinned base. @@ -58,6 +84,7 @@ validate_config() { exact_only=$(bool_key exact_tags_only false) || return 1 bool_key dockerhub_push true > /dev/null || return 1 digest_suffix base_image_sha256 > /dev/null || return 1 + pecl_install_list > /dev/null || return 1 if [ "$exact_only" = true ] && [ -z "$base_image_sha256" ]; then echo "$1: base_image_sha256 is required when exact_tags_only is true" >&2 @@ -106,6 +133,11 @@ generate_dockerfile() { local base_image_digest base_image_digest=$(digest_suffix base_image_sha256) + # PECL packages (optional list key pecl_packages, e.g. xdebug-3.1.6 to pin for an old PHP) + local pecl_install pecl_enable + pecl_install=$(pecl_install_list) + pecl_enable=$(pecl_install_list --names) + mkdir -p "$dir" write_warn_edit $dockerfile @@ -117,6 +149,8 @@ generate_dockerfile() { distro_release \ base_image \ base_image_digest \ + pecl_install \ + pecl_enable \ >> $dockerfile done From 0adf94525a66b6f6c25d1c1d4f6185e29da4e1c4 Mon Sep 17 00:00:00 2001 From: Bui Huy Hoang Date: Thu, 5 Nov 2026 09:43:52 +0700 Subject: [PATCH 2/2] feat: add php 7.4.33 alpine3.16 build from the patched ghcr base New versions_7.4.yml builds 7.4/alpine3.16 from ghcr.io/sun-asterisk-research/php:7.4.33-nginx-alpine3.16 pinned by digest, publishing only 7.4.33-alpine3.16 for amd64, without Docker Hub. xdebug is pinned to 3.1.6 and pcov to 1.0.12 because current xdebug needs PHP 8. 7.4.30 leaves versions.yml; its tags stop being rebuilt and keep their current digests. --- .github/workflows/7.4.yml | 19 +++-- 7.4/alpine3.15/Dockerfile | 15 ---- .../usr/local/bin/docker-php-ext-disable | 4 - 7.4/alpine3.16/Dockerfile | 4 +- 7.4/bullseye/Dockerfile | 15 ---- .../usr/local/bin/docker-php-ext-disable | 4 - 7.4/buster/Dockerfile | 15 ---- .../usr/local/bin/docker-php-ext-disable | 4 - docker-bake.hcl | 84 ++++--------------- versions.yml | 1 - versions_7.4.yml | 23 +++++ 11 files changed, 50 insertions(+), 138 deletions(-) delete mode 100644 7.4/alpine3.15/Dockerfile delete mode 100755 7.4/alpine3.15/rootfs/usr/local/bin/docker-php-ext-disable delete mode 100644 7.4/bullseye/Dockerfile delete mode 100755 7.4/bullseye/rootfs/usr/local/bin/docker-php-ext-disable delete mode 100644 7.4/buster/Dockerfile delete mode 100755 7.4/buster/rootfs/usr/local/bin/docker-php-ext-disable create mode 100644 versions_7.4.yml diff --git a/.github/workflows/7.4.yml b/.github/workflows/7.4.yml index 7c0824e..360054f 100644 --- a/.github/workflows/7.4.yml +++ b/.github/workflows/7.4.yml @@ -14,6 +14,9 @@ defaults: run: shell: 'bash -Eeuo pipefail -x {0}' +permissions: + contents: read + jobs: verify-templating: name: Verify templating @@ -31,14 +34,14 @@ jobs: runs-on: ubuntu-latest needs: - verify-templating + permissions: + contents: read + packages: write strategy: matrix: target: [ - "7_4_30-bullseye", - "7_4_30-buster", - "7_4_30-alpine3_16", - "7_4_30-alpine3_15", + "7_4_33-alpine3_16", ] steps: - name: Checkout @@ -54,7 +57,7 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - if: true + if: false - name: GHCR Login uses: docker/login-action@v1 with: @@ -66,9 +69,9 @@ jobs: with: targets: ${{ matrix.target }} set: | - *.platform=linux/amd64,linux/arm,linux/arm64 + *.platform=linux/amd64 push: ${{ github.event_name == 'push' }} - if: true + if: false - name: GHCR build and push uses: docker/bake-action@v2 env: @@ -77,5 +80,5 @@ jobs: with: targets: ${{ matrix.target }} set: | - *.platform=linux/amd64,linux/arm,linux/arm64 + *.platform=linux/amd64 push: ${{ github.event_name == 'push' }} diff --git a/7.4/alpine3.15/Dockerfile b/7.4/alpine3.15/Dockerfile deleted file mode 100644 index 0a512bf..0000000 --- a/7.4/alpine3.15/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# NOTE: This file was generated via generate.sh. Don't edit it directly - -FROM sunasteriskrnd/php:7.4.30-nginx-alpine3.15 - -ENV COMPOSER_VERSION=2.4.1 - -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version="$COMPOSER_VERSION" - -COPY rootfs / -RUN apk add --no-cache git - -RUN apk add --update linux-headers --no-cache --virtual .ext-deps autoconf gcc musl-dev make \ - && pecl install xdebug pcov \ - && docker-php-ext-enable xdebug pcov \ - && apk del .ext-deps diff --git a/7.4/alpine3.15/rootfs/usr/local/bin/docker-php-ext-disable b/7.4/alpine3.15/rootfs/usr/local/bin/docker-php-ext-disable deleted file mode 100755 index 3622ebc..0000000 --- a/7.4/alpine3.15/rootfs/usr/local/bin/docker-php-ext-disable +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -# remove config file created by docker-php-ext-enable -rm /usr/local/etc/php/conf.d/docker-php-ext-$1.ini diff --git a/7.4/alpine3.16/Dockerfile b/7.4/alpine3.16/Dockerfile index c4fb6fc..5292832 100644 --- a/7.4/alpine3.16/Dockerfile +++ b/7.4/alpine3.16/Dockerfile @@ -1,6 +1,6 @@ # NOTE: This file was generated via generate.sh. Don't edit it directly -FROM sunasteriskrnd/php:7.4.30-nginx-alpine3.16 +FROM ghcr.io/sun-asterisk-research/php:7.4.33-nginx-alpine3.16@sha256:ccd57c94a1ec0734f926ce55550c528cfabaa4f467a629e77974e61673d32061 ENV COMPOSER_VERSION=2.4.1 @@ -10,6 +10,6 @@ COPY rootfs / RUN apk add --no-cache git RUN apk add --update linux-headers --no-cache --virtual .ext-deps autoconf gcc musl-dev make \ - && pecl install xdebug pcov \ + && pecl install xdebug-3.1.6 pcov-1.0.12 \ && docker-php-ext-enable xdebug pcov \ && apk del .ext-deps diff --git a/7.4/bullseye/Dockerfile b/7.4/bullseye/Dockerfile deleted file mode 100644 index 5d36b66..0000000 --- a/7.4/bullseye/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# NOTE: This file was generated via generate.sh. Don't edit it directly - -FROM sunasteriskrnd/php:7.4.30-nginx-bullseye - -ENV COMPOSER_VERSION=2.4.1 - -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version="$COMPOSER_VERSION" - -COPY rootfs / -RUN apt-get update \ - && apt-get install -y git vim \ - && rm -rf /var/lib/apt/lists/* - -RUN pecl install xdebug pcov \ - && docker-php-ext-enable xdebug pcov diff --git a/7.4/bullseye/rootfs/usr/local/bin/docker-php-ext-disable b/7.4/bullseye/rootfs/usr/local/bin/docker-php-ext-disable deleted file mode 100755 index 3622ebc..0000000 --- a/7.4/bullseye/rootfs/usr/local/bin/docker-php-ext-disable +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -# remove config file created by docker-php-ext-enable -rm /usr/local/etc/php/conf.d/docker-php-ext-$1.ini diff --git a/7.4/buster/Dockerfile b/7.4/buster/Dockerfile deleted file mode 100644 index f429a2a..0000000 --- a/7.4/buster/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# NOTE: This file was generated via generate.sh. Don't edit it directly - -FROM sunasteriskrnd/php:7.4.30-nginx-buster - -ENV COMPOSER_VERSION=2.4.1 - -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version="$COMPOSER_VERSION" - -COPY rootfs / -RUN apt-get update \ - && apt-get install -y git vim \ - && rm -rf /var/lib/apt/lists/* - -RUN pecl install xdebug pcov \ - && docker-php-ext-enable xdebug pcov diff --git a/7.4/buster/rootfs/usr/local/bin/docker-php-ext-disable b/7.4/buster/rootfs/usr/local/bin/docker-php-ext-disable deleted file mode 100755 index 3622ebc..0000000 --- a/7.4/buster/rootfs/usr/local/bin/docker-php-ext-disable +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -# remove config file created by docker-php-ext-enable -rm /usr/local/etc/php/conf.d/docker-php-ext-$1.ini diff --git a/docker-bake.hcl b/docker-bake.hcl index 38eb229..07d3f64 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -8,76 +8,6 @@ variable "REPO" { default = "sunasteriskrnd/php-dev" } -target "7_4_30-bullseye" { - context = "./7.4/bullseye" - cache-from = [ - "${REGISTRY}/${REPO}:7.4-bullseye" - ] - tags = [ - "${REGISTRY}/${REPO}:7-bullseye", - "${REGISTRY}/${REPO}:7", - "${REGISTRY}/${REPO}:7.4-bullseye", - "${REGISTRY}/${REPO}:7.4", - "${REGISTRY}/${REPO}:7.4.30-bullseye", - "${REGISTRY}/${REPO}:7.4.30", - ] -} - -target "7_4-bullseye" { - inherits = ["7_4_30-bullseye"] -} - -target "7_4_30-buster" { - context = "./7.4/buster" - cache-from = [ - "${REGISTRY}/${REPO}:7.4-buster" - ] - tags = [ - "${REGISTRY}/${REPO}:7-buster", - "${REGISTRY}/${REPO}:7.4-buster", - "${REGISTRY}/${REPO}:7.4.30-buster", - ] -} - -target "7_4-buster" { - inherits = ["7_4_30-buster"] -} - -target "7_4_30-alpine3_16" { - context = "./7.4/alpine3.16" - cache-from = [ - "${REGISTRY}/${REPO}:7.4-alpine3.16" - ] - tags = [ - "${REGISTRY}/${REPO}:7-alpine3.16", - "${REGISTRY}/${REPO}:7-alpine", - "${REGISTRY}/${REPO}:7.4-alpine3.16", - "${REGISTRY}/${REPO}:7.4-alpine", - "${REGISTRY}/${REPO}:7.4.30-alpine3.16", - "${REGISTRY}/${REPO}:7.4.30-alpine", - ] -} - -target "7_4-alpine3_16" { - inherits = ["7_4_30-alpine3_16"] -} - -target "7_4_30-alpine3_15" { - context = "./7.4/alpine3.15" - cache-from = [ - "${REGISTRY}/${REPO}:7.4-alpine3.15" - ] - tags = [ - "${REGISTRY}/${REPO}:7-alpine3.15", - "${REGISTRY}/${REPO}:7.4-alpine3.15", - "${REGISTRY}/${REPO}:7.4.30-alpine3.15", - ] -} - -target "7_4-alpine3_15" { - inherits = ["7_4_30-alpine3_15"] -} - target "8_0_22-bullseye" { context = "./8.0/bullseye" cache-from = [ @@ -206,6 +136,20 @@ target "7_3-alpine3_14" { inherits = ["7_3_33-alpine3_14"] } +target "7_4_33-alpine3_16" { + context = "./7.4/alpine3.16" + cache-from = [ + "${REGISTRY}/${REPO}:7.4-alpine3.16" + ] + tags = [ + "${REGISTRY}/${REPO}:7.4.33-alpine3.16", + ] +} + +target "7_4-alpine3_16" { + inherits = ["7_4_33-alpine3_16"] +} + target "8_1_34-alpine3_22" { context = "./8.1/alpine3.22" cache-from = [ diff --git a/versions.yml b/versions.yml index e17e813..2b2d962 100644 --- a/versions.yml +++ b/versions.yml @@ -1,5 +1,4 @@ php_versions: -- 7.4.30 - 8.0.22 composer_version: 2.4.1 diff --git a/versions_7.4.yml b/versions_7.4.yml new file mode 100644 index 0000000..59f6014 --- /dev/null +++ b/versions_7.4.yml @@ -0,0 +1,23 @@ +php_versions: +- 7.4.33 + +composer_version: 2.4.1 +base_image: ghcr.io/sun-asterisk-research/php +base_image_sha256: ccd57c94a1ec0734f926ce55550c528cfabaa4f467a629e77974e61673d32061 + +pecl_packages: +- xdebug-3.1.6 +- pcov-1.0.12 + +default_php_7_version: 7.4 +default_distro: alpine +default_alpine_release: alpine3.16 + +alpine_releases: +- alpine3.16 + +platforms: +- linux/amd64 + +exact_tags_only: true +dockerhub_push: false