From 75b2e0a01752f5f71190e148d46bd61f22c87f07 Mon Sep 17 00:00:00 2001 From: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> Date: Tue, 12 Dec 2023 01:45:58 +0100 Subject: [PATCH 1/4] chore: build images for all supported PHP versions Signed-off-by: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> --- .github/workflows/docker-image.yml | 18 ++++++++++++++---- Dockerfile | 7 +++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index de81b7df..3dbdb933 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -6,6 +6,9 @@ on: - main release: types: [published] + pull_request: + branches: + - main workflow_dispatch: env: @@ -14,8 +17,13 @@ env: jobs: build-and-push-image: + name: Build and push Docker image for PHP ${{ matrix.php-version }} runs-on: ubuntu-latest + strategy: + matrix: + php-version: ["8.1", "8.2", "8.3"] + permissions: contents: read packages: write @@ -37,10 +45,10 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha,format=long + type=ref,event=branch,suffix=-php${{ matrix.php-version }} + type=semver,pattern={{version}},suffix=-php${{ matrix.php-version }} + type=semver,pattern={{major}}.{{minor}},suffix=-php${{ matrix.php-version }} + type=sha,format=long,suffix=-php${{ matrix.php-version }} - name: Build and push Docker image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5 @@ -49,3 +57,5 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + PHP_VERSION=${{ matrix.php-version }} diff --git a/Dockerfile b/Dockerfile index 999c6303..06a99540 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ +ARG COMPOSER_VERSION=lts +ARG PHP_VERSION=8.1-apache + # Stage 1: Build -FROM composer:lts@sha256:0e7405d851433b5bb61c1783833b65e6b71fdab006c1029f42f2da1d670d53a5 as build +FROM composer:${COMPOSER_VERSION} as build WORKDIR /app @@ -9,7 +12,7 @@ COPY . /app/ RUN composer install --prefer-dist --no-dev --optimize-autoloader --no-interaction --no-progress # Stage 2: Production -FROM php:8.1-apache@sha256:3a2ed73364dbeecfdf9432550e294e5b989b182157ab2a56bd9c5a582504f4b6 as production +FROM php:${PHP_VERSION} as production ENV APP_ENV=production ENV APP_DEBUG=false From 52f4025c954e18eacd007506910faddc53ecc7b0 Mon Sep 17 00:00:00 2001 From: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> Date: Tue, 12 Dec 2023 01:48:06 +0100 Subject: [PATCH 2/4] add `-apache` suffix Signed-off-by: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3dbdb933..9723baad 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -58,4 +58,4 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | - PHP_VERSION=${{ matrix.php-version }} + PHP_VERSION=${{ matrix.php-version }}-apache From 19bc41721c2e6bf26ebd055028746d9c3bc3e2fd Mon Sep 17 00:00:00 2001 From: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> Date: Tue, 12 Dec 2023 02:06:06 +0100 Subject: [PATCH 3/4] remove PR build Signed-off-by: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> --- .github/workflows/docker-image.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 9723baad..65e21456 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -6,9 +6,6 @@ on: - main release: types: [published] - pull_request: - branches: - - main workflow_dispatch: env: From 61a29030c23f5702211462cf68258a146a00e200 Mon Sep 17 00:00:00 2001 From: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> Date: Tue, 12 Dec 2023 02:25:21 +0100 Subject: [PATCH 4/4] moved to global suffix Signed-off-by: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> --- .github/workflows/docker-image.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 65e21456..7ac66df1 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -41,11 +41,13 @@ jobs: uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + suffix=-php${{ matrix.php-version }} tags: | - type=ref,event=branch,suffix=-php${{ matrix.php-version }} - type=semver,pattern={{version}},suffix=-php${{ matrix.php-version }} - type=semver,pattern={{major}}.{{minor}},suffix=-php${{ matrix.php-version }} - type=sha,format=long,suffix=-php${{ matrix.php-version }} + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha,format=long - name: Build and push Docker image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5