containers icon indicating copy to clipboard operation
containers copied to clipboard

[bitnami/wordpress] [bitnami/wordpress-nginx] Support for PHP Redis Extension in Bitnami WordPress & WordPress-NGINX Containers

Open LucaDev opened this issue 8 months ago • 6 comments

Name and Version

bitnami/wordpress and bitnami/wordpress-nginx

What is the problem this feature will solve?

I would like to add support for the PHP Redis extension (php-redis) to the Bitnami WordPress and WordPress-NGINX containers. Right now, one way to do this would be to compile it manually in each Dockerfile, but that would add a lot of extra code to each Dockerfile, which seems inefficient.

What is the feature you are proposing to solve the problem?

Would it be possible to:

Ship php-redis along with the Bitnami PHP component (perhaps disabled by default)? or Compile it centrally for the relevant PHP version and make it downloadable as a separate component (via stacksmith)?

This has already been requested in issue #16124, and having php-redis available would help many plugins, such as W3 Total Cache.

Here’s an example of how I would integrate it via Dockerfile:

FROM docker.io/bitnami/minideb:bookworm AS builder
 ARG DOWNLOADS_URL="downloads.bitnami.com/files/stacksmith"
 ARG TARGETARCH
 
 ENV HOME="/" \
   OS_ARCH="${TARGETARCH:-amd64}" \
   OS_FLAVOUR="debian-12" \
   OS_NAME="linux"
 
 SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
 
 RUN install_packages autoconf build-essential curl ca-certificates
 RUN mkdir -p /tmp/bitnami/pkg/cache/ ; cd /tmp/bitnami/pkg/cache/ ; mkdir /opt/bitnami ; \
   COMPONENTS=( \
   "php-8.2.27-11-linux-${OS_ARCH}-debian-12" \
   ) ; \
   for COMPONENT in "${COMPONENTS[@]}"; do \
   if [ ! -f "${COMPONENT}.tar.gz" ]; then \
   curl -SsLf "https://${DOWNLOADS_URL}/${COMPONENT}.tar.gz" -O ; \
   curl -SsLf "https://${DOWNLOADS_URL}/${COMPONENT}.tar.gz.sha256" -O ; \
   fi ; \
   sha256sum -c "${COMPONENT}.tar.gz.sha256" ; \
   tar -zxf "${COMPONENT}.tar.gz" -C /opt/bitnami --strip-components=2 --no-same-owner --wildcards '*/files' ; \
   rm -rf "${COMPONENT}".tar.gz{,.sha256} ; \
   done
 RUN cd / ; \
    curl -SsLf https://pecl.php.net/get/redis-6.1.0.tgz | tar xzf - ; mv redis-* redis ; cd redis ; \
    /opt/bitnami/php/bin/phpize ; \
    ./configure --with-php-config=/opt/bitnami/php/bin/php-config ; \
    make 

[...]
And finally in the the actual container:

COPY --from=builder /redis/modules/redis.so /opt/bitnami/php/lib/php/extensions/
RUN echo "extension=redis.so" >> /opt/bitnami/php/etc/php.ini

I am happy to contribute the implementation, but I need guidance on the best approach.

What alternatives have you considered?

No response

LucaDev avatar Mar 23 '25 15:03 LucaDev

Thank you so much for opening the ticket. Let me forward this to engineering team for reconsideration.

javsalgar avatar Mar 24 '25 09:03 javsalgar

Hey @javsalgar, any news on this yet? Seems like more people need/want the redis extension 😄

LucaDev avatar Apr 02 '25 18:04 LucaDev

Hi,

I'm afraid that we currently have no bandwidth to work on this. As soon as we have more news we will update this ticket

javsalgar avatar Apr 03 '25 07:04 javsalgar

Alright. Keep in mind: I'd be glad to implement this for you. I just need a slight guidance on your preferred way of accomplishing it.

LucaDev avatar Apr 04 '25 08:04 LucaDev

Bump

I am trying to install phpredis via a post-install script that runs pecl install redis, but the permissions won't allow it. This is the error from the container's console during bootstrapping:

Cannot install, php_dir for channel "pecl.php.net" is not writeable by the current user

Is there any way to work around this permission limitation?

(Note that my issue is specific to bitnami/matomo but it applies to bitnami/wordpress as well.)

dcoder2099 avatar Jun 03 '25 19:06 dcoder2099

Hi,

Did you try creating a fork image instead of installing it in the container at runtime?

javsalgar avatar Jun 05 '25 07:06 javsalgar