FROM php:8.3-fpm

COPY redis-6.0.2.tgz /tmp/redis.tgz
COPY xdebug-3.4.3.tgz /tmp/xdebug.tgz
COPY rdkafka-6.0.5.tgz /tmp/rdkafka.tgz
COPY composer.phar /usr/local/bin/composer

RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list.d/debian.sources

RUN apt-get update && apt-get install -y \
            git \
            zip \
            unzip \
            libpq-dev \
            libzip-dev \
            libpng-dev \
            libfreetype6-dev \
            libxml2-dev \
            libicu-dev \
            libssl-dev \
            librdkafka-dev \
        && docker-php-ext-configure intl \
        && docker-php-ext-configure pcntl --enable-pcntl \
        && docker-php-ext-install -j$(nproc) \
            bcmath \
            pdo_mysql \
            pdo_pgsql \
            gd \
            zip \
            exif \
            sockets \
            intl \
            soap \
            pcntl \
        && pecl install \
            /tmp/redis.tgz \
            /tmp/xdebug.tgz \
            /tmp/rdkafka.tgz \
        && docker-php-ext-enable \
            redis \
            xdebug \
            rdkafka \
        && rm -f /tmp/redis.tgz /tmp/xdebug.tgz \
        && apt-get clean \
        && apt-get autoclean

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# 修改 composer 为国内镜像
RUN composer config -g repo.packagist composer https://mirrors.cloud.tencent.com/composer/
