From c38ae6a4120f111c3178b8273ba61a1e9a996a39 Mon Sep 17 00:00:00 2001 From: Tim Nolte Date: Thu, 18 Apr 2024 08:25:58 -0400 Subject: [PATCH] feat(Admin lsphp): Updates build to support using PHP 8.2 sources for admin lsphp (#167) - Supports #166 - Adds support for testing a newer version of PHP for the OLS admin dashboard. - Adds OLS admin control panel access testing to Docker image build testing. --- .github/workflows/docker.yml | 58 +++++++++++++++++++++++++++++++ .github/workflows/test-builds.yml | 45 ++++++++++++++++++++++-- template/Dockerfile | 15 ++++++-- 3 files changed, 112 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d2b1b01..99801bd 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -9,6 +9,7 @@ on: env: OLS_VERSION: '1.7.19' PHP_STABLE_VERSION: '8.3.6' + OLS_ADMIN_PHP_STABLE_VERSION: '7.4.33' NODE_STABLE_VERSION: '20' REGISTRY: ghcr.io @@ -27,6 +28,13 @@ jobs: - '16' - '18' - '20' + OLS_ADMIN_PHP_VERSION: + - '7.4.33' + include: + - job-name: 'OLS Admin PHP 8.x RC' + PHP_VERSION: '8.1.28' + NODE_VERSION: '20' + OLS_ADMIN_PHP_VERSION: '8.2.18' steps: - name: Checkout @@ -65,12 +73,22 @@ jobs: echo "_0=$_0" >> $GITHUB_OUTPUT echo "_1=$_1" >> $GITHUB_OUTPUT + # https://github.com/orgs/community/discussions/26625#discussioncomment-3252582 + - name: Determine OLS Admin PHP Major/Minor Version + id: ols-admin-php-version + run: | + _0=$(echo ${{ matrix.OLS_ADMIN_PHP_VERSION }} | cut -d. -f1) + _1=$(echo ${{ matrix.OLS_ADMIN_PHP_VERSION }} | cut -d. -f2) + echo "_0=$_0" >> $GITHUB_OUTPUT + echo "_1=$_1" >> $GITHUB_OUTPUT + # https://github.com/marketplace/actions/build-and-push-docker-images - name: Build and Push Docker Image uses: docker/build-push-action@v5 if: | matrix.PHP_VERSION != env.PHP_STABLE_VERSION && matrix.NODE_VERSION != env.NODE_STABLE_VERSION + && matrix.OLS_ADMIN_PHP_VERSION == env.OLS_ADMIN_PHP_STABLE_VERSION with: context: template platforms: linux/arm64 @@ -80,6 +98,9 @@ jobs: PHP_VERSION=${{ matrix.PHP_VERSION }} PHP_MAJOR_VERSION=${{ steps.php-version.outputs._0 }} PHP_MINOR_VERSION=${{ steps.php-version.outputs._1 }} + OLS_ADMIN_PHP_VERSION=${{ matrix.OLS_ADMIN_PHP_VERSION }} + OLS_ADMIN_PHP_MAJOR_VERSION=${{ steps.ols-admin-php-version.outputs._0 }} + OLS_ADMIN_PHP_MINOR_VERSION=${{ steps.ols-admin-php-version.outputs._1 }} NODE_VERSION=${{ matrix.NODE_VERSION }} push: true tags: | @@ -97,6 +118,7 @@ jobs: if: | matrix.PHP_VERSION == env.PHP_STABLE_VERSION && matrix.NODE_VERSION != env.NODE_STABLE_VERSION + && matrix.OLS_ADMIN_PHP_VERSION == env.OLS_ADMIN_PHP_STABLE_VERSION with: context: template platforms: linux/arm64 @@ -106,6 +128,9 @@ jobs: PHP_VERSION=${{ matrix.PHP_VERSION }} PHP_MAJOR_VERSION=${{ steps.php-version.outputs._0 }} PHP_MINOR_VERSION=${{ steps.php-version.outputs._1 }} + OLS_ADMIN_PHP_VERSION=${{ matrix.OLS_ADMIN_PHP_VERSION }} + OLS_ADMIN_PHP_MAJOR_VERSION=${{ steps.ols-admin-php-version.outputs._0 }} + OLS_ADMIN_PHP_MINOR_VERSION=${{ steps.ols-admin-php-version.outputs._1 }} NODE_VERSION=${{ matrix.NODE_VERSION }} push: true tags: | @@ -123,6 +148,7 @@ jobs: if: | matrix.PHP_VERSION != env.PHP_STABLE_VERSION && matrix.NODE_VERSION == env.NODE_STABLE_VERSION + && matrix.OLS_ADMIN_PHP_VERSION == env.OLS_ADMIN_PHP_STABLE_VERSION with: context: template platforms: linux/arm64 @@ -132,6 +158,9 @@ jobs: PHP_VERSION=${{ matrix.PHP_VERSION }} PHP_MAJOR_VERSION=${{ steps.php-version.outputs._0 }} PHP_MINOR_VERSION=${{ steps.php-version.outputs._1 }} + OLS_ADMIN_PHP_VERSION=${{ matrix.OLS_ADMIN_PHP_VERSION }} + OLS_ADMIN_PHP_MAJOR_VERSION=${{ steps.ols-admin-php-version.outputs._0 }} + OLS_ADMIN_PHP_MINOR_VERSION=${{ steps.ols-admin-php-version.outputs._1 }} NODE_VERSION=${{ matrix.NODE_VERSION }} push: true tags: | @@ -153,6 +182,7 @@ jobs: if: | matrix.PHP_VERSION == env.PHP_STABLE_VERSION && matrix.NODE_VERSION == env.NODE_STABLE_VERSION + && matrix.OLS_ADMIN_PHP_VERSION == env.OLS_ADMIN_PHP_STABLE_VERSION with: context: template platforms: linux/arm64 @@ -162,6 +192,9 @@ jobs: PHP_VERSION=${{ matrix.PHP_VERSION }} PHP_MAJOR_VERSION=${{ steps.php-version.outputs._0 }} PHP_MINOR_VERSION=${{ steps.php-version.outputs._1 }} + OLS_ADMIN_PHP_VERSION=${{ matrix.OLS_ADMIN_PHP_VERSION }} + OLS_ADMIN_PHP_MAJOR_VERSION=${{ steps.ols-admin-php-version.outputs._0 }} + OLS_ADMIN_PHP_MINOR_VERSION=${{ steps.ols-admin-php-version.outputs._1 }} NODE_VERSION=${{ matrix.NODE_VERSION }} push: true tags: | @@ -178,6 +211,31 @@ jobs: cache-from: type=registry,ref=${{ env.REGISTRY }}/ndigitals/openlitespeed cache-to: type=inline + # https://github.com/marketplace/actions/build-and-push-docker-images + - name: Build and Push Docker Image Admin PHP 8.x RC + uses: docker/build-push-action@v5 + if: | + matrix.OLS_ADMIN_PHP_VERSION != env.OLS_ADMIN_PHP_STABLE_VERSION + with: + context: template + platforms: linux/arm64 + provenance: false + build-args: | + OLS_VERSION=${{ env.OLS_VERSION }} + PHP_VERSION=${{ matrix.PHP_VERSION }} + PHP_MAJOR_VERSION=${{ steps.php-version.outputs._0 }} + PHP_MINOR_VERSION=${{ steps.php-version.outputs._1 }} + OLS_ADMIN_PHP_VERSION=${{ matrix.OLS_ADMIN_PHP_VERSION }} + OLS_ADMIN_PHP_MAJOR_VERSION=${{ steps.ols-admin-php-version.outputs._0 }} + OLS_ADMIN_PHP_MINOR_VERSION=${{ steps.ols-admin-php-version.outputs._1 }} + NODE_VERSION=${{ matrix.NODE_VERSION }} + push: true + tags: | + ${{ env.REGISTRY }}/ndigitals/openlitespeed:${{ env.OLS_VERSION }}-lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }}-node${{ matrix.NODE_VERSION }}-adminlsphp${{ steps.ols-admin-php-version.outputs._0 }}${{ steps.ols-admin-php-version.outputs._1 }} + no-cache: ${{ github.event_name == 'workflow_dispatch' && true || false }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/ndigitals/openlitespeed + cache-to: type=inline + release: name: Publish Release runs-on: ubuntu-latest diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml index 1febb10..0c9ba4e 100644 --- a/.github/workflows/test-builds.yml +++ b/.github/workflows/test-builds.yml @@ -9,6 +9,7 @@ on: env: OLS_VERSION: '1.7.19' PHP_STABLE_VERSION: '8.3.6' + OLS_ADMIN_PHP_STABLE_VERSION: '7.4.33' NODE_STABLE_VERSION: '20' REGISTRY: ghcr.io @@ -25,6 +26,13 @@ jobs: NODE_VERSION: - '18' - '20' + OLS_ADMIN_PHP_VERSION: + - '7.4.33' + include: + - job-name: 'OLS Admin PHP 8.x RC' + PHP_VERSION: '8.1.28' + NODE_VERSION: '20' + OLS_ADMIN_PHP_VERSION: '8.2.18' steps: - name: Checkout @@ -54,6 +62,15 @@ jobs: echo "_0=$_0" >> $GITHUB_OUTPUT echo "_1=$_1" >> $GITHUB_OUTPUT + # https://github.com/orgs/community/discussions/26625#discussioncomment-3252582 + - name: Determine OLS Admin PHP Major/Minor Version + id: ols-admin-php-version + run: | + _0=$(echo ${{ matrix.OLS_ADMIN_PHP_VERSION }} | cut -d. -f1) + _1=$(echo ${{ matrix.OLS_ADMIN_PHP_VERSION }} | cut -d. -f2) + echo "_0=$_0" >> $GITHUB_OUTPUT + echo "_1=$_1" >> $GITHUB_OUTPUT + # https://github.com/marketplace/actions/build-and-push-docker-images - name: Build Docker Image uses: docker/build-push-action@v5 @@ -66,21 +83,25 @@ jobs: PHP_VERSION=${{ matrix.PHP_VERSION }} PHP_MAJOR_VERSION=${{ steps.php-version.outputs._0 }} PHP_MINOR_VERSION=${{ steps.php-version.outputs._1 }} + OLS_ADMIN_PHP_VERSION=${{ matrix.OLS_ADMIN_PHP_VERSION }} + OLS_ADMIN_PHP_MAJOR_VERSION=${{ steps.ols-admin-php-version.outputs._0 }} + OLS_ADMIN_PHP_MINOR_VERSION=${{ steps.ols-admin-php-version.outputs._1 }} NODE_VERSION=${{ matrix.NODE_VERSION }} load: true push: false - tags: openlitespeed:${{ env.OLS_VERSION }}-lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }}-node${{ matrix.NODE_VERSION }} + tags: openlitespeed:${{ env.OLS_VERSION }}-lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }}-node${{ matrix.NODE_VERSION }}-adminlsphp${{ steps.ols-admin-php-version.outputs._0 }}${{ steps.ols-admin-php-version.outputs._1 }} no-cache: ${{ github.event_name == 'workflow_dispatch' && true || false }} cache-from: type=registry,ref=${{ env.REGISTRY }}/ndigitals/openlitespeed cache-to: type=inline - name: Test Docker Image run: | - IMAGE=openlitespeed:${{ env.OLS_VERSION }}-lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }}-node${{ matrix.NODE_VERSION }} + IMAGE=openlitespeed:${{ env.OLS_VERSION }}-lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }}-node${{ matrix.NODE_VERSION }}-adminlsphp${{ steps.ols-admin-php-version.outputs._0 }}${{ steps.ols-admin-php-version.outputs._1 }} + echo -e 'Testing PHP Info Site...' ID=$(docker run -d ${IMAGE}) sleep 5s docker exec -i ${ID} su -c 'mkdir -p /var/www/vhosts/localhost/html/ && echo " /var/www/vhosts/localhost/html/index.php && service lsws restart' - HTTP=$(docker exec -i ${ID} su -c 'curl -s -o /dev/null -Ik -w "%{http_code}" http://localhost') + HTTP=$(docker exec -i ${ID} su -c 'curl -s -o /dev/null -IkL -w "%{http_code}" http://localhost') HTTPS=$(docker exec -i ${ID} su -c 'curl -s -o /dev/null -Ik -w "%{http_code}" https://localhost') docker kill ${ID} &>/dev/null docker rm ${ID} &>/dev/null @@ -88,9 +109,27 @@ jobs: echo -e '[\u2718] Test failed!' echo "http://localhost returned ${HTTP}" echo "https://localhost returned ${HTTPS}" + docker rmi ${IMAGE} &>/dev/null exit 1 else + echo -e '[\u2714] Tests passed!' + fi + echo -e 'Testing OLS Admin Control Panel...' + ID=$(docker run -d ${IMAGE}) + sleep 5s + HTTP=$(docker exec -i ${ID} su -c 'curl -s -o /dev/null -IkL -w "%{http_code}" "http://localhost:7080/login.php?timedout=1#view/confMgr.php?m=tp_docker&p=ext"') + HTTPS=$(docker exec -i ${ID} su -c 'curl -s -o /dev/null -Ik -w "%{http_code}" "https://localhost:7080/login.php?timedout=1#view/confMgr.php?m=tp_docker&p=ext"') + docker kill ${ID} &>/dev/null + docker rm ${ID} &>/dev/null + if [[ "${HTTP}" != "200" || "${HTTPS}" != "200" ]]; then + echo -e '[\u2718] Test failed!' + echo "http://localhost returned ${HTTP}" + echo "https://localhost returned ${HTTPS}" docker rmi ${IMAGE} &>/dev/null + exit 1 + else echo -e '[\u2714] Tests passed!' fi + echo -e 'Cleaning Up Test Image...' + docker rmi ${IMAGE} &>/dev/null diff --git a/template/Dockerfile b/template/Dockerfile index ea6e4ae..1d1caa1 100644 --- a/template/Dockerfile +++ b/template/Dockerfile @@ -2,6 +2,9 @@ ARG OLS_VERSION ARG PHP_VERSION ARG PHP_MAJOR_VERSION ARG PHP_MINOR_VERSION +ARG OLS_ADMIN_PHP_VERSION +ARG OLS_ADMIN_PHP_MAJOR_VERSION +ARG OLS_ADMIN_PHP_MINOR_VERSION ARG NODE_VERSION FROM wordpress:cli-php${PHP_MAJOR_VERSION}.${PHP_MINOR_VERSION} AS wp-cli @@ -10,6 +13,9 @@ ARG OLS_VERSION ARG PHP_VERSION ARG PHP_MAJOR_VERSION ARG PHP_MINOR_VERSION +ARG OLS_ADMIN_PHP_VERSION +ARG OLS_ADMIN_PHP_MAJOR_VERSION +ARG OLS_ADMIN_PHP_MINOR_VERSION ARG NODE_VERSION FROM litespeedtech/openlitespeed:${OLS_VERSION}-lsphp${PHP_MAJOR_VERSION}0 AS ols @@ -26,15 +32,18 @@ ARG OLS_VERSION ARG PHP_VERSION ARG PHP_MAJOR_VERSION ARG PHP_MINOR_VERSION +ARG OLS_ADMIN_PHP_VERSION +ARG OLS_ADMIN_PHP_MAJOR_VERSION +ARG OLS_ADMIN_PHP_MINOR_VERSION ARG NODE_VERSION ENV OLS_VERSION=${OLS_VERSION} ENV PHP_VERSION=${PHP_VERSION} ENV PHP_MAJOR_VERSION=${PHP_MAJOR_VERSION} ENV PHP_MINOR_VERSION=${PHP_MINOR_VERSION} -ENV OLS_ADMIN_PHP_VERSION=7.4.33 -ENV OLS_ADMIN_PHP_MAJOR_VERSION=7 -ENV OLS_ADMIN_PHP_MINOR_VERSION=4 +ENV OLS_ADMIN_PHP_VERSION=${OLS_ADMIN_PHP_VERSION} +ENV OLS_ADMIN_PHP_MAJOR_VERSION=${OLS_ADMIN_PHP_MAJOR_VERSION} +ENV OLS_ADMIN_PHP_MINOR_VERSION=${OLS_ADMIN_PHP_MINOR_VERSION} ENV NODE_VERSION=${NODE_VERSION} COPY *.sh /build/