FROM php:8.3-fpm
# RUN sed -i 's/deb.debian.org/mirrors.163.com/g' /etc/apt/sources.list
# COPY sources.list.strech /etc/apt/sources.list

RUN apt-get update \
    && apt-get upgrade -y \
    && apt-get install -y nano \
    && apt-get install -y libfreetype6-dev \
    && apt-get install -y zlib1g-dev \
    && apt-get install -y libzip-dev \
    && apt-get install -y libjpeg62-turbo-dev \
    && apt-get install -y libpng-dev \
    && apt-get install -y zip \
    && apt-get install -y git \
    && apt-get install -y supervisor \
    && apt-get install -y mariadb-client \
    && docker-php-ext-install bcmath \
    && docker-php-ext-install ctype \
    && docker-php-ext-configure gd \
    && docker-php-ext-install gd mysqli zip pdo pdo_mysql exif pcntl bcmath opcache \
    && docker-php-ext-enable mysqli pdo pdo_mysql exif pcntl bcmath gd

RUN apt-get install --assume-yes --no-install-recommends --quiet \
    build-essential \
    libmagickwand-dev
# && apt-get clean all

# RUN pecl install imagick \
#     && docker-php-ext-enable imagick

RUN pecl install mongodb
RUN echo "extension=mongodb.so" > $PHP_INI_DIR/conf.d/mongodb.ini

RUN pecl install redis
RUN echo "extension=redis.so" > $PHP_INI_DIR/conf.d/redis.ini

# xdebug 3.1.6
RUN pecl install xdebug-3.3.2 \
    && docker-php-ext-enable xdebug

RUN php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
RUN php composer-setup.php
RUN mv composer.phar /usr/local/bin/composer
RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

# COPY config/10-shorttag.ini \
#     config/20-memory-limit.ini \
#     config/30-opcache.ini \
#     config/40-xdebug.ini \
#     $PHP_INI_DIR/conf.d/
WORKDIR /var/www/html

EXPOSE 9000

CMD service supervisor start \
    && php-fpm