Skip to content

Docker Build & Release #366

Docker Build & Release

Docker Build & Release #366

Workflow file for this run

name: Docker Build & Release
on:
workflow_dispatch:
push:
tags:
- 'v*.*'
schedule:
- cron: '30 2 * * 1,3,5'
env:
IMAGE_NAME: pimcore/pimcore-cloud-build-test
jobs:
build-php:
name: "Build PHP images"
runs-on: ubuntu-latest
if: github.repository == 'pimcore/docker'
strategy:
matrix:
include:
- { tag: '1.x', php: '8.0', distro: bullseye, version-override: "v1-dev", latest-tag: false }
# - { tag: '1.x', php: '8.1', distro: bullseye, version-override: "v1-dev", latest-tag: false }
# - { tag: '1.x', php: '8.2', distro: bullseye, version-override: "v1-dev", latest-tag: false }
# - { tag: 'v1.3', php: '8.0', distro: bullseye, version-override: "", latest-tag: true }
# - { tag: 'v1.3', php: '8.1', distro: bullseye, version-override: "", latest-tag: true }
# - { tag: 'v1.3', php: '8.2', distro: bullseye, version-override: "", latest-tag: false }
# - { tag: 'v2.0', php: '8.2', distro: bullseye, version-override: "", latest-tag: false }
# - { tag: '2.x', php: '8.2', distro: bullseye, version-override: "v2-dev", latest-tag: false }
# - { tag: 'v3.0', php: '8.2', distro: bookworm, version-override: "", latest-tag: false }
# - { tag: 'v3.1', php: '8.2', distro: bookworm, version-override: "", latest-tag: false }
# - { tag: 'v3.2', php: '8.2', distro: bookworm, version-override: "", latest-tag: false }
# - { tag: 'v3.3', php: '8.2', distro: bookworm, version-override: "", latest-tag: true }
# - { tag: 'v3.3', php: '8.3', distro: bookworm, imagick_version_from_src: 28f27044e435a2b203e32675e942eb8de620ee58, version-override: "", latest-tag: true }
# - { tag: '3.x', php: '8.2', distro: bookworm, version-override: "v3-dev", latest-tag: false }
# - { tag: '3.x', php: '8.3', distro: bookworm, imagick_version_from_src: 28f27044e435a2b203e32675e942eb8de620ee58, version-override: "v3-dev", latest-tag: false }
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.tag }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_CLOUD_BUILD_USER }}
password: ${{ secrets.DOCKER_CLOUD_BUILD_TOKEN }}
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: cloud
endpoint: "pimcore/pimcore-php-docker-images"
- name: Configure and build images
id: vars
env:
VERSION_OVERRIDE: "${{ matrix.version-override }}"
run: |
set -eux;
if [[ "${{ matrix.tag }}" =~ ^v?1.[0-9x]+$ ]]; then
imageVariants=("fpm" "debug" "supervisord")
else
imageVariants=("min" "default" "max" "debug" "supervisord")
fi
for imageVariant in ${imageVariants[@]}; do
echo "Building image variant $imageVariant"
DOCKER_PLATFORMS=linux/amd64,linux/arm64
PHP_VERSION=${{ matrix.php }}
DEBIAN_VERSION="${{ matrix.distro }}"
VERSION="${{ matrix.tag }}"
# for the latest dev branch we use "dev" as the version and not the name of the branch
if [ ! -z "$VERSION_OVERRIDE" ]; then
VERSION="$VERSION_OVERRIDE"
fi
PHP_SUB_VERSION=$(docker run -i --rm php:${{ matrix.php }}-fpm-${{ matrix.distro }} php -r 'echo PHP_VERSION;')
if [ "$imageVariant" = "fpm" ] || [ "$imageVariant" = "default" ]; then
BASE_TAG="php${{ matrix.php }}"
BASE_TAG_DETAILED="php${PHP_SUB_VERSION}"
else
BASE_TAG="php${{ matrix.php }}-$imageVariant"
BASE_TAG_DETAILED="php${PHP_SUB_VERSION}-$imageVariant"
fi
TAG="${BASE_TAG}-${VERSION}"
TAG_DETAILED="${BASE_TAG_DETAILED}-${VERSION}"
TAGS="--tag ${IMAGE_NAME}:${TAG}"
TAGS="$TAGS --tag ${IMAGE_NAME}:${TAG_DETAILED}"
# Tag latest with Version build too
if [ "true" = "${{ matrix.latest-tag }}" ]; then
TAGS="$TAGS --tag ${IMAGE_NAME}:${BASE_TAG}-latest"
fi
# Create tag for major version
if [[ $VERSION =~ ^v[0-9]+.[0-9]+$ ]]; then
VERSION_MAJOR=${VERSION//.[0-9]/}
TAGS="$TAGS --tag ${IMAGE_NAME}:${BASE_TAG}-${VERSION_MAJOR}"
fi
echo ${TAGS}
docker buildx build --output "type=image,push=true" --platform ${DOCKER_PLATFORMS} \
--target="pimcore_php_$imageVariant" \
--build-arg PHP_VERSION="${PHP_VERSION}" \
--build-arg DEBIAN_VERSION="${DEBIAN_VERSION}" \
--build-arg IMAGICK_VERSION_FROM_SRC="${{ matrix.imagick_version_from_src }}" \
${TAGS} .
docker buildx imagetools inspect ${IMAGE_NAME}:${TAG} || true;
done