#FROM php:7.2.34-fpm-alpine3.12
#FROM php:7.4.33-zts-alpine3.15
FROM php:7.4.33-fpm-alpine3.16

ENV COMPOSER_ALLOW_SUPERUSER=1 \
    COMPOSER_HOME=/composer \
    COMPOSER_MEMORY_LIMIT=-1

# 使用阿里云 Alpine 3.12 存档源
RUN echo "https://mirrors.aliyun.com/alpine/v3.16/main" > /etc/apk/repositories \
    && echo "https://mirrors.aliyun.com/alpine/v3.16/community" >> /etc/apk/repositories

# 安装依赖 + 常用扩展
RUN apk add --no-cache \
        libpng-dev \
        bash \
        curl \
        wget \
        unzip \
        libzip-dev \
        mariadb-connector-c-dev \
        openssl \
        openssl-dev \
        pcre \
        pcre-dev \
        zlib \
        zlib-dev \
        oniguruma-dev \
        autoconf \
        linux-headers \
        build-base \
    && docker-php-ext-install \
        pdo_mysql \
        mysqli \
        mbstring \
        opcache \
        zip \
    && pecl install swoole-4.8.12 \
    && docker-php-ext-enable swoole \
    # 安装 redis 扩展（最后一个支持 php7.2 的版本）
    && pecl install redis-5.3.7 \
    && docker-php-ext-enable redis \
    && docker-php-ext-install gd \
    && docker-php-ext-enable gd \
    # 安装 composer
    && curl -sS https://getcomposer.org/installer | php -- \
        --install-dir=/usr/local/bin --filename=composer \
    # 清理
    && apk del build-base autoconf linux-headers \
    && rm -rf /tmp/pear ~/.pearrc /var/cache/apk/*

WORKDIR /www/wwwroot/admin
