Skip to content

Commit 0ab3ddf

Browse files
authored
chore: update Dockerfile for building with diverse PHP versions (#67)
Modify the `Dockerfile` to enable building with different PHP versions. Adjust the docker image build process to create images for all supported PHP versions. --------- Signed-off-by: Valentin Sickert <[email protected]>
1 parent 5c9142e commit 0ab3ddf

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.github/workflows/docker-image.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ env:
1414

1515
jobs:
1616
build-and-push-image:
17+
name: Build and push Docker image for PHP ${{ matrix.php-version }}
1718
runs-on: ubuntu-latest
1819

20+
strategy:
21+
matrix:
22+
php-version: ["8.1", "8.2", "8.3"]
23+
1924
permissions:
2025
contents: read
2126
packages: write
@@ -36,6 +41,8 @@ jobs:
3641
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5
3742
with:
3843
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
flavor: |
45+
suffix=-php${{ matrix.php-version }}
3946
tags: |
4047
type=ref,event=branch
4148
type=semver,pattern={{version}}
@@ -49,3 +56,5 @@ jobs:
4956
push: true
5057
tags: ${{ steps.meta.outputs.tags }}
5158
labels: ${{ steps.meta.outputs.labels }}
59+
build-args: |
60+
PHP_VERSION=${{ matrix.php-version }}-apache

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
ARG COMPOSER_VERSION=lts
2+
ARG PHP_VERSION=8.1-apache
3+
14
# Stage 1: Build
2-
FROM composer:lts@sha256:0e7405d851433b5bb61c1783833b65e6b71fdab006c1029f42f2da1d670d53a5 as build
5+
FROM composer:${COMPOSER_VERSION} as build
36

47
WORKDIR /app
58

@@ -9,7 +12,7 @@ COPY . /app/
912
RUN composer install --prefer-dist --no-dev --optimize-autoloader --no-interaction --no-progress
1013

1114
# Stage 2: Production
12-
FROM php:8.1-apache@sha256:3a2ed73364dbeecfdf9432550e294e5b989b182157ab2a56bd9c5a582504f4b6 as production
15+
FROM php:${PHP_VERSION} as production
1316

1417
ENV APP_ENV=production
1518
ENV APP_DEBUG=false

0 commit comments

Comments
 (0)