From e7a348cd0fe821c9cf798ef5cc724d3a53eda819 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sat, 24 Feb 2024 01:18:08 +0100 Subject: [PATCH] Setup Blackfire --- .env | 4 ++++ .gitignore | 2 ++ docker-compose.yml | 9 +++++++++ docker/php/Dockerfile | 15 +++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 000000000..148e3bf25 --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +BLACKFIRE_SERVER_ID=CHANGE_ME +BLACKFIRE_SERVER_TOKEN=CHANGE_ME +BLACKFIRE_CLIENT_ID=CHANGE_ME +BLACKFIRE_CLIENT_TOKEN=CHANGE_ME diff --git a/.gitignore b/.gitignore index 0f2969783..2d638ee59 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,5 @@ specialexport.json # Custom CSS file web/custom.css + +.env.local diff --git a/docker-compose.yml b/docker-compose.yml index c92bd2c0a..92a143a58 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,6 +32,8 @@ services: # - ./docker/postgres/env # Uncomment to enable Xdebug # - ./docker/php/xdebug + - .env + - .env.local ports: - 8000:8000 # Uncomment to permit Xdebug remote session @@ -75,6 +77,13 @@ services: timeout: 3s retries: 3 + blackfire: + image: blackfire/blackfire:2 + ports: [ "8307" ] + env_file: + - .env + - .env.local + volumes: db-data: driver: local diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index cab35a245..44c923e21 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -60,6 +60,21 @@ RUN pecl install redis; \ xdebug \ ; +RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ + && architecture=$(uname -m) \ + && 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:8307\n" > $PHP_INI_DIR/conf.d/blackfire.ini \ + && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz + +RUN mkdir -p /tmp/blackfire \ + && architecture=$(uname -m) \ + && curl -A "Docker" -L https://blackfire.io/api/v1/releases/cli/linux/$architecture | tar zxp -C /tmp/blackfire \ + && mv /tmp/blackfire/blackfire /usr/bin/blackfire \ + && rm -Rf /tmp/blackfire + RUN npm install -g yarn RUN curl -L -o /usr/local/bin/envsubst https://github.com/a8m/envsubst/releases/download/v1.1.0/envsubst-`uname -s`-`uname -m`; \