Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update Dockerfile for building with diverse PHP versions #67

Merged
merged 4 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
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
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