PHP Vanilla #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PHP Vanilla | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 6 * * 2' | |
jobs: | |
build_images: | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
strategy: | |
matrix: | |
include: | |
- php_version: '8.4' | |
is_latest: true | |
- php_version: '8.3' | |
is_latest: false | |
- php_version: '8.2' | |
is_latest: false | |
- php_version: '8.1' | |
is_latest: false | |
- php_version: '8.0' | |
is_latest: false | |
- php_version: '7.4' | |
is_latest: false | |
- php_version: '7.3' | |
is_latest: false | |
- php_version: '7.2' | |
is_latest: false | |
- php_version: '7.1' | |
is_latest: false | |
- php_version: '7.0' | |
is_latest: false | |
- php_version: '5.6' | |
is_latest: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# BUILD AMD64 IMAGE | |
- name: Build PHP Base Image - amd64 | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64 | |
context: . | |
file: flavors/vanilla/Dockerfile | |
load: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
PHP_VERSION=${{ matrix.php_version }} | |
tags: | | |
fbraz3/php-nginx:${{ matrix.php_version }}-amd64 | |
- name: Test images - amd64 | |
run: | | |
docker run --name test -v $PWD:/app/public -p 80:80 -it --rm -d --platform=linux/amd64 fbraz3/php-nginx:${{ matrix.php_version }}-amd64 | |
sleep 35 | |
docker exec -i test ps faux |grep -q "nginx" || exit 1 | |
docker exec -i test ps faux |grep -q "nginx: worker" || exit 1 | |
curl http://127.0.0.1/ | grep -q "Hello World" || exit 1 | |
docker exec -i test monit summary || exit 1 | |
docker exec -i test ps faux | |
docker stop test | |
env: | |
PHP_VERSION: ${{ matrix.php_version }} | |
# BUILD ARM64 IMAGE | |
- name: Build PHP Base Image - arm64 | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/arm64 | |
context: . | |
file: flavors/vanilla/Dockerfile | |
load: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
PHP_VERSION=${{ matrix.php_version }} | |
tags: | | |
fbraz3/php-nginx:${{ matrix.php_version }}-arm64 | |
- name: Test images - arm64 | |
run: | | |
docker run --name test -v $PWD:/app/public -p 80:80 -it --rm -d --platform=linux/arm64 fbraz3/php-nginx:${{ matrix.php_version }}-arm64 | |
sleep 60 | |
docker exec -i test ps faux |grep -q "nginx" || exit 1 | |
curl http://127.0.0.1/ | grep -q "Hello World" || exit 1 | |
docker exec -i test monit summary || exit 1 | |
docker exec -i test ps faux | |
docker stop test | |
env: | |
PHP_VERSION: ${{ matrix.php_version }} | |
# BUILD AND PUSH MULTI-ARCH IMAGE | |
# Github Actions cache is used to speed up the build process and ensure that the tests are run on the latest image | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and Push PHP Base Images | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
context: . | |
file: flavors/vanilla/Dockerfile | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
PHP_VERSION=${{ matrix.php_version }} | |
tags: | | |
fbraz3/php-nginx:${{ matrix.php_version }} | |
fbraz3/platform:${{ matrix.php_version }} | |
${{ matrix.is_latest && 'fbraz3/php-nginx:latest' || '' }} | |
${{ matrix.is_latest && 'fbraz3/platform:latest' || '' }} |