From fbdfc419274fd0d2d7644845399782d6c942a166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E6=AD=A3=E6=B5=B7?= Date: Sat, 18 May 2019 10:57:01 +0800 Subject: [PATCH] feat: Add PHP_FPM_INSTALL_XHPROF as an option to install xhprof extension (#2077) * feat: Add PHP_FPM_INSTALL_XHPROF as an option to install xhprof extension * fix: INSTALL_XHPROF default value set false --- .gitignore | 2 ++ env-example | 1 + php-fpm/Dockerfile | 28 ++++++++++++++++++++++++++++ php-fpm/xhprof.ini | 8 ++++++++ 4 files changed, 39 insertions(+) create mode 100644 php-fpm/xhprof.ini diff --git a/.gitignore b/.gitignore index affb5c6..0673206 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ /nginx/ssl/*.crt /nginx/ssl/*.key /nginx/ssl/*.csr + +.DS_Store \ No newline at end of file diff --git a/env-example b/env-example index d7bbc98..b5986c1 100644 --- a/env-example +++ b/env-example @@ -153,6 +153,7 @@ PHP_FPM_INSTALL_IMAGE_OPTIMIZERS=true PHP_FPM_INSTALL_PHPREDIS=true PHP_FPM_INSTALL_MEMCACHED=false PHP_FPM_INSTALL_XDEBUG=false +PHP_FPM_INSTALL_XHPROF=false PHP_FPM_INSTALL_PHPDBG=false PHP_FPM_INSTALL_IMAP=false PHP_FPM_INSTALL_MONGO=false diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index 17a9841..9d90ee6 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -239,6 +239,34 @@ RUN if [ ${INSTALL_MONGO} = true ]; then \ docker-php-ext-enable mongodb \ ;fi +########################################################################### +# Xhprof: +########################################################################### + +ARG INSTALL_XHPROF=false + +RUN if [ ${INSTALL_XHPROF} = true ]; then \ + # Install the php xhprof extension + if [ $(php -r "echo PHP_MAJOR_VERSION;") = 7 ]; then \ + curl -L -o /tmp/xhprof.tar.gz "https://github.com/tideways/php-xhprof-extension/archive/v4.1.6.tar.gz"; \ + else \ + curl -L -o /tmp/xhprof.tar.gz "https://codeload.github.com/phacility/xhprof/tar.gz/master"; \ + fi \ + && mkdir -p xhprof \ + && tar -C xhprof -zxvf /tmp/xhprof.tar.gz --strip 1 \ + && ( \ + cd xhprof \ + && phpize \ + && ./configure \ + && make \ + && make install \ + ) \ + && rm -r xhprof \ + && rm /tmp/xhprof.tar.gz \ +;fi + +COPY ./xhprof.ini /usr/local/etc/php/conf.d + ########################################################################### # AMQP: ########################################################################### diff --git a/php-fpm/xhprof.ini b/php-fpm/xhprof.ini new file mode 100644 index 0000000..1b010b9 --- /dev/null +++ b/php-fpm/xhprof.ini @@ -0,0 +1,8 @@ +[xhprof] +; extension=xhprof.so +extension=tideways.so +xhprof.output_dir=/var/www/xhprof +; no need to autoload, control in the program +tideways.auto_prepend_library=0 +; set default rate +tideways.sample_rate=100 \ No newline at end of file