Skip to content

Commit 91d4b54

Browse files
author
Bryan Latten
committed
Merge pull request #54 from bryanlatten/newrelic-integration
Dockerfile: supporting newrelic
2 parents 9be5983 + 3a929af commit 91d4b54

File tree

7 files changed

+40
-12
lines changed

7 files changed

+40
-12
lines changed

Dockerfile

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
FROM behance/docker-nginx:1.1.1
22
MAINTAINER Bryan Latten <latten@adobe.com>
33

4-
# Install singularity_runner
5-
RUN apt-get install build-essential ruby1.9.1-dev -y && \
6-
gem install --no-rdoc --no-ri singularity_dsl --version 1.6.3
4+
# Install pre-reqs for the next steps
5+
RUN apt-get update && apt-get -yq install \
6+
build-essential \
7+
wget
78

9+
# Ensure additional software sources are configured, and prevents newrelic install from prompting for input
810
RUN locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8 && \
911
add-apt-repository ppa:git-core/ppa -y && \
1012
add-apt-repository ppa:ondrej/php5-5.6 -y && \
11-
apt-get update -yq && \
12-
apt-get install -yq git
13+
echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | sudo tee /etc/apt/sources.list.d/newrelic.list && \
14+
wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add - && \
15+
echo newrelic-php5 newrelic-php5/application-name string "REPLACE_NEWRELIC_APP" | debconf-set-selections && \
16+
echo newrelic-php5 newrelic-php5/license-key string "REPLACE_NEWRELIC_LICENSE" | debconf-set-selections;
1317

1418
# Update package cache with new PPA, install language and modules
1519
RUN apt-get update && \
@@ -27,17 +31,25 @@ RUN apt-get update && \
2731
php5-mcrypt \
2832
php5-json \
2933
php5-xdebug \
30-
nano && \
31-
php5dismod xdebug
32-
34+
newrelic-php5 \
35+
nano \
36+
wget \
37+
git \
38+
&& \
39+
php5dismod xdebug && \
40+
php5dismod newrelic
41+
42+
# Build/install any extensions that aren't in trouble-free packaging
3343
RUN pecl install igbinary-1.2.1 && \
3444
echo 'extension=igbinary.so' > /etc/php5/mods-available/igbinary.ini && \
35-
php5enmod igbinary
36-
37-
RUN printf "\n" | pecl install apcu-4.0.7 && \
45+
php5enmod igbinary && \
46+
printf "\n" | pecl install apcu-4.0.7 && \
3847
echo 'extension=apcu.so' > /etc/php5/mods-available/apcu.ini && \
3948
php5enmod apcu
4049

50+
# Prevent newrelic daemon from auto-spawning; uses newrelic run.d script to enable at runtime, when ENV variables are present
51+
# @see https://docs.newrelic.com/docs/agents/php-agent/advanced-installation/starting-php-daemon-advanced
52+
RUN sed -i "s/;newrelic.daemon.dont_launch = 0/newrelic.daemon.dont_launch = 3/" /etc/php5/mods-available/newrelic.ini
4153

4254
# Perform cleanup, ensure unnecessary packages are removed
4355
RUN apt-get autoclean -y && \

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ Variable | Example | Description
3535
--- | --- | ---
3636
`CFG_*` | `CFG_DATABASE_USERNAME=root` | Ingested into `/etc/php5/fpm/pool.d/www.conf` for PHP to access as an environment variable
3737
`CFG_APP_DEBUG` | `CFG_APP_DEBUG=1` | Setting to `1` or `true` will cue the Opcache to watch for file changes as well as increase Nginx's default buffer sizes, suitable for Development Mode. Otherwise, headers are normal and the Opcache check is skipped for a performance boost.
38-
`SERVER_MAX_BODY_SIZE` | `SERVER_MAX_BODY_SIZE=4M` | Allows the downstream application to specify a non-default `client_max_body_size` configuration for the `server`-level directive in `/etc/nginx/sites-available/default`
38+
`SERVER_MAX_BODY_SIZE` | `SERVER_MAX_BODY_SIZE=4M` | Allows the downstream application to specify a non-default `client_max_body_size` configuration for the `server`-level directive in `/etc/nginx/sites-available/default`
39+
`REPLACE_NEWRELIC_APP` | `REPLACE_NEWRELIC_APP=prod-server-abc` | Sets application name for newrelic
40+
`REPLACE_NEWRELIC_LICENSE` | `REPLACE_NEWRELIC_LICENSE=abcdefg` | Sets license for newrelic, when combined with above, will enable newrelic reporting
3941

container/root/run.d/01-install.sh

100644100755
File mode changed.

container/root/run.d/02-env.sh

100644100755
File mode changed.

container/root/run.d/03-debug.sh

100644100755
File mode changed.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
NEWRELIC_CONF=/etc/php5/mods-available/newrelic.ini
4+
5+
if [[ $REPLACE_NEWRELIC_APP && $REPLACE_NEWRELIC_LICENSE ]]
6+
then
7+
echo "[newrelic] enabling APM metrics for ${REPLACE_NEWRELIC_APP}"
8+
sed -i "s/newrelic.appname = \"REPLACE_NEWRELIC_APP\"/newrelic.appname = \"${REPLACE_NEWRELIC_APP}\"/" $NEWRELIC_CONF
9+
sed -i "s/newrelic.license = \"REPLACE_NEWRELIC_LICENSE\"/newrelic.license = \"${REPLACE_NEWRELIC_LICENSE}\"/" $NEWRELIC_CONF
10+
11+
# IMPORTANT: change auto-launch parameter BACK from what was set in the Dockerfile
12+
sed -i "s/newrelic.daemon.dont_launch = 3/newrelic.daemon.dont_launch = 0/" $NEWRELIC_CONF
13+
php5enmod newrelic
14+
fi

container/root/run.d/99-phpfpm.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)