php在更新 mac os 后为 docker 构建 php-fpm 时 ize 失败

phpize failed when building php-fpm for docker after updating mac os

在我将 mac os 从 11.4 更新到 11.6 后,我有 os 为 docker 构建 php 图像的能力.在更新之前,一切都在顺利构建,但在更新之后,我似乎根本无法构建带有任何额外扩展的 php-fpm。

因此,如果我有没有任何扩展名的 Dockerfile,那么将构建映像

FROM php:7.4-fpm
RUN apt-get update && apt-get install -y \
        curl \
        wget \
        git \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        zlib1g-dev \
        libpng-dev \
        libonig-dev \
        libzip-dev \
        libmcrypt-dev \
        libpq-dev 

CMD ["php-fpm"]

但是,如果我的 docker 文件中有任何扩展名,则在尝试安装第一个扩展名时构建将失败。 因此,docker这样的文件

FROM php:7.4-fpm

RUN apt-get update && apt-get install -y \
        curl \
        wget \
        git \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        zlib1g-dev \
        libpng-dev \
        libonig-dev \
        libzip-dev \
        libmcrypt-dev \
        libpq-dev 

RUN pecl install mcrypt-1.0.4
RUN docker-php-ext-enable mcrypt

RUN docker-php-ext-install -j$(nproc) iconv
RUN docker-php-ext-install -j$(nproc) mbstring
RUN docker-php-ext-install -j$(nproc) mysqli
RUN docker-php-ext-install -j$(nproc) pdo_mysql
RUN docker-php-ext-install -j$(nproc) zip
RUN pecl install -o redis && docker-php-ext-enable redis

CMD ["php-fpm"]

我遇到这样的错误

 => ERROR [ 3/12] RUN pecl install mcrypt-1.0.4                                                     3.7s
------                                                                                                   
 > [ 3/12] RUN pecl install mcrypt-1.0.4:                                                                
#6 3.043 downloading mcrypt-1.0.4.tgz ...                                                                
#6 3.044 Starting to download mcrypt-1.0.4.tgz (27,056 bytes)                                            
#6 3.157 .........done: 27,056 bytes                                                                     
#6 3.196 6 source files, building                                                                        
#6 3.196 running: phpize
#6 3.208 Configuring for:
#6 3.208 PHP Api Version:         20190902
#6 3.208 Zend Module Api No:      20190902
#6 3.208 Zend Extension Api No:   320190902
#6 3.354 Use of uninitialized value $type in string eq at /usr/bin/autom4te line 272, <GEN0> line 66.
#6 3.354 Use of uninitialized value $type in string eq at /usr/bin/autom4te line 278, <GEN0> line 66.
#6 3.355 Use of uninitialized value $type in string eq at /usr/bin/autom4te line 284, <GEN0> line 66.
#6 3.355 Use of uninitialized value $type in concatenation (.) or string at /usr/bin/autom4te line 292, <GEN0> line 66.
#6 3.355 autom4te: /usr/share/autoconf/autom4te.cfg:66: unknown directive:
#6 3.718 ERROR: `phpize' failed
------
executor failed running [/bin/sh -c pecl install mcrypt-1.0.4]: exit code: 1

根据我尝试安装的扩展,错误会有所不同

=> ERROR [3/8] RUN docker-php-ext-install -j$(nproc) iconv                                         4.2s
------                                                                                                   
 > [3/8] RUN docker-php-ext-install -j$(nproc) iconv:                                                    
#6 3.155 Configuring for:                                                                                
#6 3.155 PHP Api Version:         20190902                                                               
#6 3.155 Zend Module Api No:      20190902                                                               
#6 3.155 Zend Extension Api No:   320190902                                                              
#6 3.769 Can't export symbol: US_GLOBAL at /usr/share/autoconf/Autom4te/FileUtils.pm line 42.
#6 3.769 BEGIN failed--compilation aborted at /usr/share/autoconf/Autom4te/FileUtils.pm line 42.
#6 3.769 Compilation failed in require at /usr/bin/autom4te line 40.
#6 3.769 BEGIN failed--compilation aborted at /usr/bin/autom4te line 40.
#6 3.772 autoheader: '/usr/bin/autom4te' failed with exit status: 255
------
executor failed running [/bin/sh -c docker-php-ext-install -j$(nproc) iconv]: exit code: 1

但仍然无法找到有关这些错误的任何信息。

我已经尝试重新安装开发人员工具和 brew,但仍然无法使用任何扩展构建 php 图像。

我花了 4 天时间,疯狂地搜索,完全卸载我的系统很多次,包括安装 mac os 10.12 的测试版,但是...

...由于某些绝对奇怪的原因,图像不会使用 FROM php:7.4-fpm 构建(尽管之前已成功构建)但将使用 Dockerfile

中的 FROM php:7.4.0-fpm 构建