phpwordpressdockerredisigbinary

Redis with igbinary in Wordpress PHP Docker container


I would like to allow my wordpress instance to access database content via Redis, using the igbinary serializer. I am using the Redis Cache Plugin for Worpdress by Till Krüss. According to my understanding the containers should be in the following way:

How to properly include Redis with igbinary support with the wordpress iamge? I tried the following:

FROM wordpress:php7.4-fpm-alpine
RUN set -xe \
&& apk update \
&& apk upgrade \
&& apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS \
&& pecl install -o -f igbinary \
&& cd /usr/src/ \
&& pecl bundle redis \
&& docker-php-ext-configure /usr/src/redis --enable-redis-igbinary \
&& docker-php-ext-install -j$(nproc) /usr/src/redis \
&& docker-php-ext-enable redis \
&& docker-php-ext-enable igbinary \
&& apk del .phpize-deps

I read, that pecl is outdated and should not be used anymore (Instead use pickle or composer, which however do not seem to offer the right packages)

So the question is: How does a Dockerfile have to look like to allow the use of redis with igbinary serializer using modern standards?

I hope you guys can help me :)


Solution

  • Use the following:

    FROM wordpress:php7.4-fpm-alpine
    RUN set -xe \
    && apk update \
    && apk upgrade \
    && apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS \
    # && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
    && wget https://github.com/FriendsOfPHP/pickle/releases/latest/download/pickle.phar \
    && chmod +x pickle.phar \
    && mv pickle.phar /usr/local/bin/pickle \
    && pickle install -n igbinary \
    && docker-php-ext-enable igbinary \
    && echo "--enable-redis-igbinary" > cfg-options.txt \
    && pickle install --with-configure-options cfg-options.txt redis \
    && docker-php-ext-enable redis \
    && apk del .phpize-deps \
    && rm -rf cfg-options.txt \
    && php -m | grep igbinary \
    && php -m | grep redis \
    && php -i | grep igbinary \
    && php -i | grep redis \
    #&& CLI_VERSION=$(wp cli info | grep "WP-CLI version" | cut -d$'\t' -f2) \
    #&& if [ "${CLI_VERSION}" = "2.4.0" ]; then wp cli update --nightly --yes; fi
    

    It is working when using pickel and respecting the order of enabling igbinary extension before redis extension.