From a1ac7e6a1c8aad810d29ffab59198ca03edf50f0 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 4 Oct 2024 13:37:11 +0200 Subject: [PATCH] Refactor Dockerfile to use Docker PHP Extension Installer (mlocati/docker-php-extension-installer) --- 8.1/Dockerfile | 108 ++++---------------------------------------- 8.2/Dockerfile | 108 ++++---------------------------------------- 8.3/Dockerfile | 120 +++++-------------------------------------------- 3 files changed, 30 insertions(+), 306 deletions(-) diff --git a/8.1/Dockerfile b/8.1/Dockerfile index f8b85b76..efc6baf5 100644 --- a/8.1/Dockerfile +++ b/8.1/Dockerfile @@ -106,60 +106,12 @@ ENV NOTVISIBLE "in users profile" # PHP RUN set -xe; \ # Note: essential build tools (g++, gcc, make, etc) are included upstream as persistent packages. - buildDeps=" \ - libc-client2007e-dev \ - libfreetype6-dev \ - libgpgme11-dev \ - libicu-dev \ - libjpeg62-turbo-dev \ - libkrb5-dev \ - libldap2-dev \ - libmagickcore-dev \ - libmagickwand-dev \ - libmemcached-dev \ - libmhash-dev \ - libpng-dev \ - libpq-dev \ - libwebp-dev \ - libssh2-1-dev \ - libxpm-dev \ - libxslt1-dev \ - libzip-dev \ - unixodbc-dev \ - "; \ - apt-get update >/dev/null; \ - apt-get -y --no-install-recommends install >/dev/null \ - $buildDeps \ - libc-client2007e \ - libfreetype6 \ - libgpgme11 \ - libicu72 \ - libjpeg62-turbo \ - libldap-2.5-0 \ - libmagickcore-6.q16-6-extra \ - libmagickwand-6.q16-6 \ - libmemcached11 \ - libmemcachedutil2 \ - libmhash2 \ - libpng16-16 \ - libpq5 \ - libssh2-1 \ - libxpm4 \ - libxslt1.1 \ - libzip4 \ - ;\ - docker-php-ext-configure >/dev/null gd \ - --with-freetype \ - --with-jpeg \ - --with-webp \ - --with-xpm; \ - PHP_OPENSSL=yes docker-php-ext-configure >/dev/null imap --with-kerberos --with-imap-ssl; \ - # Using $(uname -m) (returns x86_64 / aarch64) vs ${TARGETARCH} (returns amd64 / arm64) - docker-php-ext-configure >/dev/null ldap --with-libdir=lib/$(uname -m)-linux-gnu/; \ - docker-php-ext-configure >/dev/null pgsql --with-pgsql=/usr/local/pgsql/; \ - docker-php-ext-configure >/dev/null zip; \ - \ - docker-php-ext-install >/dev/null -j$(nproc) \ + # Docker PHP Extension Installer + curl -sSLf "https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions" -o /usr/local/bin/install-php-extensions \ + && chmod +x /usr/local/bin/install-php-extensions; \ + # Instal/enable all PHP extensions via mlocati/docker-php-extension-installer + install-php-extensions \ + # Core extensions bcmath \ bz2 \ calendar\ @@ -180,9 +132,7 @@ RUN set -xe; \ xsl \ zip \ sysvsem \ - ;\ - pecl update-channels; \ - pecl install >/dev/null /dev/null; \ - apt-get clean; rm -rf /var/lib/apt/lists/* - -# MSSQL PHP client -RUN set -xe; \ - # Repo and key for msodbcsql18 (MS ODBC driver), required by pecl/sqlsrv and pecl/pdo_sqlsrv - curl -fsSL https://packages.microsoft.com/config/debian/12/prod.list -o /etc/apt/sources.list.d/mssql.list; \ - curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg; \ - \ - buildDeps=" \ - unixodbc-dev \ - "; \ - apt-get update >/dev/null; \ - # Necessary for msodbcsql18 (MSSQL) - ACCEPT_EULA=Y \ - apt-get -y --no-install-recommends install >/dev/null \ - $buildDeps \ - msodbcsql18 \ - ;\ - pecl update-channels; \ - pecl install >/dev/null /dev/null; \ apt-get clean; rm -rf /var/lib/apt/lists/* # PHP tools (installed globally) @@ -251,8 +163,6 @@ ENV \ JQ_VERSION=1.7.1 \ YQ_VERSION=4.44.3 RUN set -xe; \ - # Docker PHP Extension Installer - curl -sSLf "https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions" -o /usr/local/bin/install-php-extensions; \ # Composer 1.x curl -fsSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer1; \ # Composer 2.x @@ -276,7 +186,7 @@ RUN set -xe; \ # Set Default Composer Version ln -s /usr/local/bin/composer${COMPOSER_DEFAULT_VERSION} /usr/local/bin/composer; \ # Make all downloaded binaries executable in one shot - (cd /usr/local/bin && chmod +x install-php-extensions composer1 composer2 drush8 drupal wp platform acli terminus jq yq); + (cd /usr/local/bin && chmod +x composer1 composer2 drush8 drupal wp platform acli terminus jq yq); # Install Python 3 + pip from Debian repos RUN set -xe; \ diff --git a/8.2/Dockerfile b/8.2/Dockerfile index eaf8eedc..71d5cf3b 100644 --- a/8.2/Dockerfile +++ b/8.2/Dockerfile @@ -106,60 +106,12 @@ ENV NOTVISIBLE "in users profile" # PHP RUN set -xe; \ # Note: essential build tools (g++, gcc, make, etc) are included upstream as persistent packages. - buildDeps=" \ - libc-client2007e-dev \ - libfreetype6-dev \ - libgpgme11-dev \ - libicu-dev \ - libjpeg62-turbo-dev \ - libkrb5-dev \ - libldap2-dev \ - libmagickcore-dev \ - libmagickwand-dev \ - libmemcached-dev \ - libmhash-dev \ - libpng-dev \ - libpq-dev \ - libwebp-dev \ - libssh2-1-dev \ - libxpm-dev \ - libxslt1-dev \ - libzip-dev \ - unixodbc-dev \ - "; \ - apt-get update >/dev/null; \ - apt-get -y --no-install-recommends install >/dev/null \ - $buildDeps \ - libc-client2007e \ - libfreetype6 \ - libgpgme11 \ - libicu72 \ - libjpeg62-turbo \ - libldap-2.5-0 \ - libmagickcore-6.q16-6-extra \ - libmagickwand-6.q16-6 \ - libmemcached11 \ - libmemcachedutil2 \ - libmhash2 \ - libpng16-16 \ - libpq5 \ - libssh2-1 \ - libxpm4 \ - libxslt1.1 \ - libzip4 \ - ;\ - docker-php-ext-configure >/dev/null gd \ - --with-freetype \ - --with-jpeg \ - --with-webp \ - --with-xpm; \ - PHP_OPENSSL=yes docker-php-ext-configure >/dev/null imap --with-kerberos --with-imap-ssl; \ - # Using $(uname -m) (returns x86_64 / aarch64) vs ${TARGETARCH} (returns amd64 / arm64) - docker-php-ext-configure >/dev/null ldap --with-libdir=lib/$(uname -m)-linux-gnu/; \ - docker-php-ext-configure >/dev/null pgsql --with-pgsql=/usr/local/pgsql/; \ - docker-php-ext-configure >/dev/null zip; \ - \ - docker-php-ext-install >/dev/null -j$(nproc) \ + # Docker PHP Extension Installer + curl -sSLf "https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions" -o /usr/local/bin/install-php-extensions \ + && chmod +x /usr/local/bin/install-php-extensions; \ + # Instal/enable all PHP extensions via mlocati/docker-php-extension-installer + install-php-extensions \ + # Stock extensions from upstream image bcmath \ bz2 \ calendar\ @@ -181,9 +133,7 @@ RUN set -xe; \ xsl \ zip \ sysvsem \ - ;\ - pecl update-channels; \ - pecl install >/dev/null /dev/null; \ - apt-get clean; rm -rf /var/lib/apt/lists/* - -# MSSQL PHP client -RUN set -xe; \ - # Repo and key for msodbcsql18 (MS ODBC driver), required by pecl/sqlsrv and pecl/pdo_sqlsrv - curl -fsSL https://packages.microsoft.com/config/debian/12/prod.list -o /etc/apt/sources.list.d/mssql.list; \ - curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg; \ - \ - buildDeps=" \ - unixodbc-dev \ - "; \ - apt-get update >/dev/null; \ - # Necessary for msodbcsql18 (MSSQL) - ACCEPT_EULA=Y \ - apt-get -y --no-install-recommends install >/dev/null \ - $buildDeps \ - msodbcsql18 \ - ;\ - pecl update-channels; \ - pecl install >/dev/null /dev/null; \ apt-get clean; rm -rf /var/lib/apt/lists/* # PHP tools (installed globally) @@ -252,8 +164,6 @@ ENV \ JQ_VERSION=1.7.1 \ YQ_VERSION=4.44.3 RUN set -xe; \ - # Docker PHP Extension Installer - curl -sSLf "https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions" -o /usr/local/bin/install-php-extensions; \ # Composer 1.x curl -fsSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer1; \ # Composer 2.x @@ -277,7 +187,7 @@ RUN set -xe; \ # Set Default Composer Version ln -s /usr/local/bin/composer${COMPOSER_DEFAULT_VERSION} /usr/local/bin/composer; \ # Make all downloaded binaries executable in one shot - (cd /usr/local/bin && chmod +x install-php-extensions composer1 composer2 drush8 drupal wp platform acli terminus jq yq); + (cd /usr/local/bin && chmod +x composer1 composer2 drush8 drupal wp platform acli terminus jq yq); # Install Python 3 + pip from Debian repos RUN set -xe; \ diff --git a/8.3/Dockerfile b/8.3/Dockerfile index ef74e237..75990aeb 100644 --- a/8.3/Dockerfile +++ b/8.3/Dockerfile @@ -106,60 +106,12 @@ ENV NOTVISIBLE "in users profile" # PHP RUN set -xe; \ # Note: essential build tools (g++, gcc, make, etc) are included upstream as persistent packages. - buildDeps=" \ - libc-client2007e-dev \ - libfreetype6-dev \ - libgpgme11-dev \ - libicu-dev \ - libjpeg62-turbo-dev \ - libkrb5-dev \ - libldap2-dev \ - libmagickcore-dev \ - libmagickwand-dev \ - libmemcached-dev \ - libmhash-dev \ - libpng-dev \ - libpq-dev \ - libwebp-dev \ - libssh2-1-dev \ - libxpm-dev \ - libxslt1-dev \ - libzip-dev \ - unixodbc-dev \ - "; \ - apt-get update >/dev/null; \ - apt-get -y --no-install-recommends install >/dev/null \ - $buildDeps \ - libc-client2007e \ - libfreetype6 \ - libgpgme11 \ - libicu72 \ - libjpeg62-turbo \ - libldap-2.5-0 \ - libmagickcore-6.q16-6-extra \ - libmagickwand-6.q16-6 \ - libmemcached11 \ - libmemcachedutil2 \ - libmhash2 \ - libpng16-16 \ - libpq5 \ - libssh2-1 \ - libxpm4 \ - libxslt1.1 \ - libzip4 \ - ;\ - docker-php-ext-configure >/dev/null gd \ - --with-freetype \ - --with-jpeg \ - --with-webp \ - --with-xpm; \ - PHP_OPENSSL=yes docker-php-ext-configure >/dev/null imap --with-kerberos --with-imap-ssl; \ - # Using $(uname -m) (returns x86_64 / aarch64) vs ${TARGETARCH} (returns amd64 / arm64) - docker-php-ext-configure >/dev/null ldap --with-libdir=lib/$(uname -m)-linux-gnu/; \ - docker-php-ext-configure >/dev/null pgsql --with-pgsql=/usr/local/pgsql/; \ - docker-php-ext-configure >/dev/null zip; \ - \ - docker-php-ext-install >/dev/null -j$(nproc) \ + # Docker PHP Extension Installer + curl -sSLf "https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions" -o /usr/local/bin/install-php-extensions \ + && chmod +x /usr/local/bin/install-php-extensions; \ + # Instal/enable all PHP extensions via mlocati/docker-php-extension-installer + install-php-extensions \ + # Stock extensions from upstream image bcmath \ bz2 \ calendar\ @@ -181,69 +133,23 @@ RUN set -xe; \ xsl \ zip \ sysvsem \ - ;\ - pecl update-channels; \ - pecl install >/dev/null /dev/null; \ - apt-get clean; rm -rf /var/lib/apt/lists/* - # MSSQL PHP client -RUN set -xe; \ - # Repo and key for msodbcsql18 (MS ODBC driver), required by pecl/sqlsrv and pecl/pdo_sqlsrv - curl -fsSL https://packages.microsoft.com/config/debian/12/prod.list -o /etc/apt/sources.list.d/mssql.list; \ - curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg; \ - \ - buildDeps=" \ - unixodbc-dev \ - "; \ - apt-get update >/dev/null; \ - # Necessary for msodbcsql18 (MSSQL) - ACCEPT_EULA=Y \ - apt-get -y --no-install-recommends install >/dev/null \ - $buildDeps \ - msodbcsql18 \ - ;\ - pecl update-channels; \ - pecl install >/dev/null /dev/null; \ apt-get clean; rm -rf /var/lib/apt/lists/* # PHP tools (installed globally) @@ -261,8 +167,6 @@ ENV \ JQ_VERSION=1.7.1 \ YQ_VERSION=4.44.3 RUN set -xe; \ - # Docker PHP Extension Installer - curl -sSLf "https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions" -o /usr/local/bin/install-php-extensions; \ # Composer 1.x curl -fsSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer1; \ # Composer 2.x @@ -286,7 +190,7 @@ RUN set -xe; \ # Set Default Composer Version ln -s /usr/local/bin/composer${COMPOSER_DEFAULT_VERSION} /usr/local/bin/composer; \ # Make all downloaded binaries executable in one shot - (cd /usr/local/bin && chmod +x install-php-extensions composer1 composer2 drush8 drupal wp platform acli terminus jq yq); + (cd /usr/local/bin && chmod +x composer1 composer2 drush8 drupal wp platform acli terminus jq yq); # Install Python 3 + pip from Debian repos RUN set -xe; \