Open NiklasBr opened 1 year ago
Even though the release notes and Docs say otherwise, the binaries are missing in the repository: https://apt.newrelic.com/debian/dists/newrelic/non-free/binary-arm64/
Hi and thank you for your feedback.
As mentioned in the compatibility page, New Relic PHP agent 10.10.0 or later provides support for ARM64 by including binaries in a tarball distribution.The ARM64 binaries are only provided in the tarballs.
Please see here for installation instructions: https://docs.newrelic.com/docs/apm/agents/php-agent/installation/php-agent-installation-arm64/#tarball-installation
What is the expectation when building multi-architecture containers with Docker? Impossible by design?
Hi @NiklasBr ,
Thanks for providing feedback about your usage case.
There's an example using the tarball in a dockerfile which would work on both x64 and arm64: https://docs.newrelic.com/docs/apm/agents/php-agent/advanced-installation/docker-other-container-environments-install-php-agent/#dockerfile-example
@zsistla I am unable to expand the accordion with the Dockerfile example in your link, the Firefox console gives the following error message:
Uncaught SyntaxError: '' literal not terminated before end of script app-4198df041846dc9f45e0.js:2:3931723
Update: I could manually inspect the source code and extract the contents. Is there a way to get the latest version every request rather than hardcoding the point release? Like for example using the URL https://imagemagick.org/archive/binaries/magick will download the latest version to build without the need to constantly check the site for udpates. Or like Composer does which allows either or.
Hi, apologies for that inconvenience. It seems you were able to extract the directions, but below are the details from the page:
To set up the PHP agent and daemon in the same Docker container:
Make sure a PHP installation is available in the container. For example: you might use a published Docker image like php:7.1. To install the agent, download the PHP agent package from New Relic's tar file download site and run the newrelic-install script with the install argument. Set the application name and license key via the newrelic.license and newrelic.appname entries in the newrelic.ini file.
Dockerfile example FROM php:7.1
RUN \ curl -L PHP_AGENT_URL | tar -C /tmp -zx && \ export NR_INSTALL_USE_CP_NOT_LN=1 && \ export NR_INSTALL_SILENT=1 && \ /tmp/newrelic-php5-/newrelic-install install && \ rm -rf /tmp/newrelic-php5- /tmp/nrinstall && \ sed -i \ -e 's/"REPLACE_WITH_REAL_KEY"/"YOUR_LICENSE_KEY"/' \ -e 's/newrelic.appname = "PHP Application"/newrelic.appname = "YOUR_APPLICATION_NAME"/' \ -e 's/;newrelic.daemon.app_connect_timeout =./newrelic.daemon.app_connect_timeout=15s/' \ -e 's/;newrelic.daemon.start_timeout =.*/newrelic.daemon.start_timeout=5s/' \ /usr/local/etc/php/conf.d/newrelic.ini
You must edit three parts of this example Dockerfile:
PHP_AGENT_URL: The download URL for your PHP agent version. To find the most recent version of the agent, go to download.newrelic.com/php_agent/release/. YOUR_LICENSE_KEY: Replace this with your license key. Note that "REPLACE_WITH_REAL_KEY" is an actual string in the default newrelic.ini file for the PHP agent. Don't edit that string. The sed command replaces that default string with the actual 40-character key, in quotes. YOUR_APPLICATION_NAME: Replace with the your application name, in quotes.
At the moment, to get the latest build without having to check/update the number requires something like:
NEWRELIC_FILE=$(curl -s https://download.newrelic.com/php_agent/release/ | grep -o ‘newrelic-php5-(\d+.)+-linux.tar.gz’ | head -n 1) || exit; \
curl -L https://download.newrelic.com/php_agent/release/${NEWRELIC_FILE} | tar -C /tmp -zx
Looked promising but could not get it to work:
NEWRELIC_FILE=$(curl -s https://download.newrelic.com/php_agent/release/ | grep -o ‘newrelic-php5-(\d+.)+-linux.tar.gz’ | head -n 1) || exit; \
curl -L https://download.newrelic.com/php_agent/release/${NEWRELIC_FILE} | tar -C /tmp -zx
zsh: no matches found: ‘newrelic-php5-(d+.)+-linux.tar.gz’
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1009 100 1009 0 0 11390 0 --:--:-- --:--:-- --:--:-- 11870
tar: Error opening archive: Unrecognized archive format
HI @NiklasBr ,
Probably missing some backslash in there.
The following works to get the AGENT_VERSION:
VERSION_REGEX='[1-9][0-9]\?\(\.[0-9]\+\)\{3\}'
RELEASE_URL='https://download.newrelic.com/php_agent/release/'
AGENT_VERSION="$(curl -s "$RELEASE_URL" | grep --only-match "$VERSION_REGEX" | head -n1)"
The following works to get the file:
NEWRELIC_FILE=$(curl 'https://download.newrelic.com/php_agent/release/' | grep -o 'newrelic-php5.*linux\.tar\.gz' | sed -e 's/^.*>//;s/<[^>]*>//g')
This is the complete recipe I used in case somebody is interested:
RUN cd /tmp \
&& VERSION_REGEX='[1-9][0-9]\?\(\.[0-9]\+\)\{3\}' \
&& NEWRELIC_FILE=$(curl 'https://download.newrelic.com/php_agent/release/' | grep -o 'newrelic-php5.*linux\.tar\.gz' | sed -e 's/^.*>//;s/<[^>]*>//g') \
&& NEWRELIC_FOLDER=$(echo ${NEWRELIC_FILE} | sed 's/.tar.gz//g') \
&& curl https://download.newrelic.com/php_agent/release/${NEWRELIC_FILE} | tar -zx \
&& cd ${NEWRELIC_FOLDER} \
&& export NR_INSTALL_USE_CP_NOT_LN=1 \
&& export NR_INSTALL_SILENT=1 \
&& ./newrelic-install install \
&& cd /tmp \
&& rm -rf ${NEWRELIC_FOLDER}
By the way, we got badly bit by https://github.com/newrelic/newrelic-php-agent/issues/399 when switching from the package-based installation to the tarball. We used to rely on the newrelic.ini
file in mods-available
but the install script will make two copies of the configuration file to the CLI and FPM conf.d
folders without respecting mods-available
.
We had to do this post installation to read from the mods-available config file, assuming you copied the file there:
rm /etc/php/8.1/fpm/conf.d/newrelic.ini /etc/php/8.1/cli/conf.d/newrelic.ini
&& ln -s /etc/php/8.1/mods-available/newrelic.ini /etc/php/8.1/fpm/conf.d/20-newrelic.ini
Side note, as it stands in the official configuration (-e 's/"REPLACE_WITH_REAL_KEY"/"YOUR_LICENSE_KEY"/'
), the license key will be included in the Docker image, which is a bad practice imo.
Thanks for your working recipe @AdrienPoupa!
Side note, as it stands in the official configuration (
-e 's/"REPLACE_WITH_REAL_KEY"/"YOUR_LICENSE_KEY"/'
), the license key will be included in the Docker image, which is a bad practice imo.
To mitigate this I suggest following modification to the working recipe shared here:
# Install the latest New Relic PHP Agent
RUN \
cd /tmp \
# Discover the latest released version:
&& export NEW_RELIC_AGENT_VERSION=$(curl -s https://download.newrelic.com/php_agent/release/ | grep --only-match '[1-9][0-9]\?\(\.[0-9]\+\)\{3\}' | head -n1) \
# Download the discovered version:
&& curl -o newrelic-php-agent.tar.gz https://download.newrelic.com/php_agent/release/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-linux.tar.gz \
# Install the downloaded agent:
&& tar xzf newrelic-php-agent.tar.gz \
&& NR_INSTALL_USE_CP_NOT_LN=1 NR_INSTALL_SILENT=0 ./*/newrelic-install install \
# Configure the agent to use license key from NEW_RELIC_LICENSE_KEY env var:
&& sed -ie 's/[ ;]*newrelic.license[[:space:]]=.*/newrelic.license=${NEW_RELIC_LICENSE_KEY}/' $(php-config --ini-dir)/newrelic.ini \
# Configure the agent to send telemetry to collector defined by NEW_RELIC_HOST env var:
&& sed -ie 's/[ ;]*newrelic.daemon.collector_host[[:space:]]=.*/newrelic.daemon.collector_host=${NEW_RELIC_HOST}/' $(php-config --ini-dir)/newrelic.ini \
# Configure the agent to use app name from NEW_RELIC_APP_NAME env var:
&& sed -ie 's/[ ;]*newrelic.appname[[:space:]]=.*/newrelic.appname=${NEW_RELIC_APP_NAME}/' $(php-config --ini-dir)/newrelic.ini \
# Cleanup temporary files:
&& rm newrelic-php-agent.tar.gz && rm -rf newrelic-php5-*-linux
This will cause the agent's configuration to use values for newrelic.appname
and newrelic.license
based on values of NEW_RELIC_LICENSE_KEY
and NEW_RELIC_APP_NAME
env vars provided at the time the container is started and not hardcoding them in the image.
Description
Attempting to install using a simple Docker image results in this error when building on ARM64 platforms even though the change log appears to say that support has been introduced:
Steps to Reproduce
Dockerfile:
Expected Behavior
Completed installation.
Relevant Logs / Console output
Your Environment
Additional context