php/docker/usr/local/bin/php_configure.sh
2022-06-05 22:49:25 +02:00

111 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
set -eo pipefail
shopt -s nullglob
shopt -s dotglob
PHP_VERSION=`php -r 'echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;'`
PHP_MODULES=(
"calendar"
"bcmath"
"bz2"
"curl"
"fileinfo"
"gettext"
"imap"
"intl"
"ldap"
"mbstring"
"opcache"
"pcntl"
"pdo"
"pdo_mysql"
"pdo_pgsql"
"pdo_sqlite"
"pgsql"
"phar"
"session"
"simplexml"
"soap"
"xml"
"zip"
"snmp"
)
#
# Helper functions
#
declare -i term_width=80
h1() {
declare border padding text
border='\e[1;34m'"$(printf '=%.0s' $(seq 1 "$term_width"))"'\e[0m'
padding="$(printf ' %.0s' $(seq 1 $(((term_width - $(wc -m <<<"$*")) / 2))))"
text="\\e[1m$*\\e[0m"
echo -e "$border"
echo -e "${padding}${text}${padding}"
echo -e "$border"
}
h2() {
printf '\e[1;33m==>\e[37;1m %s\e[0m\n' "$*"
}
h1 "Configure PHP modules"
case $PHP_VERSION in
'81' )
h2 "[php8.1] Configure and install GD"
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp
docker-php-ext-install -j$(nproc) gd
h2 "Install memcache module"
apk add --no-cache --virtual php81-pecl-memcache
h2 "Install iconv extension"
apk add --no-cache --virtual php81-iconv
;;
'80' )
h2 "[php8.0] Configure and install GD"
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp
docker-php-ext-install -j$(nproc) gd
h2 "Install memcache module"
apk add --no-cache --virtual php8-pecl-memcache
h1 "Install iconv extension"
apk add --no-cache --virtual php8-iconv
;;
'74' )
h2 "[php74] Configure and install GD"
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp
docker-php-ext-install -j$(nproc) gd
h2 "Install json module"
docker-php-ext-install -j$(nproc) json
h2 "Install memcache module"
apk add --no-cache --virtual php7-pecl-memcache
h1 "Install iconv extension"
apk add --no-cache --virtual php7-iconv
;;
'73' )
h2 "[php74] Configure and install GD, JSON, MEMCACHE, ICONV"
apk add --no-cache --virtual php7-gd php7-json php7-pecl-memcache php7-iconv
;;
* )
h2 "Configure and install GD"
docker-php-ext-configure gd \
--with-freetype-dir=/usr/lib/ \
--with-png-dir=/usr/lib/ \
--with-jpeg-dir=/usr/lib/ \
--with-gd
docker-php-ext-install -j$(nproc) gd
h2 "Install json module"
docker-php-ext-install -j$(nproc) json
break
esac
h1 "Install PHP modules"
for i in "${!PHP_MODULES[@]}"
do
num=$((i+1))
h1 " (${num}/${#PHP_MODULES[@]}) > Install module: ${PHP_MODULES[$i]}"
h2 " Check modules"
docker-php-ext-install -j$(nproc) ${PHP_MODULES[$i]}
done