diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index de81b7df..7ac66df1 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -14,8 +14,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 @@ -36,6 +41,8 @@ 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 type=semver,pattern={{version}} @@ -49,3 +56,5 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + PHP_VERSION=${{ matrix.php-version }}-apache 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