phpdockerblackfire

How to fix Blackfire profiling error when using with Docker Compose?


My app runs with Docker in development mode thanks to a docker-compose.yml file.

I installed Blackfire following to the letter the Docker doc and the PHP Probe doc.

I have the Firefox add-on installed in my browser.

When trying to profile my page (http://localhost) I get the following error:

Are You Authorized to Profile this Page? Probe Not Found or Invalid signature.

I followed what's indicated in the Troubleshooting to try and fix the errors:

Why do I get this error? How can I fix it?


Solution

  • In the documentation about installing Blackfire with Docker in a docker-compose.yml file, the given port in the ports option is 8307.

    version: '3'
    services:
      blackfire:
        image: blackfire/blackfire:2
        ports: ["8307"]
        environment:
            # Exposes BLACKFIRE_* environment variables from the host
            BLACKFIRE_SERVER_ID: ~
            BLACKFIRE_SERVER_TOKEN: ~
            BLACKFIRE_CLIENT_ID: ~
            BLACKFIRE_CLIENT_TOKEN: ~
    

    In the documentation about enabling the PHP Probe with Docker, the given port in both Linux image and Alpine image is 8707 (see second to last line starting with && printf "extension=blackfire.so). Below the example for Linux Image:

    FROM php:7.4-fpm
    
    RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
        && architecture=$(case $(uname -m) in i386 | i686 | x86) echo "i386" ;; x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) \
        && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/$architecture/$version \
        && mkdir -p /tmp/blackfire \
        && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
        && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
        && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
        && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
    

    You should change one or the other port to have the same one at the two places. Then restart your containers.


    Edit: The error has been fixed.