diff --git a/images/php-fpm/7.2.Dockerfile b/images/php-fpm/7.2.Dockerfile index 898b2a00c..6ab6bdcf0 100644 --- a/images/php-fpm/7.2.Dockerfile +++ b/images/php-fpm/7.2.Dockerfile @@ -35,12 +35,13 @@ ENV TMPDIR=/tmp \ BASH_ENV=/home/.bashrc COPY check_fcgi /usr/sbin/ -COPY entrypoints/70-php-config.sh entrypoints/60-php-xdebug.sh entrypoints/50-ssmtp.sh entrypoints/71-php-newrelic.sh /lagoon/entrypoints/ +COPY entrypoints/70-php-config.sh entrypoints/60-php-xdebug.sh entrypoints/50-ssmtp.sh entrypoints/71-php-newrelic.sh entrypoints/80-php-blackfire.sh /lagoon/entrypoints/ COPY php.ini /usr/local/etc/php/ COPY 00-lagoon-php.ini.tpl /usr/local/etc/php/conf.d/ COPY php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf COPY ssmtp.conf /etc/ssmtp/ssmtp.conf +COPY blackfire.ini /usr/local/etc/php/conf.d/blackfire.disable # New Relic PHP Agent. # @see https://docs.newrelic.com/docs/release-notes/agent-release-notes/php-release-notes/ @@ -105,6 +106,14 @@ RUN apk add --no-cache fcgi \ && fix-permissions /app \ && fix-permissions /etc/ssmtp/ssmtp.conf +# Add blackfire probe. +RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ + && mkdir -p /blackfire \ + && curl -A "Docker" -o /blackfire/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/alpine/amd64/$version \ + && tar zxpf /blackfire/blackfire-probe.tar.gz -C /blackfire \ + && mv /blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ + && rm -rf /blackfire + EXPOSE 9000 ENV AMAZEEIO_DB_HOST=mariadb \ diff --git a/images/php-fpm/7.3.Dockerfile b/images/php-fpm/7.3.Dockerfile index d7fd591fc..df0a1a473 100644 --- a/images/php-fpm/7.3.Dockerfile +++ b/images/php-fpm/7.3.Dockerfile @@ -35,12 +35,13 @@ ENV TMPDIR=/tmp \ BASH_ENV=/home/.bashrc COPY check_fcgi /usr/sbin/ -COPY entrypoints/70-php-config.sh entrypoints/60-php-xdebug.sh entrypoints/50-ssmtp.sh entrypoints/71-php-newrelic.sh /lagoon/entrypoints/ +COPY entrypoints/70-php-config.sh entrypoints/60-php-xdebug.sh entrypoints/50-ssmtp.sh entrypoints/71-php-newrelic.sh entrypoints/80-php-blackfire.sh /lagoon/entrypoints/ COPY php.ini /usr/local/etc/php/ COPY 00-lagoon-php.ini.tpl /usr/local/etc/php/conf.d/ COPY php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf COPY ssmtp.conf /etc/ssmtp/ssmtp.conf +COPY blackfire.ini /usr/local/etc/php/conf.d/blackfire.disable # New Relic PHP Agent. # @see https://docs.newrelic.com/docs/release-notes/agent-release-notes/php-release-notes/ @@ -105,6 +106,14 @@ RUN apk add --no-cache fcgi \ && fix-permissions /app \ && fix-permissions /etc/ssmtp/ssmtp.conf +# Add blackfire probe. +RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ + && mkdir -p /blackfire \ + && curl -A "Docker" -o /blackfire/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/alpine/amd64/$version \ + && tar zxpf /blackfire/blackfire-probe.tar.gz -C /blackfire \ + && mv /blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ + && rm -rf /blackfire + EXPOSE 9000 ENV AMAZEEIO_DB_HOST=mariadb \ diff --git a/images/php-fpm/7.4.Dockerfile b/images/php-fpm/7.4.Dockerfile index 0c4f400b6..9bc4fa8bb 100644 --- a/images/php-fpm/7.4.Dockerfile +++ b/images/php-fpm/7.4.Dockerfile @@ -35,12 +35,13 @@ ENV TMPDIR=/tmp \ BASH_ENV=/home/.bashrc COPY check_fcgi /usr/sbin/ -COPY entrypoints/70-php-config.sh entrypoints/60-php-xdebug.sh entrypoints/50-ssmtp.sh entrypoints/71-php-newrelic.sh /lagoon/entrypoints/ +COPY entrypoints/70-php-config.sh entrypoints/60-php-xdebug.sh entrypoints/50-ssmtp.sh entrypoints/71-php-newrelic.sh entrypoints/80-php-blackfire.sh /lagoon/entrypoints/ COPY php.ini /usr/local/etc/php/ COPY 00-lagoon-php.ini.tpl /usr/local/etc/php/conf.d/ COPY php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf COPY ssmtp.conf /etc/ssmtp/ssmtp.conf +COPY blackfire.ini /usr/local/etc/php/conf.d/blackfire.disable # New Relic PHP Agent. # @see https://docs.newrelic.com/docs/release-notes/agent-release-notes/php-release-notes/ @@ -105,6 +106,14 @@ RUN apk add --no-cache fcgi \ && fix-permissions /app \ && fix-permissions /etc/ssmtp/ssmtp.conf +# Add blackfire probe. +RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ + && mkdir -p /blackfire \ + && curl -A "Docker" -o /blackfire/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/alpine/amd64/$version \ + && tar zxpf /blackfire/blackfire-probe.tar.gz -C /blackfire \ + && mv /blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ + && rm -rf /blackfire + EXPOSE 9000 ENV AMAZEEIO_DB_HOST=mariadb \ diff --git a/images/php-fpm/blackfire.ini b/images/php-fpm/blackfire.ini new file mode 100644 index 000000000..58a0268e8 --- /dev/null +++ b/images/php-fpm/blackfire.ini @@ -0,0 +1,19 @@ +[blackfire] +extension=blackfire.so + +; Sets fine-grained configuration for Probe. +; This should be left blank in most cases. For most installs, +; the server credentials should only be set in the agent. +blackfire.server_id = ${BLACKFIRE_SERVER_ID:-} + +; Sets fine-grained configuration for Probe. +; This should be left blank in most cases. For most installs, +; the server credentials should only be set in the agent. +blackfire.server_token = ${BLACKFIRE_SERVER_TOKEN:-} + +; Log verbosity level (4: debug, 3: info, 2: warning, 1: error) +blackfire.log_level = ${BLACKFIRE_LOG_LEVEL:-1} + +blackfire.agent_socket = ${BLACKFIRE_AGENT_SOCKET:-} + +blackfire.apm_enabled = ${BLACKFIRE_APM_ENABLED:-0} diff --git a/images/php-fpm/entrypoints/80-php-blackfire.sh b/images/php-fpm/entrypoints/80-php-blackfire.sh new file mode 100644 index 000000000..e8f468c25 --- /dev/null +++ b/images/php-fpm/entrypoints/80-php-blackfire.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# enable blackfire only if BLACKFIRE_ENABLED is set +if [ ${BLACKFIRE_ENABLED+x} ]; then + + # if BLACKFIRE_AGENT_SOCKET is not set already, check if we can access well known locations + if [ -z "${BLACKFIRE_AGENT_SOCKET}" ]; then + # check for blackfire running in cluster + if nc -z -w 1 blackfire.blackfire.svc.cluster.local 8707 &> /dev/null; then + export BLACKFIRE_AGENT_SOCKET=tcp://blackfire.blackfire.svc.cluster.local:8707 + # check for blackfire running in same namespace + elif nc -z -w 1 blackfire 8707 &> /dev/null; then + export BLACKFIRE_AGENT_SOCKET=tcp://blackfire:8707 + fi + fi + + # envplate the blackfire ini file + ep /usr/local/etc/php/conf.d/blackfire.disable + + # copy the envplated file so that php will use it + cp /usr/local/etc/php/conf.d/blackfire.disable /usr/local/etc/php/conf.d/blackfire.ini + +fi \ No newline at end of file