diff --git a/php/8.5/Dockerfile b/php/8.5/Dockerfile index c389558..f391691 100644 --- a/php/8.5/Dockerfile +++ b/php/8.5/Dockerfile @@ -121,14 +121,14 @@ ln -s /usr/local/etc/misc/msmtprc /etc/msmtprc && \ chown www-data:www-data /usr/local/etc/misc/msmtprc && \ chown www-data:www-data /etc/msmtprc -#RUN latest_build=$(curl -s https://download.newrelic.com/php_agent/release/ | grep 'linux\.tar\.gz"' | head -n 1 | sed 's/.*"\(.*\)".*/\1/') && \ -#curl -L "https://download.newrelic.com$latest_build" | tar -C /tmp -zx && \ -#export NR_INSTALL_USE_CP_NOT_LN=1 && \ -#export NR_INSTALL_SILENT=1 && \ -#/tmp/newrelic-php5-*/newrelic-install install && \ -#rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* -# -#ENV NR_PORT=/run/newrelic/newrelic.sock +RUN latest_build=$(curl -s https://download.newrelic.com/php_agent/release/ | grep 'linux\.tar\.gz"' | head -n 1 | sed 's/.*"\(.*\)".*/\1/') && \ +curl -L "https://download.newrelic.com$latest_build" | tar -C /tmp -zx && \ +export NR_INSTALL_USE_CP_NOT_LN=1 && \ +export NR_INSTALL_SILENT=1 && \ +/tmp/newrelic-php5-*/newrelic-install install && \ +rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* + +ENV NR_PORT=/run/newrelic/newrelic.sock # Setup logs RUN mkdir -p /var/log/php; \ @@ -141,8 +141,8 @@ COPY expose_off.ini /usr/local/etc/php/conf.d/expose_off.ini COPY bashrc /root/.bashrc COPY bashrc /var/www/.bashrc COPY docker-entrypoint.sh /usr/local/bin/ -#COPY newrelic.ini /usr/local/etc/php/conf.d/newrelic.ini -#COPY newrelic.ini /data/newrelic.ini +COPY newrelic.ini /usr/local/etc/php/conf.d/newrelic.ini +COPY newrelic.ini /data/newrelic.ini WORKDIR /var/www/htdocs RUN usermod -s /bin/bash www-data diff --git a/php/8.5/docker-entrypoint.sh b/php/8.5/docker-entrypoint.sh index fc68270..7e0ca41 100755 --- a/php/8.5/docker-entrypoint.sh +++ b/php/8.5/docker-entrypoint.sh @@ -1,12 +1,19 @@ #!/bin/bash set -euo pipefail -o nounset -#if [[ -z "${NEWRELIC_LICENSE_KEY:-}" ]] || [[ -z "${NEWRELIC_APPNAME:-}" ]]; then -# : -#else -# sed -i -e "s/\"REPLACE_WITH_REAL_KEY\"/\"$NEWRELIC_LICENSE_KEY\"/" \ -# -e "s/newrelic.appname = \"PHP Application\"/newrelic.appname = \"$NEWRELIC_APPNAME\"/" \ -# /usr/local/etc/php/conf.d/newrelic.ini -#fi +nr_ini=/usr/local/etc/php/conf.d/newrelic.ini +if [[ -z "${NEWRELIC_LICENSE_KEY:-}" ]] || [[ -z "${NEWRELIC_APPNAME:-}" ]]; then + : +else + # A site config made from a php-fpm zip (ee site update --php) has no newrelic.ini: start from the image's copy instead of failing. + if [[ ! -f "$nr_ini" ]] && ! cp /data/newrelic.ini "$nr_ini"; then + echo "docker-entrypoint: could not create $nr_ini, New Relic stays off" >&2 + fi + if [[ -f "$nr_ini" ]]; then + sed -i -e "s/\"REPLACE_WITH_REAL_KEY\"/\"$NEWRELIC_LICENSE_KEY\"/" \ + -e "s/newrelic.appname = \"PHP Application\"/newrelic.appname = \"$NEWRELIC_APPNAME\"/" \ + "$nr_ini" || echo "docker-entrypoint: could not write the New Relic license to $nr_ini" >&2 + fi +fi exec "$@" diff --git a/php/8.5/expected-modules.txt b/php/8.5/expected-modules.txt index c3a3421..38489e5 100644 --- a/php/8.5/expected-modules.txt +++ b/php/8.5/expected-modules.txt @@ -24,6 +24,7 @@ mcrypt memcached mysqli mysqlnd +newrelic openssl pcntl pcre