docker-magento icon indicating copy to clipboard operation
docker-magento copied to clipboard

Blackfire setup not working

Open moonbowabid opened this issue 8 months ago • 9 comments

Description Blackfire is not working on Mac M3 with Sequoia 15.3.2 (24D81)

Steps To Reproduce

  1. Enter Command bin/root blackfire-agent --register --server-id={YOUR_SERVER_ID} --server-token={YOUR_SERVER_TOKEN}

Expected Result

  • Blackfire is configured and works fine

Actual Result OCI runtime exec failed: exec failed: unable to start container process: exec: "blackfire-agent": executable file not found in $PATH: unknown

moonbowabid avatar May 02 '25 13:05 moonbowabid

Hello @moonbowabid! I'm Dosu, your friendly bug-squashing bot here to help out while you wait for a human maintainer. If you've got questions or need help, I'm all ears! 🐾

The error message indicates that the blackfire-agent executable is not found in the $PATH. Here are some steps to troubleshoot and resolve the issue:

  1. Verify Blackfire Service Configuration: Ensure that the Blackfire service is enabled in your compose.yaml file. Uncomment the relevant section if necessary:

    ## Blackfire support, uncomment to enable
    #blackfire:
    #  image: blackfire/blackfire:2
    #  ports:
    #    - "8307"
    #  env_file: env/blackfire.env
    
  2. Check Environment Variables: Make sure the environment variables are correctly set in the compose/env/phpfpm.env and compose/env/blackfire.env files:

    # compose/env/phpfpm.env
    BLACKFIRE_CLIENT_ID=
    BLACKFIRE_CLIENT_TOKEN=
    
    # compose/env/blackfire.env
    BLACKFIRE_DISABLE_LEGACY_PORT=true
    BLACKFIRE_LOG_LEVEL=
    BLACKFIRE_SERVER_ID=
    BLACKFIRE_SERVER_TOKEN=
    
  3. Start Blackfire Agent: Ensure the Blackfire agent is started by uncommenting the line in the bin/start helper script:

    #bin/root /etc/init.d/blackfire-agent start
    
  4. Restart Containers: After making these changes, restart the containers using bin/restart.

These steps should help ensure that the Blackfire agent is correctly configured and included in the $PATH [1][2][3][4].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar May 02 '25 13:05 dosubot[bot]

@dosu - I did the above mentioned configuration and now I am getting this error and the container is not starting

OCI runtime exec failed: exec failed: unable to start container process: exec: "/etc/init.d/blackfire-agent": stat /etc/init.d/blackfire-agent: no such file or directory: unknown

moonbowabid avatar May 02 '25 13:05 moonbowabid

The error indicates that the /etc/init.d/blackfire-agent file is missing. Here are some steps to address this issue:

  1. Verify Blackfire Installation: Ensure that the Blackfire agent is installed in the Docker container. You can check the Dockerfile for PHP to see if the Blackfire agent installation steps are included. If not, you may need to add them manually.

  2. Check Dockerfile Configuration: Review the Dockerfile for PHP 8.4 to ensure that the Blackfire probe is being downloaded and installed correctly. The Dockerfile should include steps to fetch the probe from Blackfire's API and place it in the appropriate PHP extension directory [1].

  3. Update bin/start Script: If the /etc/init.d/blackfire-agent file is not present, you may need to adjust the bin/start script to start the Blackfire agent using a different method. Verify if there is an alternative way to start the Blackfire agent, such as using a direct command or script provided by Blackfire.

  4. Rebuild Containers: After making changes to the Dockerfile or scripts, rebuild the containers to ensure all configurations are applied correctly.

These steps should help resolve the issue with the missing Blackfire agent file.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar May 02 '25 13:05 dosubot[bot]

@dosu

  1. Since I am using markoshust/magento-php:8.2-fpm-2 image I assumed blackfire would be installed out-of-the box as mentioned in the readme.
  2. Anyways, I went ahead and tried to install within my custom image.
  3. After rebuild I did not get any errors and containers started successfully
  4. But, when i tried to do bin/blackfire status I get this message
cat: /usr/local/etc/php/conf.d/blackfire.ini: No such file or directory

Blackfire is enabled

Code that updates the php image - my custom image

FROM markoshust/magento-php:8.2-fpm-2

USER root

RUN apt-get install -y libssl-dev

RUN docker-php-ext-configure ftp --with-openssl-dir=/usr \
	&& docker-php-ext-install ftp
# Install rsync and wget - to run media downloader script
RUN apt-get update && apt-get install -y \
    rsync \
    wget \
    pngcrush \
    webp \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Install Blackfire
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
    && curl -sL https://packages.blackfire.io/gpg.key | apt-key add - \
    && echo "deb http://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list \
    && apt-get update \
    && apt-get install -y blackfire-agent blackfire-php \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

USER app

moonbowabid avatar May 02 '25 14:05 moonbowabid

The message "cat: /usr/local/etc/php/conf.d/blackfire.ini: No such file or directory" indicates that the blackfire.ini file is missing from the expected location. In the markoshust/magento-php:8.2-fpm-2 image, the blackfire.ini file should be copied during the build process. Ensure that your Dockerfile includes the following line to copy the blackfire.ini file:

COPY conf/blackfire.ini $PHP_INI_DIR/conf.d/blackfire.ini

Make sure that the blackfire.ini file exists in the conf directory relative to your Docker build context. The content of the blackfire.ini file should be:

extension=blackfire.so
blackfire.agent_socket=tcp://blackfire:8307

Verify that this file is correctly placed and accessible during the build process [1][2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar May 02 '25 14:05 dosubot[bot]

Thank you got it working.

moonbowabid avatar May 02 '25 14:05 moonbowabid

@moonbowabid awesome that you worked with the AI to get this resolved 🫠

Do we need to do anything here, liek add anew blackfire.ini file to the project? If so, I can get this added and merged in.

markshust avatar May 05 '25 20:05 markshust

@markshust - yes, i followed the above mentioned steps to resolve this. and final step was very important. Please add the missing files.

moonbowabid avatar May 06 '25 02:05 moonbowabid

@moonbowabid thanks for this! I'll keep this open until I can get around to it. If someone wants to make a PR for this to get it in sooner, I'd gladly take it in!

markshust avatar May 12 '25 14:05 markshust