From b7b5d0c480e57db02ac34d1799b147dcae30de02 Mon Sep 17 00:00:00 2001 From: Shao Yu-Lung Date: Mon, 2 Oct 2023 08:28:07 +0800 Subject: [PATCH 1/4] base image switch to debian --- Dockerfile | 215 +++++++++++++++++++++++------------------------------ 1 file changed, 94 insertions(+), 121 deletions(-) diff --git a/Dockerfile b/Dockerfile index d532be3..647f476 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,159 +1,132 @@ -ARG PHP_TAG_VERSION -FROM php:${PHP_TAG_VERSION} +FROM debian:11-slim +ARG DEBIAN_FRONTEND=noninteractive ARG PHP_TAG_VERSION RUN set -eux; \ apt-get update; \ - apt-get install -yq \ - git \ - libbz2-dev \ - libcurl4-gnutls-dev \ - libxml2-dev \ - libjpeg-dev \ - libpng-dev \ - libgmp3-dev \ - libicu-dev \ - libldap2-dev \ - libpq-dev \ - libsqlite3-dev \ - libpspell-dev \ - libedit-dev \ - librecode-dev \ - libsnmp-dev \ -# libmcrypt-dev libpq-dev libvpx-dev libxpm-dev zlib1g-dev libfreetype6-dev libexpat1-dev unixodbc-dev libaspell-dev libpcre3-dev libtidy-dev - libzip-dev zip unzip \ - gnupg \ - nodejs \ + apt-get install -y apt-transport-https lsb-release ca-certificates curl wget; \ + wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg; \ + echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list; \ + apt-get update; \ + apt-get install -yq git libzip-dev zip unzip gnupg \ + # nodejs \ ; \ - if [ ${PHP_TAG_VERSION} = "5.6" ] || [ ${PHP_TAG_VERSION} = "7.0" ] || [ ${PHP_TAG_VERSION} = "7.1" ] || [ ${PHP_TAG_VERSION} = "7.2" ]; then \ - apt-get install -yq libenchant-dev; \ - else \ - apt-get install -yq libenchant-2-dev; \ - fi; \ apt upgrade -yq --purge RUN set -eux; \ - # Install and run Composer - curl -sS https://getcomposer.org/installer | php; \ - mv composer.phar /usr/local/bin/composer; \ - chmod +x /usr/local/bin/composer; \ - # Install deployer - curl -LO https://deployer.org/deployer.phar; \ - mv deployer.phar /usr/local/bin/dep; \ - chmod +x /usr/local/bin/dep; + # apt-get install -y php${PHP_TAG_VERSION} + apt-get update \ + ; RUN set -eux; \ - docker-php-ext-install bcmath bz2 calendar ctype curl dba dom exif; \ - if [ ${PHP_TAG_VERSION} = "5.6" ] || [ ${PHP_TAG_VERSION} = "7.0" ] || [ ${PHP_TAG_VERSION} = "7.1" ] || [ ${PHP_TAG_VERSION} = "7.2" ]; then \ - docker-php-ext-install enchant; \ - else \ - # docker-php-ext-install enchant-2; \ - echo "TODO: need implement"; \ + apt-get install -y \ + php${PHP_TAG_VERSION}-bcmath \ + php${PHP_TAG_VERSION}-bz2 \ + php${PHP_TAG_VERSION}-cli \ + php${PHP_TAG_VERSION}-fpm \ + php${PHP_TAG_VERSION}-curl \ + php${PHP_TAG_VERSION}-decimal \ + php${PHP_TAG_VERSION}-enchant \ + # ffi 不支援 7.3 + # php${PHP_TAG_VERSION}-ffi \ + php${PHP_TAG_VERSION}-gd \ + php${PHP_TAG_VERSION}-gearman \ + php${PHP_TAG_VERSION}-gettext \ + php${PHP_TAG_VERSION}-gmp \ + php${PHP_TAG_VERSION}-gnupg \ + php${PHP_TAG_VERSION}-iconv \ + php${PHP_TAG_VERSION}-imap \ + # php${PHP_TAG_VERSION}-interbase \ + php${PHP_TAG_VERSION}-intl \ + php${PHP_TAG_VERSION}-ldap \ + php${PHP_TAG_VERSION}-mbstring \ + php${PHP_TAG_VERSION}-mcrypt \ + php${PHP_TAG_VERSION}-mongodb \ + php${PHP_TAG_VERSION}-mysql \ + php${PHP_TAG_VERSION}-odbc \ + php${PHP_TAG_VERSION}-opcache \ + php${PHP_TAG_VERSION}-pgsql \ + php${PHP_TAG_VERSION}-posix \ + php${PHP_TAG_VERSION}-pspell \ + php${PHP_TAG_VERSION}-redis \ + php${PHP_TAG_VERSION}-sqlite3 \ + # php${PHP_TAG_VERSION}-sybase \ + php${PHP_TAG_VERSION}-xmlwriter \ + php${PHP_TAG_VERSION}-zip \ + # php${PHP_TAG_VERSION}-hash \ + ; +RUN set -eux; \ + if [ ${PHP_TAG_VERSION} != "7.3" ] && \ + [ ${PHP_TAG_VERSION} != "7.2" ] && \ + [ ${PHP_TAG_VERSION} != "7.1" ]; then \ + apt-get install -y php${PHP_TAG_VERSION}-ffi; \ fi - -RUN set -eux; \ - if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \ - if [ $(php -r "echo PHP_MINOR_VERSION;") = "4" ]; then \ - docker-php-ext-install ffi \ - ;fi \ - ;fi -RUN set -eux; docker-php-ext-install fileinfo -# RUN set -eux; docker-php-ext-install filter -# RUN set -eux; docker-php-ext-install ftp -RUN set -eux; docker-php-ext-install gd -RUN set -eux; docker-php-ext-install gettext -RUN set -eux; \ - if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ - ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \ - ;fi ;\ - docker-php-ext-install gmp -RUN set -eux; \ - if [ $(php -r "echo PHP_MAJOR_VERSION;") != "7" ]; then \ - if [ $(php -r "echo PHP_MINOR_VERSION;") != "4" ]; then \ - if [ $(php -r "echo PHP_MAJOR_VERSION;") != "8" ]; then \ - docker-php-ext-install hash \ - ;fi \ - ;fi \ - ;fi -RUN set -eux; docker-php-ext-install iconv -RUN set -eux; \ - apt-get install -y libc-client-dev libkrb5-dev ;\ - docker-php-ext-configure imap --with-kerberos --with-imap-ssl ;\ - docker-php-ext-install imap -RUN set -eux; docker-php-ext-install intl -RUN set -eux; \ - if [ $(php -r "echo PHP_MAJOR_VERSION;") != "8" ]; then \ - docker-php-ext-install json \ - ;fi -RUN set -eux; \ - apt-get install -y libldap2-dev; \ - docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ ;\ - docker-php-ext-install ldap -RUN set -eux; \ - if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \ - if [ $(php -r "echo PHP_MINOR_VERSION;") = "4" ]; then \ - apt-get install -yqq libonig-dev \ - ;fi \ - ;fi +# RUN set -eux; \ +# if [ $(php -r "echo PHP_MAJOR_VERSION;") != "7" ]; then \ +# if [ $(php -r "echo PHP_MINOR_VERSION;") != "4" ]; then \ +# if [ $(php -r "echo PHP_MAJOR_VERSION;") != "8" ]; then \ +# apt-get install -y php${PHP_TAG_VERSION}-hash; \ +# fi; \ +# fi; \ +# fi RUN set -eux; \ if [ $(php -r "echo PHP_MAJOR_VERSION;") != "8" ]; then \ - docker-php-ext-install mbstring \ - ;fi -RUN set -eux; docker-php-ext-install mysqli + apt-get install -y php${PHP_TAG_VERSION}-json; \ + fi +# RUN set -eux; \ +# if [ $(php -r "echo PHP_MAJOR_VERSION;") != "8" ]; then \ +# apt-get install -y php${PHP_TAG_VERSION}-mbstring; \ +# fi # RUN set -eux; docker-php-ext-install oci8 # RUN set -eux; \ # apt-get install -yqq unixodbc unixodbc-dev; \ # docker-php-ext-configure odbc --with-unixODBC=shared,/usr; \ # docker-php-ext-install odbc -RUN set -eux; docker-php-ext-install opcache -RUN set -eux; docker-php-ext-install pcntl -RUN set -eux; docker-php-ext-install pdo -RUN set -eux; \ - apt-get install -yqq freetds-bin freetds-dev ;\ - ln -s /usr/lib/x86_64-linux-gnu/libsybdb.a /usr/lib/ ;\ - docker-php-ext-install pdo_dblib -# RUN set -eux; docker-php-ext-install pdo_firebird -RUN set -eux; docker-php-ext-install pdo_mysql -# RUN set -eux; docker-php-ext-install pdo_oci +# RUN apt-get install -y php${PHP_TAG_VERSION}-pcntl # RUN set -eux; \ -# apt-get install -yqq unixodbc unixodbc-dev; \ -# docker-php-ext-configure pdo_odbc --with-unixODBC=shared,/usr; \ -# docker-php-ext-install pdo_odbc -RUN set -eux; docker-php-ext-install pdo_pgsql -RUN set -eux; docker-php-ext-install pdo_sqlite -RUN set -eux; docker-php-ext-install pgsql + # apt-get install -yqq freetds-bin freetds-dev ;\ + # ln -s /usr/lib/x86_64-linux-gnu/libsybdb.a /usr/lib/ ;\ + # apt-get install -y php${PHP_TAG_VERSION}-pdo_dblib +# RUN set -eux; docker-php-ext-install pdo_oci # RUN set -eux; docker-php-ext-install phar -RUN set -eux; docker-php-ext-install posix -RUN set -eux; docker-php-ext-install pspell -RUN set -eux; \ - if [ ${PHP_TAG_VERSION} = "5.6" ] || [ ${PHP_TAG_VERSION} = "7.0" ] || [ ${PHP_TAG_VERSION} = "7.1" ] || [ ${PHP_TAG_VERSION} = "7.2" ]; then \ - docker-php-ext-install readline; \ +RUN if [ ${PHP_TAG_VERSION} = "5.6" ] || [ ${PHP_TAG_VERSION} = "7.0" ] || [ ${PHP_TAG_VERSION} = "7.1" ] || [ ${PHP_TAG_VERSION} = "7.2" ]; then \ + apt-get install -y php${PHP_TAG_VERSION}-readline; \ fi; \ php -m | grep -oiE '^readline$' # RUN set -eux; docker-php-ext-install reflection -RUN set -eux; \ - docker-php-ext-install session shmop simplexml snmp soap sockets +# RUN set -eux; \ +# docker-php-ext-install session shmop simplexml snmp soap sockets # RUN set -eux; docker-php-ext-install sodium # RUN set -eux; docker-php-ext-install spl # RUN set -eux; docker-php-ext-install standard -RUN set -eux; \ - docker-php-ext-install sysvmsg sysvsem sysvshm +# RUN set -eux; \ +# docker-php-ext-install sysvmsg sysvsem sysvshm # RUN set -eux; docker-php-ext-install tidy RUN set -eux; \ if [ $(PHP_TAG_VERSION) != "8.1" ]; then \ - docker-php-ext-install tokenizer; \ + apt-get install -y php${PHP_TAG_VERSION}-tokenizer; \ + php -m | grep -oiE '^tokenizer$'; \ fi -RUN set -eux; docker-php-ext-install xml +RUN apt-get install -y php${PHP_TAG_VERSION}-xml; \ + php -m | grep -oiE '^xml$' # RUN set -eux; docker-php-ext-install xmlreader RUN set -eux; \ if [ $(php -r "echo PHP_MAJOR_VERSION;") != "8" ]; then \ - docker-php-ext-install xmlrpc \ - ;fi -RUN set -eux; docker-php-ext-install xmlwriter + apt-get install -y php${PHP_TAG_VERSION}-xmlrpc; \ + php -m | grep -oiE '^xmlrpc$'; \ + fi # RUN set -eux; docker-php-ext-install xsl # RUN set -eux; docker-php-ext-install zend_test -RUN set -eux; docker-php-ext-install zip + +RUN php${PHP_TAG_VERSION} -m RUN set -eux; \ - php -m + # Install and run Composer + curl -sS https://getcomposer.org/installer | phpphp${PHP_TAG_VERSION}; \ + mv composer.phar /usr/local/bin/composer; \ + chmod +x /usr/local/bin/composer; \ + # Install deployer + curl -LO https://deployer.org/deployer.phar; \ + mv deployer.phar /usr/local/bin/dep; \ + chmod +x /usr/local/bin/dep; From 4a74e86e816061e5f5168f09ad862caa5a580d54 Mon Sep 17 00:00:00 2001 From: Shao Yu-Lung Date: Mon, 2 Oct 2023 08:34:23 +0800 Subject: [PATCH 2/4] fix: php 5.6 not support decimal ext. --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 647f476..d7fe8ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,8 @@ RUN set -eux; \ php${PHP_TAG_VERSION}-cli \ php${PHP_TAG_VERSION}-fpm \ php${PHP_TAG_VERSION}-curl \ - php${PHP_TAG_VERSION}-decimal \ + # decimal 不支援 5.6 + # php${PHP_TAG_VERSION}-decimal \ php${PHP_TAG_VERSION}-enchant \ # ffi 不支援 7.3 # php${PHP_TAG_VERSION}-ffi \ @@ -57,6 +58,9 @@ RUN set -eux; \ # php${PHP_TAG_VERSION}-hash \ ; RUN set -eux; \ + if [ ${PHP_TAG_VERSION} != "5.6" ]; then \ + apt-get install -y php${PHP_TAG_VERSION}-decimal; \ + fi; \ if [ ${PHP_TAG_VERSION} != "7.3" ] && \ [ ${PHP_TAG_VERSION} != "7.2" ] && \ [ ${PHP_TAG_VERSION} != "7.1" ]; then \ From 56022cc8897bd14da42f23a03d6087cf7e59da1e Mon Sep 17 00:00:00 2001 From: Shao Yu-Lung Date: Mon, 2 Oct 2023 08:36:16 +0800 Subject: [PATCH 3/4] fix: php 5.6 not support ffi ext. --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d7fe8ed..68658fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,7 +63,8 @@ RUN set -eux; \ fi; \ if [ ${PHP_TAG_VERSION} != "7.3" ] && \ [ ${PHP_TAG_VERSION} != "7.2" ] && \ - [ ${PHP_TAG_VERSION} != "7.1" ]; then \ + [ ${PHP_TAG_VERSION} != "7.1" ] && \ + [ ${PHP_TAG_VERSION} != "5.6" ]; then \ apt-get install -y php${PHP_TAG_VERSION}-ffi; \ fi # RUN set -eux; \ @@ -127,7 +128,7 @@ RUN php${PHP_TAG_VERSION} -m RUN set -eux; \ # Install and run Composer - curl -sS https://getcomposer.org/installer | phpphp${PHP_TAG_VERSION}; \ + curl -sS https://getcomposer.org/installer | php${PHP_TAG_VERSION}; \ mv composer.phar /usr/local/bin/composer; \ chmod +x /usr/local/bin/composer; \ # Install deployer From b775ebce3cee8c14758166b3ba08c5df69e96ea9 Mon Sep 17 00:00:00 2001 From: Shao Yu-Lung Date: Mon, 2 Oct 2023 08:49:34 +0800 Subject: [PATCH 4/4] fix: php 7.0 not support ffi ext. --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 68658fd..8409d44 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,6 +64,7 @@ RUN set -eux; \ if [ ${PHP_TAG_VERSION} != "7.3" ] && \ [ ${PHP_TAG_VERSION} != "7.2" ] && \ [ ${PHP_TAG_VERSION} != "7.1" ] && \ + [ ${PHP_TAG_VERSION} != "7.0" ] && \ [ ${PHP_TAG_VERSION} != "5.6" ]; then \ apt-get install -y php${PHP_TAG_VERSION}-ffi; \ fi