Skip to content

Instantly share code, notes, and snippets.

@abenevaut
Last active October 11, 2024 15:53
Show Gist options
  • Save abenevaut/ef5b61cc9cc4b76e0f1240d5e73251c8 to your computer and use it in GitHub Desktop.
Save abenevaut/ef5b61cc9cc4b76e0f1240d5e73251c8 to your computer and use it in GitHub Desktop.
Vapor Dockerfile with newrelic
FROM laravelphp/vapor:php81
# Download and install newrelic: https://download.newrelic.com/php_agent/release/
RUN \
curl -L "https://download.newrelic.com/php_agent/release/newrelic-php5-10.0.0.312-linux-musl.tar.gz" | tar -C /tmp -zx && \
export NR_INSTALL_USE_CP_NOT_LN=1 && \
export NR_INSTALL_SILENT=1 && \
/tmp/newrelic-php5-*/newrelic-install install
# Add global var to php.ini file
RUN echo 'extension = "newrelic.so"' >> /usr/local/etc/php/php.ini
RUN echo 'newrelic.logfile = "/dev/null"' >> /usr/local/etc/php/php.ini
RUN echo 'newrelic.loglevel = "error"' >> /usr/local/etc/php/php.ini
RUN echo 'newrelic.appname = "auth-prod"' >> /usr/local/etc/php/php.ini
RUN echo 'newrelic.license = "<YOUR_LICENSE>"' >> /usr/local/etc/php/php.ini
# Remove newrelic.ini file
RUN rm /usr/local/etc/php/conf.d/newrelic.ini
RUN mkdir -p /usr/local/etc/newrelic
RUN echo "loglevel=error" > /usr/local/etc/newrelic/newrelic.cfg
RUN echo "logfile=/dev/null" >> /usr/local/etc/newrelic/newrelic.cfg
ADD entrypoint.sh /var/task/entrypoint.sh
COPY . /var/task
USER root
RUN chmod +x /var/task/entrypoint.sh
ENTRYPOINT ["/var/task/entrypoint.sh"]
#! /bin/sh
# Start Newrelic daemon
newrelic-daemon -c /usr/local/etc/newrelic/newrelic.cfg
# Start PHP
/opt/bootstrap
newrelic_background_job(false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment