Skip to content

Instantly share code, notes, and snippets.

@aramalipoor
Last active November 23, 2023 14:05
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save aramalipoor/a981ebfd94a5920df4b958d8a6b9ad70 to your computer and use it in GitHub Desktop.
Save aramalipoor/a981ebfd94a5920df4b958d8a6b9ad70 to your computer and use it in GitHub Desktop.
Docker + Alpine + Newrelic + PHP (Kubernetes / AbarCloud)
# Prepare required directories for Newrelic installation
RUN mkdir -p /var/log/newrelic /var/run/newrelic && \
touch /var/log/newrelic/php_agent.log /var/log/newrelic/newrelic-daemon.log && \
chmod -R g+ws /tmp /var/log/newrelic/ /var/run/newrelic/ && \
chown -R 1001:0 /tmp /var/log/newrelic/ /var/run/newrelic/ && \
# Download and install Newrelic binary
export NEWRELIC_VERSION=$(curl -sS https://download.newrelic.com/php_agent/release/ | sed -n 's/.*>\(.*linux-musl\).tar.gz<.*/\1/p') && \
cd /tmp && curl -sS "https://download.newrelic.com/php_agent/release/${NEWRELIC_VERSION}.tar.gz" | gzip -dc | tar xf - && \
cd "${NEWRELIC_VERSION}" && \
NR_INSTALL_SILENT=true ./newrelic-install install && \
rm -f /var/run/newrelic-daemon.pid && \
rm -f /tmp/.newrelic.sock && \
# For Newrelic's APM (Application Monitoring) license and appname are required.
# Enviroment variables `NEW_RELIC_LICENSE_KEY` and `NEW_RELIC_APP_NAME` are required when buidling Docker image,
# so you must set them in your **BuildConfig** Environments.
sed -i \
-e "s/newrelic.license =.*/newrelic.license = ${NEW_RELIC_LICENSE_KEY}/" \
-e "s/newrelic.appname =.*/newrelic.appname = ${NEW_RELIC_APP_NAME}/" \
/etc/php7/conf.d/newrelic.ini
@antonxo
Copy link

antonxo commented Aug 25, 2021

Really helped me to realize I needed the "linux-musl" release. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment