@@ -3,19 +3,22 @@ FROM php:8.1-alpine3.19
33LABEL maintainer="Andrea Falco <andrea@falco.sh>"
44
55# PHP ext-newrelic
6- ARG PHPEXT_NEWRELIC_VERSION=10.21.0.11
76RUN set -eux; \
8- curl -fsSL https://download.newrelic.com/php_agent/release/newrelic-php5-${PHPEXT_NEWRELIC_VERSION}-linux-musl.tar.gz \
7+ # Discover the latest released version:
8+ export NEW_RELIC_AGENT_VERSION=$(curl -fsSL https://download.newrelic.com/php_agent/release/ | grep -o '[1-9][0-9]\?\(\. [0-9]\+\)\{ 3\} ' | head -n1); \
9+ # Discover libc provider
10+ export NR_INSTALL_PLATFORM=$(ldd --version 2>&1 | grep -q musl && echo "linux-musl" || echo "linux" ); \
11+ \
12+ # Download the discovered version:
13+ curl -fsSL https://download.newrelic.com/php_agent/release/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-${NR_INSTALL_PLATFORM}.tar.gz \
914 | tar -xzC /tmp; \
10- export NR_INSTALL_USE_CP_NOT_LN=1; \
11- /tmp/newrelic-php5-*/newrelic-install install; \
15+ # Install the downloaded agent:
16+ NR_INSTALL_USE_CP_NOT_LN=1 NR_INSTALL_SILENT=0 /tmp/newrelic-php5-*/newrelic-install install; \
1217 \
13- sed -i \
14- -e 's/"REPLACE_WITH_REAL_KEY"/"YOUR_LICENSE_KEY"/' \
15- -e 's/newrelic.appname = "PHP Application"/newrelic.appname = "YOUR_APPLICATION_NAME"/' \
16- -e 's/;newrelic.daemon.app_connect_timeout =.*/newrelic.daemon.app_connect_timeout=15s/' \
17- -e 's/;newrelic.daemon.start_timeout =.*/newrelic.daemon.start_timeout=5s/' \
18- /usr/local/etc/php/conf.d/newrelic.ini \
19- ; \
18+ # Configure the agent to use license key from NEW_RELIC_LICENSE_KEY env var:
19+ sed -ie 's/[ ;]*newrelic.license[[:space:]]=.*/newrelic.license=${NEW_RELIC_LICENSE_KEY}/' $(php-config --ini-dir)/newrelic.ini; \
20+ # Configure the agent to use app name from NEW_RELIC_APP_NAME env var:
21+ sed -ie 's/[ ;]*newrelic.appname[[:space:]]=.*/newrelic.appname=${NEW_RELIC_APP_NAME}/' $(php-config --ini-dir)/newrelic.ini; \
2022 \
23+ # Cleanup temporary files:
2124 rm -rf /tmp/* /var/tmp/*
0 commit comments