|
4 | 4 | set -ex
|
5 | 5 |
|
6 | 6 | # Install Blackfire
|
7 |
| -version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") |
8 |
| - |
9 | 7 | if [[ -z "${BLACKFIRE_VERSION}" ]]; then
|
10 | 8 | echo "Blackfire version is not set in the environment variables. Exiting!"
|
11 | 9 | exit 1
|
|
14 | 12 | # Let's make it flexible: for those who want to be safe, the image will be built with v1
|
15 | 13 | # Now if you build the image yourself, you can build it with v2, this way everyone gets happy :)
|
16 | 14 |
|
17 |
| -mkdir /tmp/blackfire |
| 15 | +version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") |
| 16 | +# Probe is the same for v1 and v2 |
| 17 | +curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/${TARGETOS}/${TARGETARCH}/$version |
| 18 | +mkdir -p /tmp/blackfire |
| 19 | +tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire |
| 20 | +mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so |
| 21 | +printf "extension=blackfire.so" > "/etc/php/${PHP_VERSION}/mods-available/blackfire.ini" |
| 22 | +rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz |
18 | 23 |
|
19 | 24 | if [ $BLACKFIRE_VERSION == "1" ]; then
|
20 |
| - echo "Installing Blackfire version 1" |
21 |
| - # curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v2/releases/probe/php/linux/amd64/$version |
22 |
| - curl -o /tmp/blackfire/blackfire.so "https://packages.blackfire.io/binaries/blackfire-php/1.78.0/blackfire-php-${TARGETOS}"_"${TARGETARCH}-php-${version}.so" |
23 |
| - mv /tmp/blackfire/blackfire.so $(php -r "echo ini_get('extension_dir');")/blackfire.so |
24 |
| - echo "extension=blackfire" > /etc/php/${PHP_VERSION}/mods-available/blackfire.ini |
25 |
| - |
26 |
| - # Adding this in the list of Ubuntu extensions because we use that list as a base for the modules list. |
27 |
| - # TODO: question: cannot we use /etc/php/mods-available instead??? |
28 |
| - touch /var/lib/php/modules/${PHP_VERSION}/registry/blackfire |
29 |
| - # curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire |
30 |
| - curl -o /tmp/blackfire/blackfire "https://packages.blackfire.io/binaries/blackfire-agent/1.50.0/blackfire-cli-${TARGETOS}"_"${TARGETARCH}" |
31 |
| - chmod +x /tmp/blackfire/blackfire |
32 |
| - mv /tmp/blackfire/blackfire /usr/bin/blackfire |
33 |
| - rm -Rf /tmp/blackfire |
34 |
| - |
| 25 | + # Cli for v1 require specific version |
| 26 | + curl -A "Docker" "https://packages.blackfire.io/binaries/blackfire-agent/1.50.0/blackfire-cli-${TARGETOS}"_"${TARGETARCH}" -o /tmp/blackfire |
| 27 | + chmod +x /tmp/blackfire |
| 28 | + mv /tmp/blackfire /usr/bin/blackfire |
| 29 | + rm -Rf /tmp/blackfire |
35 | 30 | elif [ $BLACKFIRE_VERSION == "2" ]; then
|
36 |
| - echo "Installing Blackfire version 2..." |
37 |
| - |
38 |
| - curl -o /tmp/blackfire/blackfire.so "https://packages.blackfire.io/binaries/blackfire-php/1.78.0/blackfire-php-${TARGETOS}"_"${TARGETARCH}-php-${version}.so" |
39 |
| - mv /tmp/blackfire/blackfire.so $(php -r "echo ini_get('extension_dir');")/blackfire.so |
40 |
| - echo "extension=blackfire.so" > /etc/php/${PHP_VERSION}/mods-available/blackfire.ini |
41 |
| - touch /var/lib/php/modules/${PHP_VERSION}/registry/blackfire |
42 |
| - curl -o /tmp/blackfire-cli.tar.gz "https://packages.blackfire.io/binaries/blackfire/2.10.0/blackfire-"${TARGETOS}"_"${TARGETARCH}".tar.gz" |
43 |
| - tar zxpf /tmp/blackfire-cli.tar.gz -C /tmp/blackfire |
44 |
| - mv /tmp/blackfire/blackfire /usr/bin/blackfire |
45 |
| - |
46 |
| - rm -Rf /tmp/blackfire |
| 31 | + # Cli for v2 is latest version |
| 32 | + echo "Installing Blackfire version 2..." |
| 33 | + mkdir -p /tmp/blackfire |
| 34 | + curl -A "Docker" -L https://blackfire.io/api/v1/releases/cli/linux/${TARGETARCH} | tar zxp -C /tmp/blackfire |
| 35 | + if ! /tmp/blackfire/blackfire self:version --no-ansi | grep -qE "version 2\.[0-9]+\.[0-9]+"; then |
| 36 | + echo "Blackfire installed is not version 2 : $(/tmp/blackfire/blackfire self:version --no-ansi)" |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | + mv /tmp/blackfire/blackfire /usr/bin/blackfire |
| 40 | + rm -Rf /tmp/blackfire |
47 | 41 | else
|
48 | 42 | echo "Blackfire version in environment variable is either empty or the value is invalid"
|
49 | 43 | echo "Value: '$BLACKFIRE_VERSION'"
|
|
0 commit comments