diff --git a/docker-compose-services/newrelic/README.md b/docker-compose-services/newrelic/README.md new file mode 100644 index 00000000..2c674539 --- /dev/null +++ b/docker-compose-services/newrelic/README.md @@ -0,0 +1,12 @@ +# New Relic + +This recipe adds a New Relic daemon service and PHP agent to the `web` container. + +Once configured it will begin reporting data to New Relic. Your DDEV project name will be the app name reported in your New Relic APM list. + +## Configuration + +There are two configuration items in `docker-compose.newrelic.yaml`. + +* `NEW_RELIC_LICENSE_KEY`: You must specify your license key. +* `NEW_RELIC_AGENT_VERSION`: Specify the New Relic agent version. diff --git a/docker-compose-services/newrelic/docker-compose.newrelic.yaml b/docker-compose-services/newrelic/docker-compose.newrelic.yaml new file mode 100644 index 00000000..e3e7090f --- /dev/null +++ b/docker-compose-services/newrelic/docker-compose.newrelic.yaml @@ -0,0 +1,19 @@ +--- +# Adds New Relic support for performance profiling. +version: '3.6' +services: + newrelic: + image: newrelic/php-daemon + container_name: ddev-${DDEV_SITENAME}-newrelic + ports: ['31339'] + labels: + com.ddev.site-name: ${DDEV_SITENAME} + com.ddev.approot: $DDEV_APPROOT + + web: + build: + args: + NEW_RELIC_AGENT_VERSION: "9.2.0.247" + NEW_RELIC_LICENSE_KEY: "" + links: + - newrelic diff --git a/docker-compose-services/newrelic/php/newrelic-ddev.ini b/docker-compose-services/newrelic/php/newrelic-ddev.ini new file mode 100644 index 00000000..0226a748 --- /dev/null +++ b/docker-compose-services/newrelic/php/newrelic-ddev.ini @@ -0,0 +1,2 @@ +newrelic.distributed_tracing_enabled=true +newrelic.daemon.address="newrelic:31339" diff --git a/docker-compose-services/newrelic/web-build/Dockerfile b/docker-compose-services/newrelic/web-build/Dockerfile new file mode 100644 index 00000000..17a75664 --- /dev/null +++ b/docker-compose-services/newrelic/web-build/Dockerfile @@ -0,0 +1,20 @@ +ARG BASE_IMAGE +FROM $BASE_IMAGE + +# Install New Relic +# @see https://docs.newrelic.com/docs/agents/php-agent/advanced-installation/docker-other-container-environments-install-php-agent +ARG NEW_RELIC_AGENT_VERSION +ARG NEW_RELIC_LICENSE_KEY + +RUN curl -L https://download.newrelic.com/php_agent/archive/${NEW_RELIC_AGENT_VERSION}/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-linux.tar.gz | tar -C /tmp -zx \ + && export NR_INSTALL_USE_CP_NOT_LN=1 \ + && export NR_INSTALL_SILENT=1 \ + && /tmp/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-linux/newrelic-install install \ + && rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* + +RUN sed -i -e "s/REPLACE_WITH_REAL_KEY/${NEW_RELIC_LICENSE_KEY}/" \ + -e "s/newrelic.appname[[:space:]]=[[:space:]].*/newrelic.appname=\"${NEW_RELIC_APPNAME}\"/" \ + /etc/php/${PHP_DEFAULT_VERSION}/fpm/conf.d/newrelic.ini +RUN sed -i -e "s/REPLACE_WITH_REAL_KEY/${NEW_RELIC_LICENSE_KEY}/" \ + -e "s/newrelic.appname[[:space:]]=[[:space:]].*/newrelic.appname=\"${NEW_RELIC_APPNAME}\"/" \ + /etc/php/${PHP_DEFAULT_VERSION}/cli/conf.d/newrelic.ini