Skip to content

Commit

Permalink
add blackfire php probe (uselagoon#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
Schnitzel authored Dec 10, 2020
1 parent 0ae8ee0 commit 3429d59
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 3 deletions.
11 changes: 10 additions & 1 deletion 7.2.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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 \
Expand Down
11 changes: 10 additions & 1 deletion 7.3.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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 \
Expand Down
11 changes: 10 additions & 1 deletion 7.4.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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 \
Expand Down
19 changes: 19 additions & 0 deletions blackfire.ini
Original file line number Diff line number Diff line change
@@ -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}
23 changes: 23 additions & 0 deletions entrypoints/80-php-blackfire.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3429d59

Please sign in to comment.