Skip to content

Commit

Permalink
fix(Admin lsphp): Updates build to use PHP 8.2 sources for admin lsphp (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
timnolte authored Apr 18, 2024
1 parent 9b7fede commit da8e364
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 6 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand Down
45 changes: 42 additions & 3 deletions .github/workflows/test-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -66,31 +83,53 @@ 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 "<?php phpinfo();" > /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
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 '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
15 changes: 12 additions & 3 deletions template/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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/
Expand Down

0 comments on commit da8e364

Please sign in to comment.