Skip to content

Build the PHP 8.2 Apache2 container #914

Build the PHP 8.2 Apache2 container

Build the PHP 8.2 Apache2 container #914

---
name: Build the PHP 8.2 Apache2 container
on:
push:
paths:
- "php82-apache2/**"
- ".github/workflows/build-php82-apache2.yaml"
schedule:
- cron: '30 7 * * *'
workflow_dispatch:
env:
NAME: "php82-apache2"
# Beware of magick below!
# The matrix strategy is used to create a job for each architecture
# The individual images are pushed by digest to the package registry
# The separate architectures are merged into a single image
# see https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
jobs:
build-php82:
permissions:
packages: write
strategy:
matrix:
arch: [ 'amd64', 'arm64' ]
runs-on: "ubuntu-24.04${{ matrix.arch == 'arm64' && '-arm' || '' }}"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
id: build
with:
context: ./php82-apache2
platforms: "linux/${{ matrix.arch }}"
push: "${{ github.ref == 'refs/heads/main' }}"
tags: "ghcr.io/openconext/openconext-basecontainers/php82-apache2"
outputs: "type=image,push-by-digest=true,name-canonical=true"
cache-from: type=gha,scope=buildkit-${{ matrix.arch }}
cache-to: type=gha,scope=buildkit-${{ matrix.arch }}
- name: Export digest
run: |
mkdir -p "${{ runner.temp }}/digests/"
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
echo "Files created:"
find "${{ runner.temp }}/digests"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: "digests__${{ env.NAME }}__${{ matrix.arch }}"
path: "${{ runner.temp }}/digests/*"
if-no-files-found: error
retention-days: 1
image-php82:
name: Merge images
if: >
github.actor!='dependabot[bot]' &&
github.event_name!='pull_request' &&
github.ref == 'refs/heads/main'
needs:
- "build-php82"
runs-on: "ubuntu-24.04"
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: "${{ runner.temp }}/digests"
pattern: "digests__*"
merge-multiple: true
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create manifest list and push
working-directory: "${{ runner.temp }}/digests/"
run: |
DIGESTS=$( printf 'ghcr.io/openconext/openconext-basecontainers/php82-apache2@sha256:%s ' * )
TAGS="-t ghcr.io/openconext/openconext-basecontainers/php82-apache2:${{ github.sha }}"
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
TAGS="${TAGS} -t ghcr.io/openconext/openconext-basecontainers/php82-apache2:latest"
fi
echo "Creating docker manifest list"
echo "Digests: $DIGESTS"
echo "Tags: $TAGS"
docker buildx imagetools create ${TAGS} ${DIGESTS}
- name: Inspect image
run: |
docker buildx imagetools inspect ghcr.io/openconext/openconext-basecontainers/php82-apache2:latest