Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 69 additions & 41 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,94 @@
name: CI/CD

on:
push:
branches: [main]
pull_request:
workflow_dispatch:
repository_dispatch:
types: [docker-php-swoole-updated]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
DOCKER_BUILDKIT: 1

jobs:
checks:
runs-on: ubuntu-24.04
outputs:
tags: ${{ steps.tags.outputs.tags }}
steps:
- uses: actions/checkout@v7
- name: Check generated contexts
run: |
docker run --rm -v "$PWD:/app" fireworkweb/fwd:v1.0 fwd template
git diff --exit-code
- id: tags
run: echo "tags=$(jq -c '[.builds[].name]' fwd-template.json)" >> "$GITHUB_OUTPUT"
build:
name: Build
runs-on: ubuntu-latest
needs: checks
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
version: ['8.2', '8.3', '8.4']

variant: [nginx, nginx-prod, swoole-nginx, swoole-nginx-prod]
platform:
- {arch: amd64, runner: ubuntu-24.04}
env:
VARIANT: ${{ matrix.version }}-oci8-${{ matrix.variant }}
steps:
- name: Checkout code
uses: actions/checkout@v3.3.0

- name: Check generated Dockerfiles
run: python3 tests/check-generated.py

- name: Build
run: |
docker build --pull -t kooldev/php:${{ matrix.version }}-oci8-nginx ${{ matrix.version }}-oci8-nginx
docker build --pull -t kooldev/php:${{ matrix.version }}-oci8-nginx-prod ${{ matrix.version }}-oci8-nginx-prod

docker build --pull -t kooldev/php:${{ matrix.version }}-oci8-swoole-nginx ${{ matrix.version }}-oci8-swoole-nginx
docker build --pull -t kooldev/php:${{ matrix.version }}-oci8-swoole-nginx-prod ${{ matrix.version }}-oci8-swoole-nginx-prod

- name: Tests
- uses: actions/checkout@v7
- uses: kool-dev/action/image-build@6a6d04e8d1e1c66afc178e32c7d77d76169c7717
with:
arch: ${{ matrix.platform.arch }}
- name: Pull parent once and retain its ID for ancestry/runtime tests
id: parent
run: |
for variant in nginx nginx-prod swoole-nginx swoole-nginx-prod; do
image="${{ matrix.version }}-oci8-${variant}"
bash tests/test-image.sh "kooldev/php:${image}" "${image}/Dockerfile"
done

- name: Login to DockerHub
uses: docker/login-action@v2.1.0
parent=$(awk '$1 == "FROM" {print $2; exit}' "$VARIANT/Dockerfile")
docker pull --platform linux/amd64 "$parent"
echo "ref=$parent" >> "$GITHUB_OUTPUT"
echo "id=$(docker image inspect "$parent" --format '{{.Id}}')" >> "$GITHUB_OUTPUT"
- name: Build from this job's fresh parent (never force-pull)
id: image
uses: docker/build-push-action@v7
with:
context: ${{ env.VARIANT }}
platforms: linux/${{ matrix.platform.arch }}
load: true
provenance: false
tags: kooldev/php:${{ env.VARIANT }}
- uses: kool-dev/action/image-parent@6a6d04e8d1e1c66afc178e32c7d77d76169c7717
with:
base-ref: ${{ steps.parent.outputs.ref }}
base-id: ${{ steps.parent.outputs.id }}
image-id: ${{ steps.image.outputs.imageid }}
- name: Test exact image and parent IDs
env:
IMAGE: ${{ steps.image.outputs.imageid }}
PARENT: ${{ steps.parent.outputs.id }}
run: bash tests/test-image.sh "$IMAGE" "$VARIANT/Dockerfile" "$PARENT"
- uses: kool-dev/action/image-stage@6a6d04e8d1e1c66afc178e32c7d77d76169c7717
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.repository == 'kool-dev/docker-php-oci8'
with:
canonical-repository: kool-dev/docker-php-oci8
default-branch: main
repository: kooldev/php
arch: ${{ matrix.platform.arch }}
group: ${{ env.VARIANT }}
images: '[{"tag":"${{ env.VARIANT }}","id":"${{ steps.image.outputs.imageid }}"}]'
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
publish:
needs: [checks, build]
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.repository == 'kool-dev/docker-php-oci8'
runs-on: ubuntu-24.04
steps:
- uses: kool-dev/action/image-publish@6a6d04e8d1e1c66afc178e32c7d77d76169c7717
with:
canonical-repository: kool-dev/docker-php-oci8
default-branch: main
repository: kooldev/php
tags: ${{ needs.checks.outputs.tags }}
architectures: '["amd64"]'
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push to DockerHub
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.repository == 'kool-dev/docker-php-oci8'
run: |
docker push kooldev/php:${{ matrix.version }}-oci8-nginx
docker push kooldev/php:${{ matrix.version }}-oci8-nginx-prod

docker push kooldev/php:${{ matrix.version }}-oci8-swoole-nginx
docker push kooldev/php:${{ matrix.version }}-oci8-swoole-nginx-prod
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
## Rebuilds and validation

CI rebuilds on `docker-php-swoole-updated` repository dispatches, using
`docker build --pull` to refresh each parent. The event is sent after all Swoole
an explicit parent pull once per build, retaining its ID for build ancestry and
runtime checks instead of pulling again during tests. The event is sent after all Swoole
image publications succeed. Upstream PHP scheduled parent rebuilds propagate
through Swoole to OCI8; there is no direct PHP event receiver or separate OCI8
rebuild cron, avoiding duplicate or premature builds against old Swoole parents.
Expand All @@ -80,10 +81,16 @@ configuration. If delivery fails, recover with this workflow's manual
`workflow_dispatch` on `main` after the required parents have been published.
Only builds on this repository's `main` branch publish images; PRs do not.

CI uses [shared Bash/`jq` actions](https://github.com/kool-dev/action/blob/master/image-ci.md),
pinned in the workflow. Twelve native amd64 jobs build/test once; one publisher
validates and promotes their tested digests. See the shared release rules for
publication guards and retry behavior.

To validate a local build:

```sh
python3 tests/check-generated.py
docker run --rm -v "$PWD:/app" fireworkweb/fwd:v1.0 fwd template
git diff --exit-code
docker build --pull -t oci8-test 8.4-oci8-nginx
bash tests/test-image.sh oci8-test 8.4-oci8-nginx/Dockerfile
```
Expand Down
11 changes: 0 additions & 11 deletions tests/check-generated.py

This file was deleted.

7 changes: 5 additions & 2 deletions tests/test-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ set -euo pipefail

image="${1:?image required}"
dockerfile="${2:?Dockerfile required}"
parent="$(awk '$1 == "FROM" { print $2; exit }' "$dockerfile")"
docker pull "$parent"
parent="${3:-}"
if [[ -z "$parent" ]]; then
parent="$(awk '$1 == "FROM" { print $2; exit }' "$dockerfile")"
docker pull "$parent"
fi
expected="$(docker run --rm --network none --entrypoint php "$parent" -r 'echo PHP_VERSION;')"

# Instant Client 11.2 hangs on Alpine with Docker's network=none.
Expand Down