Skip to content

Instantly share code, notes, and snippets.

@devils-ey3
Forked from aramalipoor/Dockerfile
Created March 9, 2020 20:09
Show Gist options
  • Save devils-ey3/9544b23e1c8c54833e7353a861862045 to your computer and use it in GitHub Desktop.
Save devils-ey3/9544b23e1c8c54833e7353a861862045 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment