# Production build stage
FROM php:7.4-fpm AS production
# disable dpkg interactive-mode
ENV DEBIAN_FRONTEND noninteractive
# Set working directory
WORKDIR /var/www/app
# Set timezone
RUN rm /etc/localtime && ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime && "date"
# Install intl necessary packages
RUN apt-get update && apt-get install -y zlib1g-dev libicu-dev g++ apt-utils
# Install php extensions
RUN docker-php-ext-install pdo pdo_mysql mysqli bcmath intl
# Install Redis extension
RUN pecl install -o -f redis && rm -rf /tmp/pear && echo "extension=redis.so" > /usr/local/etc/php/conf.d/docker-php-ext-redis.ini
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Bind container to the php-fpm service
CMD ["php-fpm"]
# Development build stage
FROM production as development
# Install enable and configure xDebug
RUN pecl install xdebug && \
docker-php-ext-enable xdebug && \
echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo "display_startup_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo "display_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo "xdebug.remote_port=9001" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo "xdebug.remote_host=docker.host.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini