Skip to content

Commit

Permalink
Merge pull request #241 from WyriHaximusNet/split-debian-and-alpine-i…
Browse files Browse the repository at this point in the history
…nto-two-workflows

Split Debian and Alpine into two workflows
  • Loading branch information
WyriHaximus authored Feb 10, 2024
2 parents 31252b3 + a597355 commit 8d7b013
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 52 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/alpine.yml
Original file line number Diff line number Diff line change
@@ -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: "[]"
45 changes: 14 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/debian.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 3 additions & 1 deletion Dockerfile-nts-alpine
Original file line number Diff line number Diff line change
@@ -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" \
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile-nts-debian
Original file line number Diff line number Diff line change
@@ -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" \
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile-zts-alpine
Original file line number Diff line number Diff line change
@@ -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" \
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile-zts-debian
Original file line number Diff line number Diff line change
@@ -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" \
Expand Down
11 changes: 2 additions & 9 deletions build-php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
16 changes: 8 additions & 8 deletions utils/all-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,34 @@
$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';
}
}

if (getenv('NO_DEBIAN') !== 'yes') {
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';
}
}
}
Expand Down

0 comments on commit 8d7b013

Please sign in to comment.