Skip to content

Commit 26fb522

Browse files
committed
Enhance Dockerfiles to conditionally install opcache for PHP versions below 8.5( PHP 8.5 integrates it directly https://wiki.php.net/rfc/make_opcache_required)
1 parent 2781ee7 commit 26fb522

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

.github/workflows/Dockerfile.centos-php-test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ RUN dnf --assumeyes module reset php
1919
RUN dnf --assumeyes --nogpgcheck module install php:remi-${PHP_VERSION}
2020
RUN dnf --assumeyes install php-pdo
2121
RUN dnf --assumeyes install php-mysqlnd
22+
RUN if [ "$(printf '%s\n' "${PHP_VERSION}" "8.5" | sort -V | head -n1)" != "8.5" ]; then \
23+
dnf --assumeyes install php-opcache || true; \
24+
fi
2225
RUN yum install -y mod_php nginx php-fpm procps-ng mysql-server
2326

2427

.github/workflows/Dockerfile.ubuntu-php-test

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ RUN apt-get update
2727

2828
RUN set -eux; \
2929
PHP_PKG="php${PHP_VERSION}"; \
30-
apt-get install -y --no-install-recommends \
31-
nginx \
32-
apache2 \
33-
mariadb-server \
30+
# Build package list - PHP 8.5+ has opcache bundled, so skip the separate opcache package \
31+
PACKAGES="nginx apache2 mariadb-server \
3432
${PHP_PKG} ${PHP_PKG}-cli ${PHP_PKG}-common ${PHP_PKG}-fpm \
3533
${PHP_PKG}-curl ${PHP_PKG}-sqlite3 ${PHP_PKG}-mysql \
36-
${PHP_PKG}-mbstring ${PHP_PKG}-xml ${PHP_PKG}-zip ${PHP_PKG}-opcache \
37-
libapache2-mod-php${PHP_VERSION} \
38-
; \
34+
${PHP_PKG}-mbstring ${PHP_PKG}-xml ${PHP_PKG}-zip \
35+
libapache2-mod-php${PHP_VERSION}"; \
36+
if [ "$(printf '%s\n' "${PHP_VERSION}" "8.5" | sort -V | head -n1)" != "8.5" ]; then \
37+
PACKAGES="${PACKAGES} ${PHP_PKG}-opcache"; \
38+
fi; \
39+
apt-get install -y --no-install-recommends ${PACKAGES} \
3940
# Apache: switch to prefork for mod_php scenario and enable rewrite
4041
a2dismod mpm_event || true; \
4142
a2dismod mpm_worker || true; \

0 commit comments

Comments
 (0)