From a597355757f81e8aafef3c4d559a86fb3c98a1b7 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Sat, 10 Feb 2024 20:55:22 +0100 Subject: [PATCH] Split Debian and Alpine into two workflows --- .github/workflows/alpine.yml | 27 ++++++++++++++++++++++ .github/workflows/ci.yml | 45 +++++++++++------------------------- .github/workflows/debian.yml | 27 ++++++++++++++++++++++ Dockerfile-nts-alpine | 4 +++- Dockerfile-nts-debian | 4 +++- Dockerfile-zts-alpine | 4 +++- Dockerfile-zts-debian | 4 +++- build-php.sh | 11 ++------- utils/all-images.php | 16 ++++++------- 9 files changed, 90 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/alpine.yml create mode 100644 .github/workflows/debian.yml diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml new file mode 100644 index 0000000..db19df8 --- /dev/null +++ b/.github/workflows/alpine.yml @@ -0,0 +1,27 @@ +name: Alpine +on: + workflow_dispatch: + push: + branches: + - master + pull_request: + schedule: + - cron: '13 3 * * *' +jobs: + supported-alpine-versions: + name: Supported Alpine versions + runs-on: ubuntu-latest + outputs: + alpine: ${{ steps.supported-alpine-versions.outputs.versions }} + steps: + - id: supported-alpine-versions + name: Generate Alpine + uses: wyrihaximus/github-action-supported-alpine-linux-versions@v1 + ci: + needs: + - supported-alpine-versions + name: Continuous Integration + uses: ./.github/workflows/ci.yml + with: + alpine: ${{ needs.supported-alpine-versions.outputs.alpine }} + debian: "[]" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30545c3..95c0da4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,35 +4,20 @@ env: DOCKER_BUILDKIT: 1 DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING: '{"ghcr.io":"GHCR_TOKEN","docker.io":"HUB_PASSCODE"}' DOCKER_CLI_EXPERIMENTAL: enabled + on: - workflow_dispatch: - push: - branches: - - master - pull_request: - schedule: - - cron: '13 4 * * *' + workflow_call: + inputs: + alpine: + description: JSON string with Alpine versions to build + required: true + type: string + debian: + description: JSON string with Debian versions to build + required: true + type: string + jobs: - supported-alpine-versions: - name: Supported Alpine versions - runs-on: ubuntu-latest - outputs: - alpine: ${{ steps.supported-alpine-versions.outputs.versions }} - steps: - - id: supported-alpine-versions - name: Generate Alpine - uses: wyrihaximus/github-action-supported-alpine-linux-versions@v1 - with: - maxVersions: 2 - supported-debian-versions: - name: Supported Debian versions - runs-on: ubuntu-latest - outputs: - debian: ${{ steps.supported-debian-versions.outputs.versions }} - steps: - - id: supported-debian-versions - name: Generate Debian - uses: wyrihaximus/github-action-supported-debian-linux-versions@v1 supported-php-versions: name: Supported PHP versions runs-on: ubuntu-latest @@ -85,8 +70,6 @@ jobs: runs-on: ubuntu-latest needs: - lint - - supported-alpine-versions - - supported-debian-versions - supported-php-versions outputs: image: ${{ steps.image-matrix.outputs.image }} @@ -129,8 +112,8 @@ jobs: printf "image=%s" $(cat all-images.list) >> $GITHUB_OUTPUT exit 0 env: - ALPINE: ${{ needs.supported-alpine-versions.outputs.alpine }} - DEBIAN: ${{ needs.supported-debian-versions.outputs.debian }} + ALPINE: ${{ inputs.alpine }} + DEBIAN: ${{ inputs.debian }} PHP: ${{ needs.supported-php-versions.outputs.php }} lint: name: Linting Dockerfile-${{ matrix.type }} diff --git a/.github/workflows/debian.yml b/.github/workflows/debian.yml new file mode 100644 index 0000000..fa388e1 --- /dev/null +++ b/.github/workflows/debian.yml @@ -0,0 +1,27 @@ +name: Debian +on: + workflow_dispatch: + push: + branches: + - master + pull_request: + schedule: + - cron: '13 4 * * *' +jobs: + supported-debian-versions: + name: Supported Debian versions + runs-on: ubuntu-latest + outputs: + debian: ${{ steps.supported-debian-versions.outputs.versions }} + steps: + - id: supported-debian-versions + name: Generate Debian + uses: wyrihaximus/github-action-supported-debian-linux-versions@v1 + ci: + needs: + - supported-debian-versions + name: Continuous Integration + uses: ./.github/workflows/ci.yml + with: + alpine: "[]" + debian: ${{ needs.supported-debian-versions.outputs.debian }} diff --git a/Dockerfile-nts-alpine b/Dockerfile-nts-alpine index ada28c7..d74929c 100644 --- a/Dockerfile-nts-alpine +++ b/Dockerfile-nts-alpine @@ -1,5 +1,7 @@ # syntax=docker/dockerfile:experimental -FROM php:7.4-cli-alpine3.11 AS base +ARG PHP_VERSION=7.4 +ARG OS_VERSION=alpine3.11 +FROM php:$PHP_VERSION-cli-$OS_VERSION AS base # Build-time metadata as defined at http://label-schema.org LABEL org.label-schema.name="wyrihaximusnet/php" \ diff --git a/Dockerfile-nts-debian b/Dockerfile-nts-debian index 3cdbac0..93af2fa 100644 --- a/Dockerfile-nts-debian +++ b/Dockerfile-nts-debian @@ -1,5 +1,7 @@ # syntax=docker/dockerfile:experimental -FROM php:7.4-cli-buster AS base +ARG PHP_VERSION=7.4 +ARG OS_VERSION=buster +FROM php:$PHP_VERSION-cli-$OS_VERSION AS base # Build-time metadata as defined at http://label-schema.org LABEL org.label-schema.name="wyrihaximusnet/php" \ diff --git a/Dockerfile-zts-alpine b/Dockerfile-zts-alpine index f202808..099951f 100644 --- a/Dockerfile-zts-alpine +++ b/Dockerfile-zts-alpine @@ -1,5 +1,7 @@ # syntax=docker/dockerfile:experimental -FROM php:7.4-zts-alpine3.11 AS base +ARG PHP_VERSION=7.4 +ARG OS_VERSION=alpine3.11 +FROM php:$PHP_VERSION-zts-$OS_VERSION AS base # Build-time metadata as defined at http://label-schema.org LABEL org.label-schema.name="wyrihaximusnet/php" \ diff --git a/Dockerfile-zts-debian b/Dockerfile-zts-debian index c4f8e5a..8cadb16 100644 --- a/Dockerfile-zts-debian +++ b/Dockerfile-zts-debian @@ -1,5 +1,7 @@ # syntax=docker/dockerfile:experimental -FROM php:7.4-zts-buster AS base +ARG PHP_VERSION=7.4 +ARG OS_VERSION=buster +FROM php:$PHP_VERSION-zts-$OS_VERSION AS base # Build-time metadata as defined at http://label-schema.org LABEL org.label-schema.name="wyrihaximusnet/php" \ diff --git a/build-php.sh b/build-php.sh index fdc1908..9cc47fb 100755 --- a/build-php.sh +++ b/build-php.sh @@ -16,14 +16,7 @@ declare -r VERSION_OS=$6 declare -r VERSION_OS_TAG=$7 -declare -r VERSION_OS_FROM=$8 - -declare -r TARGET_ARCH=$9 - -# I could create a placeholder like php:x.y-image-alpinex.y in the Dockerfile itself, -# but I think it wouldn't be a good experience if you try to build the image yourself -# thus that's the way I opted to have dynamic base images -declare -r IMAGE_ORIGINAL_TAG="7.[0-9]-${SRC_IMAGE}-${VERSION_OS_FROM}" +declare -r TARGET_ARCH=$8 declare -r IMAGE_TAG="${VERSION_PHP}-${SRC_IMAGE}-${VERSION_OS}" declare -r WYRIHAXIMUSNET_TAG="wyrihaximusnet/php:${VERSION_PHP_ALIAS}-${DST_IMAGE}-${VERSION_OS_TAG}" @@ -52,6 +45,6 @@ docker pull "php:${IMAGE_TAG}" for buildTarget in "${target[@]}" do - sed -E "s/${IMAGE_ORIGINAL_TAG}/${IMAGE_TAG}/g" "Dockerfile-${DST_IMAGE}-${OS}" | docker build --build-arg ARCH=${TARGET_ARCH} --platform ${TARGET_ARCH} --label org.label-schema.build-date=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --label org.label-schema.vcs-ref=`git rev-parse --short HEAD` -t "${WYRIHAXIMUSNET_TAG}${buildTarget}-${TARGET_ARCH}" --target="${DST_IMAGE}${buildTarget}" -f - . + docker build --build-arg ARCH=${TARGET_ARCH} --build-arg PHP_VERSION=${VERSION_PHP} --build-arg OS_VERSION=${VERSION_OS} --platform ${TARGET_ARCH} --label org.label-schema.build-date=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --label org.label-schema.vcs-ref=`git rev-parse --short HEAD` -t "${WYRIHAXIMUSNET_TAG}${buildTarget}-${TARGET_ARCH}" --target="${DST_IMAGE}${buildTarget}" -f "Dockerfile-${DST_IMAGE}-${OS}" . echo "${WYRIHAXIMUSNET_TAG}${buildTarget}-${TARGET_ARCH}" >> "$TAG_FILE" done diff --git a/utils/all-images.php b/utils/all-images.php index 6ee8567..6b1ba57 100644 --- a/utils/all-images.php +++ b/utils/all-images.php @@ -26,18 +26,18 @@ $latestOSVersion = $alpine; } if (array_key_exists($php . '-zts-alpine' . $alpine, $upstreamImages)) { - $line[] = 'zts-zts-' . $php . '-' . cleanUpVersion($php) . '-alpine-alpine' . $alpine . '-alpine' . $alpine . '-alpine3.11'; + $line[] = 'zts-zts-' . $php . '-' . cleanUpVersion($php) . '-alpine-alpine' . $alpine . '-alpine' . $alpine; } if (array_key_exists($php . '-cli-alpine' . $alpine, $upstreamImages)) { - $line[] = 'cli-nts-' . $php . '-' . cleanUpVersion($php) . '-alpine-alpine' . $alpine . '-alpine' . $alpine . '-alpine3.11'; + $line[] = 'cli-nts-' . $php . '-' . cleanUpVersion($php) . '-alpine-alpine' . $alpine . '-alpine' . $alpine; } } if (array_key_exists($php . '-zts-alpine' . $latestOSVersion, $upstreamImages)) { - $line[] = 'zts-zts-' . $php . '-' . cleanUpVersion($php) . '-alpine-alpine' . $latestOSVersion . '-alpine-alpine3.11'; + $line[] = 'zts-zts-' . $php . '-' . cleanUpVersion($php) . '-alpine-alpine' . $latestOSVersion . '-alpine'; } if (array_key_exists($php . '-cli-alpine' . $latestOSVersion, $upstreamImages)) { - $line[] = 'cli-nts-' . $php . '-' . cleanUpVersion($php) . '-alpine-alpine' . $latestOSVersion . '-alpine-alpine3.11'; + $line[] = 'cli-nts-' . $php . '-' . cleanUpVersion($php) . '-alpine-alpine' . $latestOSVersion . '-alpine'; } } @@ -45,15 +45,15 @@ foreach (json_decode(getenv('PHP'), true) as $php) { foreach (json_decode(getenv('DEBIAN'), true) as $debian) { if (array_key_exists($php . '-zts-' . $debian, $upstreamImages)) { - $line[] = 'zts-zts-' . $php . '-' . cleanUpVersion($php) . '-debian-' . $debian . '-' . $debian . '-buster'; + $line[] = 'zts-zts-' . $php . '-' . cleanUpVersion($php) . '-debian-' . $debian . '-' . $debian . ''; if ($debian === 'buster') { - $line[] = 'zts-zts-' . $php . '-' . cleanUpVersion($php) . '-debian-' . $debian . '-debian-buster'; + $line[] = 'zts-zts-' . $php . '-' . cleanUpVersion($php) . '-debian-' . $debian . '-debian'; } } if (array_key_exists($php . '-cli-' . $debian, $upstreamImages)) { - $line[] = 'cli-nts-' . $php . '-' . cleanUpVersion($php) . '-debian-' . $debian . '-' . $debian . '-buster'; + $line[] = 'cli-nts-' . $php . '-' . cleanUpVersion($php) . '-debian-' . $debian . '-' . $debian . ''; if ($debian === 'buster') { - $line[] = 'cli-nts-' . $php . '-' . cleanUpVersion($php) . '-debian-' . $debian . '-debian-buster'; + $line[] = 'cli-nts-' . $php . '-' . cleanUpVersion($php) . '-debian-' . $debian . '-debian'; } } }