Skip to content

Commit cf2be37

Browse files
author
David Ferlay
authored
Merge pull request #274 from skilld-labs/blackfire
Add profiles make tasks
2 parents 7a7df6a + c8f8036 commit cf2be37

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ networks:
118118
* `make lint` - Runs frontend linters.
119119
* `make storybook` - Runs storybook in current theme.
120120
* `make blackfire` - Adds and enables blackfire.io php extension, needs [configuration](https://blackfire.io/docs/configuration/php) in docker-composer override.yml.
121+
* `make newrelic` - Adds and enables newrelic.com php extension, needs [configuration](https://docs.newrelic.com/docs/agents/php-agent/getting-started/introduction-new-relic-php#configuration) in docker-composer.override.yml.
121122

122123
#### Additional goals
123124

docker/docker-compose.override.yml.default

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ services:
88
COMPOSER_MEMORY_LIMIT: "-1"
99
# BLACKFIRE_CLIENT_ID: x
1010
# BLACKFIRE_CLIENT_TOKEN: x
11+
# NEW_RELIC_LICENSE_KEY: x
12+
# NEW_RELIC_APPNAME: "${COMPOSE_PROJECT_NAME}"
1113
volumes:
1214
- "./90-mail.ini:/etc/php7/conf.d/90-mail.ini:z"
1315
# depends_on:
@@ -29,6 +31,12 @@ services:
2931
# networks:
3032
# - front
3133

34+
# newrelic:
35+
# image: newrelic/php-daemon
36+
# container_name: "${COMPOSE_PROJECT_NAME}_newrelic"
37+
# networks:
38+
# - front
39+
3240
# adminer:
3341
# image: dockette/adminer:mysql-php7
3442
# container_name: "${COMPOSE_PROJECT_NAME}_adminer"

scripts/makefile/blackfire.sh

100644100755
File mode changed.

scripts/makefile/newrelic.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env sh
2+
3+
# installs newrelic.com agent extension
4+
5+
# use `php -i | grep "additional .ini"` to get it
6+
PHP_INI_DIR=/etc/php7/conf.d
7+
8+
# get the latest version from https://download.newrelic.com/php_agent/archive/
9+
NEW_RELIC_AGENT_VERSION="${NEW_RELIC_AGENT_VERSION:-9.12.0.268}"
10+
# change it to 'linux' if docker image is not based on Alpinelinux
11+
NEW_RELIC_LINUX=${NEW_RELIC_LINUX:-linux-musl}
12+
13+
set -e
14+
15+
env_vars='NEW_RELIC_APPNAME NEW_RELIC_LICENSE_KEY'
16+
17+
for var in $env_vars; do
18+
eval "val=\${$var}"
19+
if [ -z "${val}" -o "${val}" = 'x' ]; then
20+
echo "Configure ${var} in docker-compose.override.yml"
21+
echo "Visit https://newrelic.com 'Account settings' to get the key"; exit 1;
22+
fi
23+
done
24+
25+
curl -L https://download.newrelic.com/php_agent/archive/${NEW_RELIC_AGENT_VERSION}/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-${NEW_RELIC_LINUX}.tar.gz | tar -C /tmp -zx \
26+
&& export NR_INSTALL_USE_CP_NOT_LN=1 \
27+
&& export NR_INSTALL_SILENT=1 \
28+
&& /tmp/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-${NEW_RELIC_LINUX}/newrelic-install install \
29+
&& rm -rf /tmp/newrelic-php5-* /tmp/nrinstall*
30+
31+
sed -i -e s/\"REPLACE_WITH_REAL_KEY\"/${NEW_RELIC_LICENSE_KEY}/ \
32+
-e s/newrelic.appname[[:space:]]=[[:space:]].\*/newrelic.appname="${NEW_RELIC_APPNAME}"/ \
33+
$PHP_INI_DIR/newrelic.ini
34+
# -e s/\;newrelic.daemon.address[[:space:]]=[[:space:]].\*/newrelic.daemon.address="${NEW_RELIC_DAEMON_ADDRESS}"/ \

scripts/makefile/tests.mk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,13 @@ else
197197
@echo "scripts/makefile/blackfire.sh file does not exist"
198198
@exit 1
199199
endif
200+
201+
newrelic:
202+
ifneq ("$(wildcard scripts/makefile/newrelic.sh)","")
203+
$(call php-0, /bin/sh ./scripts/makefile/newrelic.sh)
204+
$(call php-0, kill -USR2 1)
205+
@echo "NewRelic extension enabled"
206+
else
207+
@echo "scripts/makefile/newrelic.sh file does not exist"
208+
@exit 1
209+
endif

0 commit comments

Comments
 (0)