diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index dcce877..2543543 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -1,6 +1,19 @@ name: CI/CD -on: [pull_request, push, workflow_dispatch] +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 @@ -10,6 +23,7 @@ jobs: name: Build runs-on: ubuntu-latest strategy: + fail-fast: false matrix: version: ['8.2', '8.3', '8.4'] @@ -17,6 +31,9 @@ jobs: - 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 @@ -27,24 +44,20 @@ jobs: - name: Tests run: | - docker run kooldev/php:${{ matrix.version }}-oci8-nginx php -r "extension_loaded('oci8') or die(1);" - docker run kooldev/php:${{ matrix.version }}-oci8-nginx-prod php -r "extension_loaded('oci8') or die(1);" - - docker run kooldev/php:${{ matrix.version }}-oci8-nginx php -r "extension_loaded('oci8') or die(1);" - docker run kooldev/php:${{ matrix.version }}-oci8-nginx-prod php -r "extension_loaded('oci8') or die(1);" - - docker run kooldev/php:${{ matrix.version }}-oci8-swoole-nginx php -r "extension_loaded('oci8') or die(1);" - docker run kooldev/php:${{ matrix.version }}-oci8-swoole-nginx-prod php -r "extension_loaded('oci8') or die(1);" + 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 - if: github.ref == 'refs/heads/main' && github.repository == 'kool-dev/docker-php-oci8' + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.repository == 'kool-dev/docker-php-oci8' with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Push to DockerHub - if: github.ref == 'refs/heads/main' && github.repository == 'kool-dev/docker-php-oci8' + 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 diff --git a/8.2-oci8-nginx-prod/Dockerfile b/8.2-oci8-nginx-prod/Dockerfile index 62303c4..55a2a3c 100644 --- a/8.2-oci8-nginx-prod/Dockerfile +++ b/8.2-oci8-nginx-prod/Dockerfile @@ -4,7 +4,7 @@ ENV LD_LIBRARY_PATH /usr/local/instantclient ENV ORACLE_HOME /usr/local/instantclient # Download and unarchive Instant Client v11 -RUN apk add --update libaio libnsl && \ +RUN apk add --update libaio libnsl $PHPIZE_DEPS && \ curl -o /tmp/instaclient-basic.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-basic-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sdk.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sdk-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sqlplus.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip && \ @@ -17,5 +17,6 @@ RUN apk add --update libaio libnsl && \ ln -s ${ORACLE_HOME}/lib* /usr/lib && \ ln -s ${ORACLE_HOME}/sqlplus /usr/bin/sqlplus && \ ln -s /usr/lib/libnsl.so.3 /usr/lib/libnsl.so.1 && \ - docker-php-ext-configure oci8 --with-oci8=instantclient,$ORACLE_HOME && \ - docker-php-ext-install oci8 + echo "instantclient,${ORACLE_HOME}" | pecl install oci8 && \ + docker-php-ext-enable oci8 && \ + apk del $PHPIZE_DEPS diff --git a/8.2-oci8-nginx/Dockerfile b/8.2-oci8-nginx/Dockerfile index 3afbecc..43a84f5 100644 --- a/8.2-oci8-nginx/Dockerfile +++ b/8.2-oci8-nginx/Dockerfile @@ -4,7 +4,7 @@ ENV LD_LIBRARY_PATH /usr/local/instantclient ENV ORACLE_HOME /usr/local/instantclient # Download and unarchive Instant Client v11 -RUN apk add --update libaio libnsl && \ +RUN apk add --update libaio libnsl $PHPIZE_DEPS && \ curl -o /tmp/instaclient-basic.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-basic-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sdk.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sdk-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sqlplus.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip && \ @@ -17,5 +17,6 @@ RUN apk add --update libaio libnsl && \ ln -s ${ORACLE_HOME}/lib* /usr/lib && \ ln -s ${ORACLE_HOME}/sqlplus /usr/bin/sqlplus && \ ln -s /usr/lib/libnsl.so.3 /usr/lib/libnsl.so.1 && \ - docker-php-ext-configure oci8 --with-oci8=instantclient,$ORACLE_HOME && \ - docker-php-ext-install oci8 + echo "instantclient,${ORACLE_HOME}" | pecl install oci8 && \ + docker-php-ext-enable oci8 && \ + apk del $PHPIZE_DEPS diff --git a/8.2-oci8-swoole-nginx-prod/Dockerfile b/8.2-oci8-swoole-nginx-prod/Dockerfile index 3ec5f63..c112169 100644 --- a/8.2-oci8-swoole-nginx-prod/Dockerfile +++ b/8.2-oci8-swoole-nginx-prod/Dockerfile @@ -4,7 +4,7 @@ ENV LD_LIBRARY_PATH /usr/local/instantclient ENV ORACLE_HOME /usr/local/instantclient # Download and unarchive Instant Client v11 -RUN apk add --update libaio libnsl && \ +RUN apk add --update libaio libnsl $PHPIZE_DEPS && \ curl -o /tmp/instaclient-basic.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-basic-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sdk.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sdk-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sqlplus.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip && \ @@ -17,5 +17,6 @@ RUN apk add --update libaio libnsl && \ ln -s ${ORACLE_HOME}/lib* /usr/lib && \ ln -s ${ORACLE_HOME}/sqlplus /usr/bin/sqlplus && \ ln -s /usr/lib/libnsl.so.3 /usr/lib/libnsl.so.1 && \ - docker-php-ext-configure oci8 --with-oci8=instantclient,$ORACLE_HOME && \ - docker-php-ext-install oci8 + echo "instantclient,${ORACLE_HOME}" | pecl install oci8 && \ + docker-php-ext-enable oci8 && \ + apk del $PHPIZE_DEPS diff --git a/8.2-oci8-swoole-nginx/Dockerfile b/8.2-oci8-swoole-nginx/Dockerfile index d8eff40..ea70304 100644 --- a/8.2-oci8-swoole-nginx/Dockerfile +++ b/8.2-oci8-swoole-nginx/Dockerfile @@ -4,7 +4,7 @@ ENV LD_LIBRARY_PATH /usr/local/instantclient ENV ORACLE_HOME /usr/local/instantclient # Download and unarchive Instant Client v11 -RUN apk add --update libaio libnsl && \ +RUN apk add --update libaio libnsl $PHPIZE_DEPS && \ curl -o /tmp/instaclient-basic.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-basic-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sdk.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sdk-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sqlplus.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip && \ @@ -17,5 +17,6 @@ RUN apk add --update libaio libnsl && \ ln -s ${ORACLE_HOME}/lib* /usr/lib && \ ln -s ${ORACLE_HOME}/sqlplus /usr/bin/sqlplus && \ ln -s /usr/lib/libnsl.so.3 /usr/lib/libnsl.so.1 && \ - docker-php-ext-configure oci8 --with-oci8=instantclient,$ORACLE_HOME && \ - docker-php-ext-install oci8 + echo "instantclient,${ORACLE_HOME}" | pecl install oci8 && \ + docker-php-ext-enable oci8 && \ + apk del $PHPIZE_DEPS diff --git a/8.3-oci8-nginx-prod/Dockerfile b/8.3-oci8-nginx-prod/Dockerfile index 8b5bd46..4c9ce00 100644 --- a/8.3-oci8-nginx-prod/Dockerfile +++ b/8.3-oci8-nginx-prod/Dockerfile @@ -4,7 +4,7 @@ ENV LD_LIBRARY_PATH /usr/local/instantclient ENV ORACLE_HOME /usr/local/instantclient # Download and unarchive Instant Client v11 -RUN apk add --update libaio libnsl && \ +RUN apk add --update libaio libnsl $PHPIZE_DEPS && \ curl -o /tmp/instaclient-basic.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-basic-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sdk.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sdk-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sqlplus.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip && \ @@ -17,5 +17,6 @@ RUN apk add --update libaio libnsl && \ ln -s ${ORACLE_HOME}/lib* /usr/lib && \ ln -s ${ORACLE_HOME}/sqlplus /usr/bin/sqlplus && \ ln -s /usr/lib/libnsl.so.3 /usr/lib/libnsl.so.1 && \ - docker-php-ext-configure oci8 --with-oci8=instantclient,$ORACLE_HOME && \ - docker-php-ext-install oci8 + echo "instantclient,${ORACLE_HOME}" | pecl install oci8 && \ + docker-php-ext-enable oci8 && \ + apk del $PHPIZE_DEPS diff --git a/8.3-oci8-nginx/Dockerfile b/8.3-oci8-nginx/Dockerfile index 96e14d2..6a4484d 100644 --- a/8.3-oci8-nginx/Dockerfile +++ b/8.3-oci8-nginx/Dockerfile @@ -4,7 +4,7 @@ ENV LD_LIBRARY_PATH /usr/local/instantclient ENV ORACLE_HOME /usr/local/instantclient # Download and unarchive Instant Client v11 -RUN apk add --update libaio libnsl && \ +RUN apk add --update libaio libnsl $PHPIZE_DEPS && \ curl -o /tmp/instaclient-basic.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-basic-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sdk.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sdk-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sqlplus.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip && \ @@ -17,5 +17,6 @@ RUN apk add --update libaio libnsl && \ ln -s ${ORACLE_HOME}/lib* /usr/lib && \ ln -s ${ORACLE_HOME}/sqlplus /usr/bin/sqlplus && \ ln -s /usr/lib/libnsl.so.3 /usr/lib/libnsl.so.1 && \ - docker-php-ext-configure oci8 --with-oci8=instantclient,$ORACLE_HOME && \ - docker-php-ext-install oci8 + echo "instantclient,${ORACLE_HOME}" | pecl install oci8 && \ + docker-php-ext-enable oci8 && \ + apk del $PHPIZE_DEPS diff --git a/8.3-oci8-swoole-nginx-prod/Dockerfile b/8.3-oci8-swoole-nginx-prod/Dockerfile index 31df101..7d74bf2 100644 --- a/8.3-oci8-swoole-nginx-prod/Dockerfile +++ b/8.3-oci8-swoole-nginx-prod/Dockerfile @@ -4,7 +4,7 @@ ENV LD_LIBRARY_PATH /usr/local/instantclient ENV ORACLE_HOME /usr/local/instantclient # Download and unarchive Instant Client v11 -RUN apk add --update libaio libnsl && \ +RUN apk add --update libaio libnsl $PHPIZE_DEPS && \ curl -o /tmp/instaclient-basic.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-basic-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sdk.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sdk-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sqlplus.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip && \ @@ -17,5 +17,6 @@ RUN apk add --update libaio libnsl && \ ln -s ${ORACLE_HOME}/lib* /usr/lib && \ ln -s ${ORACLE_HOME}/sqlplus /usr/bin/sqlplus && \ ln -s /usr/lib/libnsl.so.3 /usr/lib/libnsl.so.1 && \ - docker-php-ext-configure oci8 --with-oci8=instantclient,$ORACLE_HOME && \ - docker-php-ext-install oci8 + echo "instantclient,${ORACLE_HOME}" | pecl install oci8 && \ + docker-php-ext-enable oci8 && \ + apk del $PHPIZE_DEPS diff --git a/8.3-oci8-swoole-nginx/Dockerfile b/8.3-oci8-swoole-nginx/Dockerfile index 6675afd..cd43f27 100644 --- a/8.3-oci8-swoole-nginx/Dockerfile +++ b/8.3-oci8-swoole-nginx/Dockerfile @@ -4,7 +4,7 @@ ENV LD_LIBRARY_PATH /usr/local/instantclient ENV ORACLE_HOME /usr/local/instantclient # Download and unarchive Instant Client v11 -RUN apk add --update libaio libnsl && \ +RUN apk add --update libaio libnsl $PHPIZE_DEPS && \ curl -o /tmp/instaclient-basic.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-basic-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sdk.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sdk-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sqlplus.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip && \ @@ -17,5 +17,6 @@ RUN apk add --update libaio libnsl && \ ln -s ${ORACLE_HOME}/lib* /usr/lib && \ ln -s ${ORACLE_HOME}/sqlplus /usr/bin/sqlplus && \ ln -s /usr/lib/libnsl.so.3 /usr/lib/libnsl.so.1 && \ - docker-php-ext-configure oci8 --with-oci8=instantclient,$ORACLE_HOME && \ - docker-php-ext-install oci8 + echo "instantclient,${ORACLE_HOME}" | pecl install oci8 && \ + docker-php-ext-enable oci8 && \ + apk del $PHPIZE_DEPS diff --git a/README.md b/README.md index 245039a..e365731 100644 --- a/README.md +++ b/README.md @@ -65,3 +65,42 @@ After any changes, we need to run `kool run template` to parse the templates and ## License The MIT License (MIT). Please see [License File](LICENSE.md) for more information. + +## 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 +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. +Workflow runs are serialized by ref. Only superseded PR runs are canceled; +main-branch release runs are allowed to finish. Dispatch delivery requires the +upstream Swoole repository's dispatch credentials and OCI8 recipient +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. + +To validate a local build: + +```sh +python3 tests/check-generated.py +docker build --pull -t oci8-test 8.4-oci8-nginx +bash tests/test-image.sh oci8-test 8.4-oci8-nginx/Dockerfile +``` + +The smoke test checks PHP against the freshly pulled parent, OCI8, native +Instant Client loading, and the expected Oracle no-listener error from a +loopback connection. It is bounded to 30 seconds. Instant Client 11.2 hangs +in the tested Alpine image with Docker's `--network none`, so this check uses +the normal bridge but connects only to loopback. It does not test +authentication, queries, TLS, SQL*Plus, or a live Oracle database. + +These images remain **amd64-only**. The template still downloads legacy Oracle +Instant Client 11.2 x64 ZIPs from a third-party GitHub repository's mutable +`master` branch without checksum verification. Successful loading is not +provenance or security validation. Replacing that source/client and adding ARM +support require separate licensing, provenance, and compatibility review. +Swoole variants depend on the separately published Swoole parents; verify +delivery of the post-publication event through the PHP → Swoole → OCI8 chain. +After merging, maintainers must publish and verify every supported tag's +runtime version and digest before considering stale published images fixed. diff --git a/template/Dockerfile.blade.php b/template/Dockerfile.blade.php index fe4a0c1..9c02cd6 100644 --- a/template/Dockerfile.blade.php +++ b/template/Dockerfile.blade.php @@ -3,6 +3,7 @@ ENV LD_LIBRARY_PATH /usr/local/instantclient ENV ORACLE_HOME /usr/local/instantclient +# Download and unarchive Instant Client v11 RUN apk add --update libaio libnsl $PHPIZE_DEPS && \ curl -o /tmp/instaclient-basic.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-basic-linux.x64-11.2.0.4.0.zip && \ curl -o /tmp/instaclient-sdk.zip https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/instantclient-sdk-linux.x64-11.2.0.4.0.zip && \ diff --git a/tests/check-generated.py b/tests/check-generated.py new file mode 100644 index 0000000..cdd3316 --- /dev/null +++ b/tests/check-generated.py @@ -0,0 +1,11 @@ +import json +from pathlib import Path + + +template = Path("template/Dockerfile.blade.php").read_text() +for build in json.loads(Path("fwd-template.json").read_text())["builds"]: + expected = template.replace("{{ $from }}", build["data"]["from"]) + path = Path(build["name"]) / "Dockerfile" + if path.read_text() != expected: + raise SystemExit(f"{path} differs from its template; run kool run template") +print("Generated Dockerfiles match the template") diff --git a/tests/smoke.php b/tests/smoke.php new file mode 100644 index 0000000..8e51986 --- /dev/null +++ b/tests/smoke.php @@ -0,0 +1,23 @@ +