Build containers for PHP > 8.1 #42
Workflow file for this run
This file contains 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: Create images | |
on: | |
push: | |
paths: | |
- .github/workflows/create-images.yml | |
- "docker/**" | |
pull_request: | |
paths: | |
- .github/workflows/create-images.yml | |
- "docker/**" | |
jobs: | |
inspect: | |
name: Inspect environment | |
runs-on: ubuntu-latest | |
outputs: | |
publish: ${{ steps.check-publish.outputs.result }} | |
steps: | |
- name: Check if we have to publish the docker images | |
id: check-publish | |
run: | | |
PUBLISH_IMAGES=no | |
if [ "$GITHUB_REPOSITORY" != 'php-imagine/docker-builder' ]; then | |
echo "This is not the production repository: docker images won't be published" | |
elif [ "$GITHUB_EVENT_NAME" != 'push' ]; then | |
echo "This is a '$GITHUB_EVENT_NAME' event, not a 'push' event: docker images won't be published" | |
elif [ "$GITHUB_REF" != 'refs/heads/main' ]; then | |
echo "This is a push to '$GITHUB_REF', not to 'refs/heads/main' docker images won't be published" | |
else | |
echo 'Docker images will be published' | |
PUBLISH_IMAGES=yes | |
fi | |
echo "result=$PUBLISH_IMAGES" >> $GITHUB_OUTPUT | |
build-base-images: | |
name: PHP ${{ matrix.php-version }} | |
runs-on: ubuntu-latest | |
needs: | |
- inspect | |
env: | |
# The version of git to be installed if the default one is too old - see https://github.com/git/git/releases | |
GIT_VERSION: 2.33.0 | |
# The version of libaom to be installed - see https://aomedia.googlesource.com/aom/+refs | |
LIBAOM_VERSION: 3.1.2 | |
# The version of libdav1d to be installed - see https://code.videolan.org/videolan/dav1d/-/tags | |
LIBDAV1D_VERSION: 0.9.2 | |
# The version of libavif to be installed - see https://github.com/AOMediaCodec/libavif/tags | |
LIBAVIF_VERSION: 0.9.2 | |
# The version of libde265 to be installed - see https://github.com/strukturag/libde265/releases | |
LIBDE265_VERSION: 1.0.8 | |
# The version of libheif to be installed - see # https://github.com/strukturag/libheif/releases | |
LIBHEIF_VERSION: 1.12.0 | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: | |
- "5.5" | |
- "5.6" | |
- "7.0" | |
- "7.1" | |
- "7.2" | |
- "7.3" | |
- "7.4" | |
- "8.0" | |
- "8.1" | |
- "8.2" | |
- "8.3" | |
- "8.4" | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Create initial image | |
run: | | |
PHP_VERSION_DOCKERSUFFIX='' | |
if [ "${{ matrix.php-version }}" = '8.5' ]; then | |
PHP_VERSION_DOCKERSUFFIX='-rc' | |
fi | |
docker build \ | |
--build-arg "PHP_VERSION=${{ matrix.php-version }}" \ | |
--build-arg "PHP_VERSION_DOCKERSUFFIX=$PHP_VERSION_DOCKERSUFFIX" \ | |
--tag "ghcr.io/php-imagine/test:${{ matrix.php-version }}-temp" \ | |
--force-rm --rm \ | |
--file ./docker/Dockerfile.base \ | |
./docker | |
- | |
name: Create container | |
run: docker create -t --name imagine-${{ matrix.php-version }} "ghcr.io/php-imagine/test:${{ matrix.php-version }}-temp" bash | |
- | |
name: Start container | |
run: docker start imagine-${{ matrix.php-version }} | |
- | |
name: Temp | |
run: docker exec -t imagine-${{ matrix.php-version }} ls -al /usr/local/bin/ | |
- | |
name: Fix apt | |
run: docker exec -t imagine-${{ matrix.php-version }} imagine-fix-apt | |
- | |
name: Update apt cache | |
run: docker exec -t imagine-${{ matrix.php-version }} apt-get update -q | |
- | |
name: Update apt packages | |
run: docker exec -t imagine-${{ matrix.php-version }} apt-get upgrade -qy | |
- | |
name: Fix Let's Encrypt CA certificate | |
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 imagine-${{ matrix.php-version }} install-php-extensions @fix_letsencrypt | |
- | |
name: Inspect container environment | |
id: inspect | |
run: | | |
if docker exec -t imagine-${{ matrix.php-version }} imagine-install support-avif; then | |
echo 'AVIF is supported' | |
AVIF_SUPPORT=yes | |
else | |
AVIF_SUPPORT=no | |
fi | |
if docker exec -t imagine-${{ matrix.php-version }} imagine-install support-heic; then | |
echo 'HEIC is supported' | |
HEIC_SUPPORT=yes | |
else | |
HEIC_SUPPORT=no | |
fi | |
echo "avif-support=$AVIF_SUPPORT" >> $GITHUB_OUTPUT | |
echo "heic-support=$HEIC_SUPPORT" >> $GITHUB_OUTPUT | |
- | |
name: Install git | |
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install git $GIT_VERSION | |
- | |
name: Install libaom ${{ env.LIBAOM_VERSION }} | |
if: ${{ steps.inspect.outputs.avif-support == 'yes' || steps.inspect.outputs.heic-support == 'yes' }} | |
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install libaom $LIBAOM_VERSION | |
- | |
name: Install libdav1d ${{ env.LIBDAV1D_VERSION }} | |
if: ${{ steps.inspect.outputs.avif-support == 'yes' }} | |
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install libdav1d $LIBDAV1D_VERSION | |
- | |
name: Install libyuv | |
if: ${{ steps.inspect.outputs.avif-support == 'yes' || steps.inspect.outputs.heic-support == 'yes' }} | |
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install libyuv | |
- | |
name: Install libavif ${{ env.LIBAVIF_VERSION }} | |
if: ${{ steps.inspect.outputs.avif-support == 'yes' }} | |
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install libavif $LIBAVIF_VERSION | |
- | |
name: Install libde265 ${{ env.LIBDE265_VERSION }} | |
if: ${{ steps.inspect.outputs.heic-support == 'yes' }} | |
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install libde265 $LIBDE265_VERSION | |
- | |
name: Install libheif ${{ env.LIBHEIF_VERSION }} | |
if: ${{ steps.inspect.outputs.heic-support == 'yes' }} | |
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install libheif $LIBHEIF_VERSION | |
- | |
name: Install Composer | |
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 imagine-${{ matrix.php-version }} install-php-extensions @composer-2 | |
- | |
name: Install xdebug PHP extension (without enabling it) | |
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 -e IPE_DONT_ENABLE=1 imagine-${{ matrix.php-version }} install-php-extensions xdebug | |
- | |
name: Install exif PHP extension | |
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 imagine-${{ matrix.php-version }} install-php-extensions exif | |
- | |
name: Check exif PHP extension | |
run: docker exec -t imagine-${{ matrix.php-version }} php --ri exif | |
- | |
name: Cleanup | |
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install cleanup | |
- | |
name: Check container | |
run: docker container ls -s --filter name=imagine-${{ matrix.php-version }} | |
- | |
name: Stop container | |
run: docker stop imagine-${{ matrix.php-version }} | |
- | |
name: Create base image | |
run: docker commit imagine-${{ matrix.php-version }} "ghcr.io/php-imagine/test:${{ matrix.php-version }}" | |
- | |
name: Save image | |
if: needs.inspect.outputs.publish == 'no' | |
run: docker save "ghcr.io/php-imagine/test:${{ matrix.php-version }}" | gzip >"/tmp/base-image-${{ matrix.php-version }}.tgz" | |
- | |
name: Upload image | |
if: needs.inspect.outputs.publish == 'no' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: base-image-${{ matrix.php-version }} | |
path: /tmp/base-image-${{ matrix.php-version }}.tgz | |
- | |
name: Login to the container registry | |
if: needs.inspect.outputs.publish == 'yes' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Upload image to the container registry | |
if: needs.inspect.outputs.publish == 'yes' | |
run: docker push "ghcr.io/php-imagine/test:${{ matrix.php-version }}" | |
build-final-images: | |
name: PHP ${{ matrix.config.php-version }} - ${{ matrix.extensions }} | |
runs-on: ubuntu-latest | |
needs: | |
- inspect | |
- build-base-images | |
strategy: | |
matrix: | |
config: | |
# GraphicsMagic versions: http://www.graphicsmagick.org/NEWS.html | |
# ImageMagick versions: https://www.imagemagick.org/download/releases | |
- php-version: "5.5" | |
graphicsmagic-version: "1.3.23" | |
imagemagick-version: "6.8.9-10" | |
- php-version: "5.6" | |
graphicsmagic-version: "1.3.36" | |
imagemagick-version: "7.1.0-8" | |
- php-version: "7.0" | |
graphicsmagic-version: "1.3.36" | |
imagemagick-version: "7.1.0-8" | |
- php-version: "7.1" | |
graphicsmagic-version: "1.3.36" | |
imagemagick-version: "7.1.0-8" | |
- php-version: "7.2" | |
graphicsmagic-version: "1.3.36" | |
imagemagick-version: "6.8.9-10" | |
- php-version: "7.3" | |
graphicsmagic-version: "1.3.23" | |
imagemagick-version: "7.1.0-8" | |
- php-version: "7.4" | |
graphicsmagic-version: "1.3.36" | |
imagemagick-version: "7.1.0-8" | |
- php-version: "8.0" | |
graphicsmagic-version: "1.3.36" | |
imagemagick-version: "7.1.0-8" | |
- php-version: "8.1" | |
graphicsmagic-version: "1.3.36" | |
imagemagick-version: "7.1.0-8" | |
- php-version: "8.2" | |
graphicsmagic-version: "1.3.36" | |
imagemagick-version: "7.1.0-8" | |
- php-version: "8.3" | |
graphicsmagic-version: "1.3.36" | |
imagemagick-version: "7.1.0-8" | |
- php-version: "8.4" | |
graphicsmagic-version: "1.3.36" | |
imagemagick-version: "7.1.0-8" | |
extensions: | |
- "gd-gmagick" | |
- "gd-imagick" | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Download base image | |
if: needs.inspect.outputs.publish == 'no' | |
uses: actions/download-artifact@v4 | |
with: | |
name: base-image-${{ matrix.config.php-version }} | |
path: /tmp/ | |
- | |
name: Load base image | |
if: needs.inspect.outputs.publish == 'no' | |
run: docker load --input /tmp/base-image-${{ matrix.config.php-version }}.tgz | |
- | |
name: Create container | |
run: docker create -t --name imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} "ghcr.io/php-imagine/test:${{ matrix.config.php-version }}" bash | |
- | |
name: Start container | |
run: docker start imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} | |
- | |
name: Update apt cache | |
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} apt-get update -q | |
- | |
name: Install GraphicsMagic | |
if: ${{ contains(format('-{0}-', matrix.extensions), '-gmagick-') }} | |
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} imagine-install graphicsmagick ${{ matrix.config.graphicsmagic-version }} | |
- | |
name: Install gmagick PHP extension | |
if: ${{ contains(format('-{0}-', matrix.extensions), '-gmagick-') }} | |
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} install-php-extensions gmagick | |
- | |
name: Check gmagick PHP extension | |
if: ${{ contains(format('-{0}-', matrix.extensions), '-gmagick-') }} | |
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} php --ri gmagick | |
- | |
name: Install ImageMagick | |
if: ${{ contains(format('-{0}-', matrix.extensions), '-imagick-') }} | |
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} imagine-install imagemagick ${{ matrix.config.imagemagick-version }} | |
- | |
name: Install imagick PHP extension | |
if: ${{ contains(format('-{0}-', matrix.extensions), '-imagick-') }} | |
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} install-php-extensions imagick | |
- | |
name: Check imagick PHP extension | |
if: ${{ contains(format('-{0}-', matrix.extensions), '-imagick-') }} | |
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} php --ri imagick | |
- | |
name: Install gd PHP extension | |
if: ${{ contains(format('-{0}-', matrix.extensions), '-gd-') }} | |
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} install-php-extensions gd | |
- | |
name: Check gd PHP extension | |
if: ${{ contains(format('-{0}-', matrix.extensions), '-gd-') }} | |
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} php --ri gd | |
- | |
name: Cleanup | |
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} imagine-install cleanup | |
- | |
name: Check container | |
run: docker container ls -s --filter name=imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} | |
- | |
name: Stop container | |
run: docker stop imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} | |
- | |
name: Create image | |
run: docker commit imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} "ghcr.io/php-imagine/test:${{ matrix.config.php-version }}-${{ matrix.extensions }}" | |
- | |
name: Login to the container registry | |
if: needs.inspect.outputs.publish == 'yes' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Upload image to the container registry | |
if: needs.inspect.outputs.publish == 'yes' | |
run: docker push "ghcr.io/php-imagine/test:${{ matrix.config.php-version }}-${{ matrix.extensions }}" |