From 80f972d6c0078ef2c2af062954702cf48a5f5ab6 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Thu, 25 May 2023 08:59:30 +0200 Subject: [PATCH 01/13] add profiler, use cache and dd-library files --- bin/compile | 48 +++++++++++++++++++++++++++++++----------------- bin/detect | 2 +- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/bin/compile b/bin/compile index 84c165c..4071d3b 100755 --- a/bin/compile +++ b/bin/compile @@ -39,7 +39,7 @@ export_env_dir() { export_env_dir "$ENV_DIR" '^DDTRACE_EXT_' -topic "Preparing to install ddtrace PHP extension" +topic "Preparing to install Datadog PHP extensions" if [[ -n ${DDTRACE_EXT_PKG_URL:-} ]]; then echo "Using package URL '$DDTRACE_EXT_PKG_URL' (from "'$DDTRACE_EXT_PKG_URL env var).' | indent @@ -47,27 +47,37 @@ else if [[ -n ${DDTRACE_EXT_RELEASE:-} ]]; then echo "Using dd-trace-php release '$DDTRACE_EXT_RELEASE' (from "'$DDTRACE_EXT_RELEASE env var).' | indent else - export DDTRACE_EXT_RELEASE="0.82.0" + export DDTRACE_EXT_RELEASE="0.87.2" echo "Using dd-trace-php release '$DDTRACE_EXT_RELEASE' (default value)." | indent fi - export DDTRACE_EXT_PKG_URL="https://github.com/DataDog/dd-trace-php/releases/download/"$DDTRACE_EXT_RELEASE"/datadog-php-tracer_"$DDTRACE_EXT_RELEASE"_amd64.deb" + export DDTRACE_EXT_PKG_URL="https://github.com/DataDog/dd-trace-php/releases/download/"$DDTRACE_EXT_RELEASE"/dd-library-php-"$DDTRACE_EXT_RELEASE"-x86_64-linux-gnu.tar.gz" fi -APT_DIR="$BUILD_DIR/.apt" -APT_CACHE_DIR="$CACHE_DIR/apt/cache" -PACKAGE_NAME="dd-php-tracer" -PACKAGE_FILE=$APT_CACHE_DIR/archives/$PACKAGE_NAME.deb +if [[ "$DDTRACE_EXT_PKG_URL" != *tar.gz ]] +then + echo "Deprecated package URL. Please note that it is encourage to use the 'dd-library-php-*-x86_64-linux-gnu.tar.gz' distribution" | indent + exit 1 +fi -mkdir -p $APT_CACHE_DIR/archives/partial -mkdir -p $BUILD_DIR/.apt +mkdir -p $CACHE_DIR + +PACKAGE_NAME="dd-library-php-"$DDTRACE_EXT_RELEASE +PACKAGE_FILE=$CACHE_DIR/$PACKAGE_NAME.tar.gz topic "Downloading package from $DDTRACE_EXT_PKG_URL" -curl --silent --show-error --fail --location --output $PACKAGE_FILE $DDTRACE_EXT_PKG_URL 2>&1 | indent +if [[ -f ${PACKAGE_FILE} ]]; +then + echo "Found cached file at "$PACKAGE_FILE | indent +else + curl --silent --show-error --fail --location --output $PACKAGE_FILE $DDTRACE_EXT_PKG_URL 2>&1 | indent +fi + +mkdir -p $BUILD_DIR/.apt/opt -topic "Installing ddtrace PHP extension" -dpkg -x $PACKAGE_FILE $BUILD_DIR/.apt/ +topic "Installing Datadog PHP extensions" +tar -zxvf $PACKAGE_FILE --directory=$BUILD_DIR/.apt/opt 2>&1 | indent -topic "Enabling ddtrace PHP extension" +topic "Enabling Datadog PHP extensions" if [[ -n ${DDTRACE_EXT_PHP_API:-} ]]; then echo "Using version '$DDTRACE_EXT_PHP_API' (from "'$DDTRACE_EXT_PHP_API env var).' | indent @@ -76,9 +86,13 @@ else echo "Using version '$DDTRACE_EXT_PHP_API' (default value)." | indent fi -touch /app/.heroku/php/etc/php/conf.d/datadog-php-custom.ini -echo "[PHP]" >> /app/.heroku/php/etc/php/conf.d/datadog-php-custom.ini -echo "extension=/app/.apt/opt/datadog-php/extensions/ddtrace-$DDTRACE_EXT_PHP_API.so" >> /app/.heroku/php/etc/php/conf.d/datadog-php-custom.ini -echo "ddtrace.request_init_hook=/app/.apt/opt/datadog-php/dd-trace-sources/bridge/dd_wrap_autoloader.php" >> /app/.heroku/php/etc/php/conf.d/datadog-php-custom.ini +INI_FILE=/app/.heroku/php/etc/php/conf.d/datadog-php-custom.ini +INI_FILE=datadog-php-custom.ini + +touch $INI_FILE +echo "[PHP]" >> $INI_FILE +echo "extension=/app/.apt/opt/dd-library-php/trace/ext/$DDTRACE_EXT_PHP_API/ddtrace.so" >> $INI_FILE +echo "ddtrace.request_init_hook=/app/.apt/opt/dd-library-php/trace/bridge/dd_wrap_autoloader.php" >> $INI_FILE +echo "extension=/app/.apt/opt/dd-library-php/profiling/ext/$DDTRACE_EXT_PHP_API/datadog-profiling.so" >> $INI_FILE echo "Done" | indent diff --git a/bin/detect b/bin/detect index 7c9f895..6c63f13 100755 --- a/bin/detect +++ b/bin/detect @@ -1,4 +1,4 @@ #!/usr/bin/env bash -echo "ddtrace PHP extension" +echo "Datadog PHP extensions" exit 0 From 3833a27ecb4d56cb4aa62ff1df2c5ed1c4f3f15e Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Thu, 25 May 2023 09:09:58 +0200 Subject: [PATCH 02/13] make profiler ext enabling configurable --- README.md | 1 + bin/compile | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b022c9..a3ac29b 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ This buildpack accepts several config vars. All of them are optional: - `DDTRACE_EXT_PHP_API` - The PHP API version that your application uses. Defaults to `20210902`. Use `phpinfo()` to find the API version if you're not sure. - `DDTRACE_EXT_RELEASE` - The release name of [dd-trace-php](https://github.com/DataDog/dd-trace-php/releases/) to download. Defaults to `0.82.0`. - `DDTRACE_EXT_PKG_URL` - The URL to a dd-trace-php `.deb` file. This option overides `DDTRACE_EXT_RELEASE`. +- `DD_PROFILING_ENABLED` - This will enable the profiling extension. ### More information: `DDTRACE_EXT_PHP_API` diff --git a/bin/compile b/bin/compile index 4071d3b..3364194 100755 --- a/bin/compile +++ b/bin/compile @@ -93,6 +93,11 @@ touch $INI_FILE echo "[PHP]" >> $INI_FILE echo "extension=/app/.apt/opt/dd-library-php/trace/ext/$DDTRACE_EXT_PHP_API/ddtrace.so" >> $INI_FILE echo "ddtrace.request_init_hook=/app/.apt/opt/dd-library-php/trace/bridge/dd_wrap_autoloader.php" >> $INI_FILE -echo "extension=/app/.apt/opt/dd-library-php/profiling/ext/$DDTRACE_EXT_PHP_API/datadog-profiling.so" >> $INI_FILE + +if [[ -n ${DD_PROFILING_ENABLED:-} ]]; +then + echo "Enabling the profiler" | indent + echo "extension=/app/.apt/opt/dd-library-php/profiling/ext/$DDTRACE_EXT_PHP_API/datadog-profiling.so" >> $INI_FILE +fi echo "Done" | indent From 9a668697d16bfe82d1f73dc9f00f1d8ee889f5bc Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Thu, 25 May 2023 11:33:33 +0200 Subject: [PATCH 03/13] fix wording and give better advice --- bin/compile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index 3364194..1e03a20 100755 --- a/bin/compile +++ b/bin/compile @@ -55,7 +55,7 @@ fi if [[ "$DDTRACE_EXT_PKG_URL" != *tar.gz ]] then - echo "Deprecated package URL. Please note that it is encourage to use the 'dd-library-php-*-x86_64-linux-gnu.tar.gz' distribution" | indent + echo "The package URL is out of date. Please note to use the 'dd-library-php-*-x86_64-linux-gnu.tar.gz' files from the releases at https://github.com/DataDog/dd-trace-php/releases" | indent exit 1 fi From de724d71122f8b19c89f91873a444d51a3351930 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Thu, 25 May 2023 11:35:04 +0200 Subject: [PATCH 04/13] remove testing code --- bin/compile | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/compile b/bin/compile index 1e03a20..2757ce1 100755 --- a/bin/compile +++ b/bin/compile @@ -87,7 +87,6 @@ else fi INI_FILE=/app/.heroku/php/etc/php/conf.d/datadog-php-custom.ini -INI_FILE=datadog-php-custom.ini touch $INI_FILE echo "[PHP]" >> $INI_FILE From f67fff3e34474f78879885a3bc3652ac8ab200d1 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Tue, 30 May 2023 09:39:19 +0200 Subject: [PATCH 05/13] fix environment variable usage --- bin/compile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index 2757ce1..e2a7213 100755 --- a/bin/compile +++ b/bin/compile @@ -37,7 +37,7 @@ export_env_dir() { fi } -export_env_dir "$ENV_DIR" '^DDTRACE_EXT_' +export_env_dir "$ENV_DIR" '^DDTRACE_EXT|DD_' topic "Preparing to install Datadog PHP extensions" From 7be41d52ddfb0347e4445e2f30c8908dccc82d4b Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Tue, 30 May 2023 09:55:53 +0200 Subject: [PATCH 06/13] check if cache is valid --- bin/compile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/compile b/bin/compile index e2a7213..272a224 100755 --- a/bin/compile +++ b/bin/compile @@ -68,6 +68,10 @@ topic "Downloading package from $DDTRACE_EXT_PKG_URL" if [[ -f ${PACKAGE_FILE} ]]; then echo "Found cached file at "$PACKAGE_FILE | indent + if ! gzip -t ${PACKAGE_FILE} 2>&1 | indent ; then + echo "cache is invalid, downloading ..." | indent + curl --silent --show-error --fail --location --output $PACKAGE_FILE $DDTRACE_EXT_PKG_URL 2>&1 | indent + fi else curl --silent --show-error --fail --location --output $PACKAGE_FILE $DDTRACE_EXT_PKG_URL 2>&1 | indent fi From 57d6569cd85839f3ef304945c794d0f9690f3ac5 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Tue, 30 May 2023 12:03:40 +0200 Subject: [PATCH 07/13] fix readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a3ac29b..73588a7 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This buildpack accepts several config vars. All of them are optional: - `DDTRACE_EXT_PHP_API` - The PHP API version that your application uses. Defaults to `20210902`. Use `phpinfo()` to find the API version if you're not sure. - `DDTRACE_EXT_RELEASE` - The release name of [dd-trace-php](https://github.com/DataDog/dd-trace-php/releases/) to download. Defaults to `0.82.0`. -- `DDTRACE_EXT_PKG_URL` - The URL to a dd-trace-php `.deb` file. This option overides `DDTRACE_EXT_RELEASE`. +- `DDTRACE_EXT_PKG_URL` - The URL to a dd-trace-php `.tar.gz` file. This option overides `DDTRACE_EXT_RELEASE`. - `DD_PROFILING_ENABLED` - This will enable the profiling extension. ### More information: `DDTRACE_EXT_PHP_API` From 8581d3bb1a365b9b8372fc2bd71a724516c00aba Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Tue, 30 May 2023 12:32:10 +0200 Subject: [PATCH 08/13] Use `datadog-setup.php` for installing the Datadog PHP extensions --- README.md | 25 ++++--------------- bin/compile | 69 +++++++++++++++++++---------------------------------- 2 files changed, 29 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 73588a7..f41bec7 100644 --- a/README.md +++ b/README.md @@ -18,24 +18,7 @@ heroku buildpacks:add --app https://github.com/SpeedCurve-Metric This buildpack accepts several config vars. All of them are optional: -- `DDTRACE_EXT_PHP_API` - The PHP API version that your application uses. Defaults to `20210902`. Use `phpinfo()` to find the API version if you're not sure. -- `DDTRACE_EXT_RELEASE` - The release name of [dd-trace-php](https://github.com/DataDog/dd-trace-php/releases/) to download. Defaults to `0.82.0`. -- `DDTRACE_EXT_PKG_URL` - The URL to a dd-trace-php `.tar.gz` file. This option overides `DDTRACE_EXT_RELEASE`. -- `DD_PROFILING_ENABLED` - This will enable the profiling extension. - -### More information: `DDTRACE_EXT_PHP_API` - -This buildpack does not determine that PHP API version automatically. The default value should work for most PHP versions, but if the version is wrong then you will see warnings like this in your application logs: - -``` -PHP Warning: PHP Startup: ddtrace: Unable to initialize module -Module compiled with module API=20210902 -PHP compiled with module API=20220829 -These options need to match -``` - -You can change the version by setting the `DDTRACE_EXT_VERSION` config var in Heroku. For example: - -``` -heroku config:set --app DDTRACE_EXT_VERSION=20220829 -``` +- `DD_RELEASE` - The release name of [dd-trace-php](https://github.com/DataDog/dd-trace-php/releases/) to download. Defaults to `0.87.2`. +- `DD_INSTALLER_URL` - The URL to the `datadog-setup.php` to be used (to be found on the [dd-trace-php release page](https://github.com/DataDog/dd-trace-php/releases/)). +- `DD_PROFILING_ENABLED` - Set to a non empty value, this will install and enable the profiling extension. +- `DD_APPSEC_ENABLED` - Set to a non empty value, this will install and enable the appsec extension. diff --git a/bin/compile b/bin/compile index 272a224..7c84a9c 100755 --- a/bin/compile +++ b/bin/compile @@ -37,70 +37,51 @@ export_env_dir() { fi } -export_env_dir "$ENV_DIR" '^DDTRACE_EXT|DD_' +export_env_dir "$ENV_DIR" '^DD_' topic "Preparing to install Datadog PHP extensions" -if [[ -n ${DDTRACE_EXT_PKG_URL:-} ]]; then - echo "Using package URL '$DDTRACE_EXT_PKG_URL' (from "'$DDTRACE_EXT_PKG_URL env var).' | indent +if [[ -n ${DD_INSTALLER_URL:-} ]]; then + echo "Using package URL '$DD_INSTALLER_URL' (from "'$DD_INSTALLER_URL env var).' | indent else - if [[ -n ${DDTRACE_EXT_RELEASE:-} ]]; then - echo "Using dd-trace-php release '$DDTRACE_EXT_RELEASE' (from "'$DDTRACE_EXT_RELEASE env var).' | indent + if [[ -n ${DD_RELEASE:-} ]]; then + echo "Using dd-trace-php release '$DD_RELEASE' (from "'$DD_RELEASE env var).' | indent else - export DDTRACE_EXT_RELEASE="0.87.2" - echo "Using dd-trace-php release '$DDTRACE_EXT_RELEASE' (default value)." | indent + export DD_RELEASE="0.87.2" + echo "Using dd-trace-php release '$DD_RELEASE' (default value)." | indent fi - export DDTRACE_EXT_PKG_URL="https://github.com/DataDog/dd-trace-php/releases/download/"$DDTRACE_EXT_RELEASE"/dd-library-php-"$DDTRACE_EXT_RELEASE"-x86_64-linux-gnu.tar.gz" + export DD_INSTALLER_URL="https://github.com/DataDog/dd-trace-php/releases/download/"$DD_RELEASE"/datadog-setup.php" fi -if [[ "$DDTRACE_EXT_PKG_URL" != *tar.gz ]] +if [[ "$DD_INSTALLER_URL" != *datadog-setup.php ]] then - echo "The package URL is out of date. Please note to use the 'dd-library-php-*-x86_64-linux-gnu.tar.gz' files from the releases at https://github.com/DataDog/dd-trace-php/releases" | indent + echo "The package URL is out of date. Please note to use the 'datadog-setup.php' file URL from the releases at https://github.com/DataDog/dd-trace-php/releases" | indent exit 1 fi -mkdir -p $CACHE_DIR +topic "Downloading installer from $DD_INSTALLER_URL" +curl --silent --show-error --fail --location --output datadog-setup.php $DD_INSTALLER_URL 2>&1 | indent -PACKAGE_NAME="dd-library-php-"$DDTRACE_EXT_RELEASE -PACKAGE_FILE=$CACHE_DIR/$PACKAGE_NAME.tar.gz +mkdir -p $BUILD_DIR/opt -topic "Downloading package from $DDTRACE_EXT_PKG_URL" -if [[ -f ${PACKAGE_FILE} ]]; -then - echo "Found cached file at "$PACKAGE_FILE | indent - if ! gzip -t ${PACKAGE_FILE} 2>&1 | indent ; then - echo "cache is invalid, downloading ..." | indent - curl --silent --show-error --fail --location --output $PACKAGE_FILE $DDTRACE_EXT_PKG_URL 2>&1 | indent - fi -else - curl --silent --show-error --fail --location --output $PACKAGE_FILE $DDTRACE_EXT_PKG_URL 2>&1 | indent -fi +topic "Running Datadog installer" -mkdir -p $BUILD_DIR/.apt/opt +OPTS="" -topic "Installing Datadog PHP extensions" -tar -zxvf $PACKAGE_FILE --directory=$BUILD_DIR/.apt/opt 2>&1 | indent - -topic "Enabling Datadog PHP extensions" +if [[ -n ${DD_PROFILING_ENABLED:-} ]]; +then + OPTS+=" --enable-profiling" +fi -if [[ -n ${DDTRACE_EXT_PHP_API:-} ]]; then - echo "Using version '$DDTRACE_EXT_PHP_API' (from "'$DDTRACE_EXT_PHP_API env var).' | indent -else - export DDTRACE_EXT_PHP_API="20210902" - echo "Using version '$DDTRACE_EXT_PHP_API' (default value)." | indent +if [[ -n ${DD_APPSEC_ENABLED:-} ]]; +then + OPTS+=" --enable-appsec" fi -INI_FILE=/app/.heroku/php/etc/php/conf.d/datadog-php-custom.ini +env -u PHP_INI_SCAN_DIR php datadog-setup.php --php-bin=all --install-dir=$BUILD_DIR/opt $OPTS 2>&1 | indent -touch $INI_FILE -echo "[PHP]" >> $INI_FILE -echo "extension=/app/.apt/opt/dd-library-php/trace/ext/$DDTRACE_EXT_PHP_API/ddtrace.so" >> $INI_FILE -echo "ddtrace.request_init_hook=/app/.apt/opt/dd-library-php/trace/bridge/dd_wrap_autoloader.php" >> $INI_FILE +topic "Validating installation" -if [[ -n ${DD_PROFILING_ENABLED:-} ]]; -then - echo "Enabling the profiler" | indent - echo "extension=/app/.apt/opt/dd-library-php/profiling/ext/$DDTRACE_EXT_PHP_API/datadog-profiling.so" >> $INI_FILE -fi +env -u PHP_INI_SCAN_DIR php -v 2>&1 | indent echo "Done" | indent From 553ecd2fd341f65b33e23496945d844b7b04cc51 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Tue, 30 May 2023 12:58:58 +0200 Subject: [PATCH 09/13] add some debug output --- bin/compile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/compile b/bin/compile index 7c84a9c..0f20820 100755 --- a/bin/compile +++ b/bin/compile @@ -71,11 +71,13 @@ OPTS="" if [[ -n ${DD_PROFILING_ENABLED:-} ]]; then OPTS+=" --enable-profiling" + echo "Profiling will be enabled" | indent fi if [[ -n ${DD_APPSEC_ENABLED:-} ]]; then OPTS+=" --enable-appsec" + echo "Appsec will be enabled" | indent fi env -u PHP_INI_SCAN_DIR php datadog-setup.php --php-bin=all --install-dir=$BUILD_DIR/opt $OPTS 2>&1 | indent From 5447fbdb4605c90ae5323f7145804da855467d0b Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Tue, 30 May 2023 13:10:41 +0200 Subject: [PATCH 10/13] small cleanup --- bin/compile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/compile b/bin/compile index 0f20820..332c707 100755 --- a/bin/compile +++ b/bin/compile @@ -55,15 +55,12 @@ fi if [[ "$DD_INSTALLER_URL" != *datadog-setup.php ]] then - echo "The package URL is out of date. Please note to use the 'datadog-setup.php' file URL from the releases at https://github.com/DataDog/dd-trace-php/releases" | indent - exit 1 + error "The package URL is out of date. Please use the 'datadog-setup.php' file URL from the releases at https://github.com/DataDog/dd-trace-php/releases" fi topic "Downloading installer from $DD_INSTALLER_URL" curl --silent --show-error --fail --location --output datadog-setup.php $DD_INSTALLER_URL 2>&1 | indent -mkdir -p $BUILD_DIR/opt - topic "Running Datadog installer" OPTS="" @@ -80,6 +77,8 @@ then echo "Appsec will be enabled" | indent fi +mkdir -p $BUILD_DIR/opt + env -u PHP_INI_SCAN_DIR php datadog-setup.php --php-bin=all --install-dir=$BUILD_DIR/opt $OPTS 2>&1 | indent topic "Validating installation" From 6a77709b06512681f9efe283a0726aeb7d20092e Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Tue, 30 May 2023 14:12:07 +0200 Subject: [PATCH 11/13] make sure user know about the updates --- bin/compile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bin/compile b/bin/compile index 332c707..ea546d9 100755 --- a/bin/compile +++ b/bin/compile @@ -41,6 +41,20 @@ export_env_dir "$ENV_DIR" '^DD_' topic "Preparing to install Datadog PHP extensions" +# Warn folks about +if [[ -n ${DDTRACE_EXT_PKG_URL:-} ]]; then + error "The environment variable \$DDTRACE_EXT_PKG_URL has been renamed to \$DD_INSTALLER_URL and it needs to be a URL to the desired 'datadog-setup.php' to be found at https://github.com/DataDog/dd-trace-php/releases" +fi + +if [[ -n ${DDTRACE_EXT_RELEASE:-} ]]; then + echo "The environment variable \$DDTRACE_EXT_RELEASE got renamed to \$DD_RELEASE, rewriting it for now, please update your environment variable." | indent + DD_RELEASE=$DDTRACE_EXT_RELEASE +fi + +if [[ -n ${DDTRACE_EXT_PHP_API} ]]; then + echo "The environment variable \$DDTRACE_EXT_PHP_API is superfluous and will be ignored, feel free to remove it." | indent +fi + if [[ -n ${DD_INSTALLER_URL:-} ]]; then echo "Using package URL '$DD_INSTALLER_URL' (from "'$DD_INSTALLER_URL env var).' | indent else From 047d935c92a0a2b4c910b0f8d3e664c621454f6a Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Wed, 31 May 2023 11:04:10 +0200 Subject: [PATCH 12/13] make PHP dependency explicit --- README.md | 3 +++ bin/compile | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index f41bec7..e0c381e 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ To add this buildpack to your project, run the following: heroku buildpacks:add --app https://github.com/SpeedCurve-Metrics/heroku-buildpack-php-ddtrace.git ``` +Make sure to add this buildpack after the PHP buildpack, as a PHP binary is +needed to run the installer. + ## Configuration This buildpack accepts several config vars. All of them are optional: diff --git a/bin/compile b/bin/compile index ea546d9..be24247 100755 --- a/bin/compile +++ b/bin/compile @@ -41,6 +41,10 @@ export_env_dir "$ENV_DIR" '^DD_' topic "Preparing to install Datadog PHP extensions" +if ! which php >/dev/null; then + error "PHP is not installed. Please add a PHP buildpack to your app before adding this buildpack." +fi + # Warn folks about if [[ -n ${DDTRACE_EXT_PKG_URL:-} ]]; then error "The environment variable \$DDTRACE_EXT_PKG_URL has been renamed to \$DD_INSTALLER_URL and it needs to be a URL to the desired 'datadog-setup.php' to be found at https://github.com/DataDog/dd-trace-php/releases" From 5cfdb4087348285956a79671195e7ccfb66b5cfb Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Thu, 8 Jun 2023 20:31:51 +0200 Subject: [PATCH 13/13] add missing DDTRACE env variables --- bin/compile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index be24247..eb4b626 100755 --- a/bin/compile +++ b/bin/compile @@ -37,7 +37,7 @@ export_env_dir() { fi } -export_env_dir "$ENV_DIR" '^DD_' +export_env_dir "$ENV_DIR" '^DD_|DDTRACE_' topic "Preparing to install Datadog PHP extensions"