flownative / docker-beach-php

Docker image providing PHP-FPM for Flownative Beach and Local Beach
MIT License
1 stars 1 forks source link

Blackfire "agent socket" not reachable as 127.0.0.1 (in Local Beach) #2

Open kdambekalns opened 2 years ago

kdambekalns commented 2 years ago

The update to Blackfire v2 works fine if the BLACKFIRE_AGENT_SOCKET is set correctly in Local Beach. Otherwise you get a hard-to-debug message

Are you authorized to profile this page? No probe response, missing PHP extension or invalid signature for relaying agent.

when trying to debug HTTP requests (blackfire run inside Local Beach works fine!)

kdambekalns commented 2 years ago

Observations for Local Beach

These are needed environment variables for the blackfire/blackfire container:

      - BLACKFIRE_CLIENT_ID=${BLACKFIRE_CLIENT_ID}
      - BLACKFIRE_CLIENT_TOKEN=${BLACKFIRE_CLIENT_TOKEN}
      - BLACKFIRE_SERVER_ID=${BLACKFIRE_SERVER_ID}
      - BLACKFIRE_SERVER_TOKEN=${BLACKFIRE_SERVER_TOKEN}

That's what is needed, says their documentation. One can add these to get more logging and remove a warning:

      - BLACKFIRE_LOG_LEVEL=3
      - BLACKFIRE_DISABLE_LEGACY_PORT=true

These are needed environment variables for the flownative/beach-php container:

      - BEACH_ADDON_BLACKFIRE_ENABLE=true
      - BLACKFIRE_CLIENT_ID=${BLACKFIRE_CLIENT_ID}
      - BLACKFIRE_CLIENT_TOKEN=…${BLACKFIRE_CLIENT_TOKEN}
      - BLACKFIRE_SERVER_ID=${BLACKFIRE_SERVER_ID}
      - BLACKFIRE_SERVER_TOKEN=${BLACKFIRE_SERVER_TOKEN}
      - BLACKFIRE_AGENT_SOCKET=tcp://<project-name>_blackfire.local_beach:8307

Internally, it's a bit weird right now… BEACH_ADDON_BLACKFIRE_SERVER_* are set from BLACKFIRE_SERVER_* if not defined:

https://github.com/flownative/docker-beach-php/blob/d7941acc73c414a2cc62aafd2bf3e428f2457ea0/root-files/opt/flownative/lib/beach.sh#L59-L60

And then BLACKFIRE_SERVER_* are (re-)set from BEACH_ADDON_BLACKFIRE_SERVER_*:

https://github.com/flownative/docker-beach-php/blob/d7941acc73c414a2cc62aafd2bf3e428f2457ea0/root-files/opt/flownative/lib/beach.sh#L65-L66

I suggest to drop BEACH_ADDON_BLACKFIRE_SERVER_* completely.