Installing php agent on docker linux alpine

Hello, i am installing agent for php on docker with alpine linux
The version of agent i use is the latest newrelic-php5-
The resulting error i am getting all the time is:

ERROR: the following directories could not be found:
ERROR: the following files could not be found:

The command inside dockerfile looks like this:

RUN export NEWRELIC_VERSION=$(curl -sS | sed -n 's/.*>\(.*linux-musl\).tar.gz<.*/\1/p') && \
    curl -L "${NEWRELIC_VERSION}.tar.gz" | tar -C /tmp -zx && \
    NR_INSTALL_USE_CP_NOT_LN=1 NR_INSTALL_SILENT=1 /tmp/newrelic-php5-*/newrelic-install install && \
      rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* && \
      sed -i \
          -e "s/newrelic.license =.*/newrelic.license = ${NEW_RELIC_LICENSE_KEY}/" \
          -e "s/newrelic.appname =.*/newrelic.appname = ${NEW_RELIC_APP_NAME}/" \

Also i tried to use NR_INSTALL_ARCH=x64 and it didn’t help at all.

Did anyone face that issue? Any ideas how to solve?

The musl installer for Alpine does not come with files compiled for x86 because Alpine is 64bit only. The installer script detects the OS and skips the check for x86 files if the OS is Apline. You can see this check around line 270 here:

check_dir "${ilibdir}/agent/${arch}"
if [ -z "${ispkg}" ] && [ "${arch}" = "x64" ]; then
  # Only check for x86 directory on supported platforms.
  case "$ostype" in
    alpine|darwin|freebsd) ;;
    *) check_dir "${ilibdir}/agent/x86" ;;

So it sounds like either the base image your dockerfile is using isn’t actually alpine or the installer can’t detect your OS. Can you share the FROM line from your dockerfile?

1 Like

@beastman Thank you for your response!
In my Dockerfile i have

FROM php:7.2-fpm-alpine3.7 AS base
..... and after for production environment
FROM base:latest AS build

After your idea was trying to find on dockerhub that image or in github, but no luck. So now i am worried :smiley:
Can you please advice what image to try instead?

That image is from the official PHP repo but it looks like they’ve replaced it with alpine3.8:

I tested that image with a quick and simple dockerfile:

FROM php:7.2-fpm-alpine3.7

RUN apk add curl bash

 curl -L | tar -C /tmp -zx && \
   NR_INSTALL_USE_CP_NOT_LN=1 NR_INSTALL_SILENT=1 /tmp/newrelic-php5-*/newrelic-install install

This installs the agent:

bash-4.4# /usr/local/sbin/php-fpm -m | grep newrelic
bash-4.4# /usr/local/sbin/php-fpm -i | grep newrelic.ini

I did notice the config files for PHP are in a different spot than in your script, /usr/ instead of /etc/. So it could be something else being installed that is tripping up our installer and making it think it is not Alpine.

1 Like

Encountered the same issue. For me it was xdebug triggering the error.

Following dockerfile was triggering the error:

FROM base as php_builder

RUN apk --no-cache add curl

RUN echo “Xdebug installation”
RUN mkdir -p ${PHP_DBG_PATH}
RUN apk add --no-cache $PHPIZE_DEPS
RUN yes | pecl install xdebug
#&& apk del $PHPIZE_DEPS

RUN echo “Installing Newrelic”

curl -L | tar -C /tmp -zx &&
NR_INSTALL_USE_CP_NOT_LN=1 NR_INSTALL_SILENT=1 /tmp/newrelic-php5-*/newrelic-install install

However If i took out (or moved it to the end) xdebug block, everything worked as expected.

1 Like

Thanks for sharing your findings! While we do have some limitations capturing errors with XDebug enabled I hadn’t run into issues with it causing problems for the installer before.

I don’t have Xdebug… It’s this line that is triggering the error if NR install is executed after it:
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS libtool libxml2-dev

@negrusti have you seen this post? Another community member was encountering something similar on Alpine, and they’ve got a great write-up / workaround for the issue.

1 Like