Browse Source

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
蔡正海 6 years ago
parent
commit
fbdfc41927
4 changed files with 39 additions and 0 deletions
  1. 2 0
      .gitignore
  2. 1 0
      env-example
  3. 28 0
      php-fpm/Dockerfile
  4. 8 0
      php-fpm/xhprof.ini

+ 2 - 0
.gitignore

@@ -12,3 +12,5 @@
 /nginx/ssl/*.crt
 /nginx/ssl/*.crt
 /nginx/ssl/*.key
 /nginx/ssl/*.key
 /nginx/ssl/*.csr
 /nginx/ssl/*.csr
+
+.DS_Store

+ 1 - 0
env-example

@@ -153,6 +153,7 @@ PHP_FPM_INSTALL_IMAGE_OPTIMIZERS=true
 PHP_FPM_INSTALL_PHPREDIS=true
 PHP_FPM_INSTALL_PHPREDIS=true
 PHP_FPM_INSTALL_MEMCACHED=false
 PHP_FPM_INSTALL_MEMCACHED=false
 PHP_FPM_INSTALL_XDEBUG=false
 PHP_FPM_INSTALL_XDEBUG=false
+PHP_FPM_INSTALL_XHPROF=false
 PHP_FPM_INSTALL_PHPDBG=false
 PHP_FPM_INSTALL_PHPDBG=false
 PHP_FPM_INSTALL_IMAP=false
 PHP_FPM_INSTALL_IMAP=false
 PHP_FPM_INSTALL_MONGO=false
 PHP_FPM_INSTALL_MONGO=false

+ 28 - 0
php-fpm/Dockerfile

@@ -239,6 +239,34 @@ RUN if [ ${INSTALL_MONGO} = true ]; then \
     docker-php-ext-enable mongodb \
     docker-php-ext-enable mongodb \
 ;fi
 ;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:
 # AMQP:
 ###########################################################################
 ###########################################################################

+ 8 - 0
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