FROM php:8.4-fpm-alpine
RUN apk add --no-cache git curl libpng-dev libjpeg-turbo-dev freetype-dev libzip-dev icu-dev oniguruma-dev postgresql-dev $PHPIZE_DEPS \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) pdo_pgsql intl mbstring zip gd opcache bcmath \
    && pecl install redis && docker-php-ext-enable redis \
    && apk del $PHPIZE_DEPS
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www/html
COPY . .
RUN composer install --no-dev --prefer-dist --no-interaction --optimize-autoloader \
    && chown -R www-data:www-data storage bootstrap/cache
COPY infrastructure/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
USER www-data
CMD ["php-fpm"]
