FROM php:8.4-fpm

# PHP Extensions
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && install-php-extensions \
    bcmath curl dom exif fileinfo filter hash iconv intl imagick json memcached mbstring mysqli opcache openssl pcre \
    redis simplexml xml xmlreader zlib zip

# New Relic
#ARG NEW_RELIC_AGENT_VERSION
#ARG NEW_RELIC_LICENSE_KEY
#ARG NEW_RELIC_APPNAME
#ARG NEW_RELIC_DAEMON_ADDRESS

#RUN curl -L "https://download.newrelic.com/php_agent/release/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-linux.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 \
# && rm -rf /tmp/newrelic-php5-* /tmp/nrinstall*
#
#RUN sed -i -e s/\"REPLACE_WITH_REAL_KEY\"/${NEW_RELIC_LICENSE_KEY}/ \
# -e s/newrelic.appname[[:space:]]=[[:space:]].\*/newrelic.appname="${NEW_RELIC_APPNAME}"/ \
# -e s/\;newrelic.daemon.address[[:space:]]=[[:space:]].\*/newrelic.daemon.address="newrelic-php-daemon:31339"/ \
#    /usr/local/etc/php/conf.d/newrelic.ini

# Configure email sending
#RUN apt-get update && apt-get install -y zlib1g-dev libzip-dev sendmail
#RUN echo "sendmail_path=/usr/sbin/sendmail -t -i" >> /usr/local/etc/php/conf.d/sendmail.ini
#RUN sed -i '/#!\/bin\/sh/aservice sendmail restart' /usr/local/bin/docker-php-entrypoint
#RUN sed -i '/#!\/bin\/sh/aecho "$(hostname -i)\t$(hostname) $(hostname).localhost" >> /etc/hosts' /usr/local/bin/docker-php-entrypoint
#RUN rm -rf /var/lib/apt/lists/*

# Local development
ARG APP_ENV
RUN if [ "${APP_ENV}" = "dev" ] ; then \
    cp -f "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" && \
    pecl install xdebug && \
    docker-php-ext-enable xdebug; \
fi
