Skip to content

Commit

Permalink
chore: update Dockerfile for building with diverse PHP versions (#67)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Lapotor authored Dec 12, 2023
1 parent 5c9142e commit 0ab3ddf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}}
Expand All @@ -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
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down

0 comments on commit 0ab3ddf

Please sign in to comment.