Skip to content

Commit

Permalink
Refactor Dockerfile to use Docker PHP Extension Installer (mlocati/do…
Browse files Browse the repository at this point in the history
…cker-php-extension-installer)
  • Loading branch information
lmakarov committed Oct 4, 2024
1 parent 867bd21 commit a1ac7e6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 306 deletions.
108 changes: 9 additions & 99 deletions 8.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand All @@ -180,9 +132,7 @@ RUN set -xe; \
xsl \
zip \
sysvsem \
;\
pecl update-channels; \
pecl install >/dev/null </dev/null \
# Pecl extensions
apcu \
gnupg \
imagick \
Expand All @@ -191,49 +141,11 @@ RUN set -xe; \
ssh2 \
xdebug \
xhprof \
;\
docker-php-ext-enable \
apcu \
gnupg \
imagick \
memcached \
redis \
ssh2 \
;\
# Cleanup
docker-php-source delete; \
rm -rf /tmp/pear ~/.pearrc; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/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 \
pdo_sqlsrv \
sqlsrv \
;\
docker-php-ext-enable \
# MSSQL PHP client
pdo_sqlsrv \
sqlsrv \
;\
# Cleanup
rm -rf /tmp/pear ~/.pearrc; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \
apt-get clean; rm -rf /var/lib/apt/lists/*

# PHP tools (installed globally)
Expand All @@ -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
Expand All @@ -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; \
Expand Down
108 changes: 9 additions & 99 deletions 8.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand All @@ -181,9 +133,7 @@ RUN set -xe; \
xsl \
zip \
sysvsem \
;\
pecl update-channels; \
pecl install >/dev/null </dev/null \
# Pecl extensions
apcu \
gnupg \
imagick \
Expand All @@ -192,49 +142,11 @@ RUN set -xe; \
ssh2 \
xdebug \
xhprof \
;\
docker-php-ext-enable \
apcu \
gnupg \
imagick \
memcached \
redis \
ssh2 \
;\
# Cleanup
docker-php-source delete; \
rm -rf /tmp/pear ~/.pearrc; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/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 \
pdo_sqlsrv \
sqlsrv \
;\
docker-php-ext-enable \
# MSSQL PHP client
pdo_sqlsrv \
sqlsrv \
;\
# Cleanup
rm -rf /tmp/pear ~/.pearrc; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \
apt-get clean; rm -rf /var/lib/apt/lists/*

# PHP tools (installed globally)
Expand All @@ -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
Expand All @@ -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; \
Expand Down
Loading

0 comments on commit a1ac7e6

Please sign in to comment.