Skip to content

Commit

Permalink
Add recipe for New Relic
Browse files Browse the repository at this point in the history
Fixes ddev#102
  • Loading branch information
mglaman committed Dec 2, 2020
1 parent 1393218 commit 7b4c4be
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docker-compose-services/newrelic/README.md
Original file line number Diff line number Diff line change
@@ -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.
19 changes: 19 additions & 0 deletions docker-compose-services/newrelic/docker-compose.newrelic.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions docker-compose-services/newrelic/php/newrelic-ddev.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
newrelic.distributed_tracing_enabled=true
newrelic.daemon.address="newrelic:31339"
20 changes: 20 additions & 0 deletions docker-compose-services/newrelic/web-build/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7b4c4be

Please sign in to comment.