Enable APCU CLI on docker php 7.3

Alessandro Candon picture Alessandro Candon · Feb 22, 2019 · Viewed 13.1k times · Source

I'm trying to enable apcu cli on my docker container in order to run my test. This is my docker file, I use :

  • basic php image
  • install composer
  • install xdebug
  • install more docker libs
  • install apcu

When I try to run my test inside this docker, it fails due to apcu error. However, in prod the apcu works well because it is enabled but the test needs to have enabled the cli.

FROM php:7.3-cli

ARG APCU_VERSION=5.1.11

RUN apt-get update  && apt-get -y install git zip libzip-dev wget \
zlib1g-dev unzip libpq-dev git-core libmcrypt-dev vim libfcgi0ldbl gnupg \
libfreetype6-dev libjpeg62-turbo-dev libpng-dev libicu-dev

#INSTALL COMPOSER
RUN echo "memory_limit = -1" > /usr/local/etc/php/conf.d/memory_limit.ini
RUN curl -sS http://getcomposer.org/installer | php -- --filename=composer && chmod a+x composer  && mv composer /usr/local/bin/composer
RUN echo 'export PATH=~/.composer/vendor/bin:$PATH' >> ~/.bashrc
RUN composer global require hirak/prestissimo

#ENABLE DOCKER LIBS
RUN docker-php-ext-install zip pdo pdo_pgsql pgsql mbstring opcache -j$(nproc) gd
RUN docker-php-ext-configure intl && docker-php-ext-install intl
RUN docker-php-ext-configure opcache --enable-opcache
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/

#INSTALL XDEBUG
RUN pecl install xdebug-2.7.0RC1 && docker-php-ext-enable xdebug
#XDEBUG

#INSTALL APCU
RUN pecl install apcu-${APCU_VERSION} && docker-php-ext-enable apcu
RUN echo "extension=apcu.so" > /usr/local/etc/php/php.ini
RUN echo "apc.enable_cli=1" > /usr/local/etc/php/php.ini
RUN echo "apc.enable=1" > /usr/local/etc/php/php.ini
#APCU

RUN php --ini
RUN php --info | grep apc

#MAKE tmp WRITABLE
RUN chmod 777 -R /tmp && chmod o+t -R /tmp

But at the end when I print php info the result is :

Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini,
apcu
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On
apc.entries_hint => 4096 => 4096
apc.gc_ttl => 3600 => 3600
apc.mmap_file_mask => no value => no value
apc.preload_path => no value => no value
apc.serializer => php => php
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.slam_defense => On => On
apc.smart => 0 => 0
apc.ttl => 0 => 0
apc.use_request_time => On => On
apc.writable => /tmp => /tmp

Thank you for your help.

Regards

Answer

Alessandro Candon picture Alessandro Candon · Feb 27, 2019

Sorrry,

my fault...

If you want to append a string to a file you have to use >> on echo line.

I hope this will help someone, regards