Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 21 additions & 41 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ env:
jobs:
build-php:
name: "Build PHP images"
runs-on: ubuntu-22.04
runs-on: ${{ matrix.runner }}
if: github.repository == 'pimcore/docker'
strategy:
matrix:
include:
runner:
- ubuntu-22.04
- ubuntu-22.04-arm
build:
- { 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.1', distro: bullseye, version-override: "", latest-tag: true }
Expand All @@ -35,35 +38,21 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.tag }}
ref: ${{ matrix.build.tag }}

- name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.tag }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.tag }}-

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: 'amd64,arm64'

- name: Set up Buildx
uses: docker/setup-buildx-action@v3


- name: Configure and build images
id: vars
env:
VERSION_OVERRIDE: "${{ matrix.version-override }}"
VERSION_OVERRIDE: "${{ matrix.build.version-override }}"
run: |
set -eux;

if [[ "${{ matrix.tag }}" =~ ^v?1.[0-9x]+$ ]]; then
sudo apt-get update

if [[ "${{ matrix.build.tag }}" =~ ^v?1.[0-9x]+$ ]]; then
imageVariants=("fpm" "debug" "supervisord")
else
imageVariants=("min" "default" "max" "debug" "supervisord")
Expand All @@ -74,22 +63,21 @@ jobs:

echo "Building image variant $imageVariant"

DOCKER_PLATFORMS=linux/amd64,linux/arm64
PHP_VERSION=${{ matrix.php }}
DEBIAN_VERSION="${{ matrix.distro }}"
VERSION="${{ matrix.tag }}"
PHP_VERSION=${{ matrix.build.php }}
DEBIAN_VERSION="${{ matrix.build.distro }}"
VERSION="${{ matrix.build.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;')
PHP_SUB_VERSION=$(docker run -i --rm php:${{ matrix.build.php }}-fpm-${{ matrix.build.distro }} php -r 'echo PHP_VERSION;')

if [ "$imageVariant" = "fpm" ] || [ "$imageVariant" = "default" ]; then
BASE_TAG="php${{ matrix.php }}"
BASE_TAG="php${{ matrix.build.php }}"
BASE_TAG_DETAILED="php${PHP_SUB_VERSION}"
else
BASE_TAG="php${{ matrix.php }}-$imageVariant"
BASE_TAG="php${{ matrix.build.php }}-$imageVariant"
BASE_TAG_DETAILED="php${PHP_SUB_VERSION}-$imageVariant"
fi

Expand All @@ -104,7 +92,7 @@ jobs:
TAGS="$TAGS --tag ${IMAGE_NAME}:${TAG_DETAILED}"

# Tag latest with Version build too
if [ "true" = "${{ matrix.latest-tag }}" ]; then
if [ "true" = "${{ matrix.build.latest-tag }}" ]; then
TAGS="$TAGS --tag ${IMAGE_NAME}:${BASE_TAG}-latest"
fi

Expand All @@ -117,20 +105,12 @@ jobs:
echo ${TAGS}


docker buildx build --output "type=image,push=true" --platform ${DOCKER_PLATFORMS} \
docker build --output "type=image,push=true" \
--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 }}" \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache-new" \
--build-arg IMAGICK_VERSION_FROM_SRC="${{ matrix.build.imagick_version_from_src }}" \
${TAGS} .

docker buildx imagetools inspect ${IMAGE_NAME}:${TAG} || true;
docker inspect ${IMAGE_NAME}:${TAG} || true;
done


- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache