diff --git a/DOCUMENTATION/content/documentation/index.md b/DOCUMENTATION/content/documentation/index.md index 73e5990b..9370110e 100644 --- a/DOCUMENTATION/content/documentation/index.md +++ b/DOCUMENTATION/content/documentation/index.md @@ -1499,10 +1499,33 @@ e) set it to `true` 3 - Set it to `true`
4 - Re-build the containers `docker-compose build php-fpm` +
+
+ +## Install libfaketime in the php-fpm container +Libfaketime allows you to control the date and time that is returned from the operating system. +It can be used by specifying a special string in the `PHP_FPM_FAKETIME` variable in the `.env` file. +For example: +`PHP_FPM_FAKETIME=-1d` +will set the clock back 1 day. See (https://github.com/wolfcw/libfaketime) for more information. + +1 - Open the `.env` file +
+2 - Search for the `PHP_FPM_INSTALL_FAKETIME` argument under the PHP-FPM container +
+3 - Set it to `true` +
+4 - Search for the `PHP_FPM_FAKETIME` argument under the PHP-FPM container +
+5 - Set it to the desired string +
+6 - Re-build the containers `docker-compose build php-fpm`
+ +
diff --git a/docker-compose.yml b/docker-compose.yml index e1a6f18c..dd595843 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -144,6 +144,7 @@ services: - INSTALL_IMAGE_OPTIMIZERS=${PHP_FPM_INSTALL_IMAGE_OPTIMIZERS} - INSTALL_IMAGEMAGICK=${PHP_FPM_INSTALL_IMAGEMAGICK} - INSTALL_CALENDAR=${PHP_FPM_INSTALL_CALENDAR} + - INSTALL_FAKETIME=${PHP_FPM_INSTALL_FAKETIME} volumes: - ./php-fpm/php${PHP_VERSION}.ini:/usr/local/etc/php/php.ini - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER} @@ -154,6 +155,7 @@ services: environment: - PHP_IDE_CONFIG=${PHP_IDE_CONFIG} - DOCKER_HOST=tcp://docker-in-docker:2375 + - FAKETIME=${PHP_FPM_FAKETIME} depends_on: - workspace networks: diff --git a/env-example b/env-example index 15f55b8d..bad6e1d1 100644 --- a/env-example +++ b/env-example @@ -149,6 +149,8 @@ PHP_FPM_INSTALL_SWOOLE=false PHP_FPM_INSTALL_PG_CLIENT=false PHP_FPM_INSTALL_PCNTL=false PHP_FPM_INSTALL_CALENDAR=false +PHP_FPM_INSTALL_FAKETIME=false +PHP_FPM_FAKETIME=-0 ### PHP_WORKER ############################################ diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index 2fb86df8..71586807 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -485,6 +485,18 @@ RUN if [ ${INSTALL_CALENDAR} = true ]; then \ docker-php-ext-install calendar \ ;fi +########################################################################### +# libfaketime: +########################################################################### + +USER root + +ARG INSTALL_FAKETIME=false + +RUN if [ ${INSTALL_FAKETIME} = true ]; then \ + apt-get install -y libfaketime \ +;fi + ########################################################################### # Check PHP version: ########################################################################### @@ -509,6 +521,12 @@ RUN apt-get clean && \ RUN usermod -u 1000 www-data +# Adding the faketime library to the preload file needs to be done last +# otherwise it will preload it for all commands that follow in this file +RUN if [ ${INSTALL_FAKETIME} = true ]; then \ + echo "/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1" > /etc/ld.so.preload \ +;fi + WORKDIR /var/www CMD ["php-fpm"]