Skip to content

Commit 4497598

Browse files
committed
Update PHP version and Redis version in Dockerfiles, improved image handlign with multi-version support for PHP
Signed-off-by: Moritz Mazetti <moritz@matchory.com>
1 parent 9ff4836 commit 4497598

5 files changed

Lines changed: 31 additions & 239 deletions

File tree

.github/workflows/docker.yaml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
- cron: '0 3 * * 1'
1313

1414
env:
15-
REGISTRY: ghcr.io
15+
LATEST_VERSION: ${{ vars.LATEST_PHP_VERSION || '8.4' }}
1616

1717
permissions:
1818
contents: read
@@ -27,7 +27,7 @@ jobs:
2727
changed: ${{ steps.check.outputs.changed }}
2828
steps:
2929
- name: Checkout repository
30-
uses: actions/checkout@v5
30+
uses: actions/checkout@v6
3131

3232
- name: Cache digests
3333
id: cache-digests
@@ -158,11 +158,13 @@ jobs:
158158
- Dockerfile
159159
- alpine.Dockerfile
160160
- frankenphp.Dockerfile
161-
- frankenphp-alpine.Dockerfile
161+
php-version:
162+
- '8.4'
163+
- '8.5'
162164

163165
steps:
164166
- name: Checkout repository
165-
uses: actions/checkout@v5
167+
uses: actions/checkout@v6
166168

167169
- name: Set up QEMU (for ARM builds)
168170
uses: docker/setup-qemu-action@v3
@@ -173,38 +175,41 @@ jobs:
173175
- name: Login to Container Registry
174176
uses: docker/login-action@v3
175177
with:
176-
registry: ${{ env.REGISTRY }}
178+
registry: ghcr.io
177179
username: ${{ github.actor }}
178180
password: ${{ secrets.GITHUB_TOKEN }}
179181

180182
- name: Determine Image Name
181-
id: image_name
183+
id: config
182184

183185
# language=bash
184186
run: |
185-
echo "IMAGE_NAME=${{ github.repository_owner }}/${{ vars.IMAGE_NAME || 'php' }}" >> $GITHUB_ENV
186-
base_version=$( \
187+
flavor=$( \
187188
echo "${{ matrix.dockerfile }}" | \
188189
sed -E 's/.?Dockerfile//' | \
189190
tr '/' '-' \
190191
)
191-
suffix="${{ matrix.stage == 'dev' && 'dev' || '' }}"
192-
echo "VERSION=${base_version:-latest}${suffix:+-}${suffix}" >> $GITHUB_ENV
192+
latest=${{ (matrix.stage == 'prod' && matrix.php-version == env.LATEST_VERSION) && 'true' || 'false' }}
193+
suffix="${{ matrix.stage == 'dev' && '-dev' || '' }}"
194+
echo "latest=${latest}" >> $GITHUB_OUTPUT
195+
echo "version=${{matrix.php-version}}${flavor:+-${flavor}}${suffix}" >> $GITHUB_OUTPUT
196+
echo "image-name=${{ github.repository_owner }}/${{ vars.image-name || 'php' }}" >> $GITHUB_OUTPUT
193197
194198
- name: Set up Docker Metadata
195199
id: meta
196200
uses: docker/metadata-action@v5
197201
with:
198202
images: |
199-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
203+
ghcr.io/${{ steps.config.outputs.image-name }}
200204
labels: |
201-
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
202-
org.opencontainers.image.version=${{ env.VERSION }}
205+
org.opencontainers.image.title=${{ steps.config.outputs.image-name }}
206+
org.opencontainers.image.version=${{ steps.config.outputs.version }}
203207
org.opencontainers.vendor="Matchory GmbH"
208+
flavor: |
209+
latest=${{ steps.config.outputs.latest }}
204210
tags: |
205-
type=sha
206-
type=sha,prefix=${{ env.VERSION }}-
207-
type=raw,value=${{ env.VERSION }}
211+
type=sha,prefix=${{ steps.config.outputs.version }}-
212+
type=raw,value=${{ steps.config.outputs.version }}
208213
209214
- name: Build and Push
210215
id: build
@@ -226,6 +231,6 @@ jobs:
226231
- name: Generate artifact attestation
227232
uses: actions/attest-build-provenance@v3
228233
with:
229-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
234+
subject-name: ghcr.io/${{ steps.config.outputs.image-name }}
230235
subject-digest: ${{ steps.build.outputs.digest }}
231236
push-to-registry: true

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# syntax=docker/dockerfile:1
2-
FROM php:8.4-cli AS upstream
2+
ARG PHP_VERSION="8.4"
3+
FROM php:${PHP_VERSION}-cli AS upstream
34
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
45
--mount=type=cache,target=/var/lib/apt,sharing=locked <<EOF
56
set -eux
@@ -23,7 +24,7 @@ EOF
2324

2425
FROM upstream AS builder
2526
ARG APCU_VERSION="5.1.27"
26-
ARG REDIS_VERSION="6.2.0"
27+
ARG REDIS_VERSION="6.3.0"
2728
ARG OPENSWOOLE_VERSION="25.2.0"
2829

2930
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \

alpine.Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# syntax=docker/dockerfile:1
2-
FROM php:8.4-cli-alpine AS upstream
2+
ARG PHP_VERSION="8.4"
3+
FROM php:${PHP_VERSION}-cli-alpine AS upstream
34
FROM upstream AS base
45
ARG APCU_VERSION="5.1.27"
5-
ARG REDIS_VERSION="6.2.0"
6+
ARG REDIS_VERSION="6.3.0"
67
ARG OPENSWOOLE_VERSION="25.2.0"
78
ARG user="php"
89
ARG uid="5000"

frankenphp-alpine.Dockerfile

Lines changed: 0 additions & 216 deletions
This file was deleted.

frankenphp.Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# syntax=docker/dockerfile:1
2-
FROM dunglas/frankenphp:1.9-php8.4 AS upstream
2+
ARG PHP_VERSION="8.4"
3+
FROM dunglas/frankenphp:1.10-php${PHP_VERSION} AS upstream
34
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
45
--mount=type=cache,target=/var/lib/apt,sharing=locked <<EOF
56
set -eux
@@ -23,7 +24,7 @@ EOF
2324

2425
FROM upstream AS builder
2526
ARG APCU_VERSION="5.1.27"
26-
ARG REDIS_VERSION="6.2.0"
27+
ARG REDIS_VERSION="6.3.0"
2728

2829
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
2930
--mount=type=cache,target=/var/lib/apt,sharing=locked <<EOF

0 commit comments

Comments
 (0)