Skip to content

Commit

Permalink
Use phpize to install tgz extensions instead of pecl
Browse files Browse the repository at this point in the history
  • Loading branch information
yeszao committed Oct 7, 2019
1 parent caf89f4 commit d5ef6b4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 29 deletions.
2 changes: 1 addition & 1 deletion services/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN if [ "${CONTAINER_PACKAGE_URL}" != "" ]; then \


RUN if [ "${PHP_EXTENSIONS}" != "" ]; then \
apk add --no-cache autoconf g++ libtool make curl-dev libxml2-dev libevent-dev linux-headers; \
apk add --no-cache autoconf g++ libtool make curl-dev linux-headers; \
fi


Expand Down
79 changes: 51 additions & 28 deletions services/php/extensions/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ echo
export EXTENSIONS=",${PHP_EXTENSIONS},"


#
# Check if current php version is greater than or equal to
# specific version.
#
# For example, to check if current php is greater than or
# equal to PHP 7.0:
#
# isPhpVersionGreaterOrEqual 7 0
#
# Param 1: Specific PHP Major version
# Param 2: Specific PHP Minor version
# Return : 1 if greater than or equal to, 0 if less than
#
isPhpVersionGreaterOrEqual()
{
local PHP_MAJOR_VERSION=$(php -r "echo PHP_MAJOR_VERSION;")
Expand All @@ -30,6 +43,28 @@ isPhpVersionGreaterOrEqual()
}


#
# Install extension from package file(.tgz),
# For example:
#
# installExtensionFromTgz redis-4.1.1
#
# Param 1: Package name with version
# Param 2: enable options
#
installExtensionFromTgz()
{
tgzName=$1
extensionName="${tgzName%%-*}"

mkdir ${extensionName}
tar -xf ${tgzName}.tgz -C ${extensionName} --strip-components=1
( cd ${extensionName} && phpize && ./configure && make ${MC} && make install )

docker-php-ext-enable ${extensionName} $2
}


if [[ -z "${EXTENSIONS##*,pdo_mysql,*}" ]]; then
echo "---------- Install pdo_mysql ----------"
docker-php-ext-install ${MC} pdo_mysql
Expand Down Expand Up @@ -178,24 +213,25 @@ fi

if [[ -z "${EXTENSIONS##*,soap,*}" ]]; then
echo "---------- Install soap ----------"
apk add --no-cache libxml2-dev
docker-php-ext-install ${MC} soap
fi

if [[ -z "${EXTENSIONS##*,xsl,*}" ]]; then
echo "---------- Install xsl ----------"
apk add --no-cache libxslt-dev
apk add --no-cache libxml2-dev libxslt-dev
docker-php-ext-install ${MC} xsl
fi

if [[ -z "${EXTENSIONS##*,xmlrpc,*}" ]]; then
echo "---------- Install xmlrpc ----------"
apk add --no-cache libxslt-dev
apk add --no-cache libxml2-dev libxslt-dev
docker-php-ext-install ${MC} xmlrpc
fi

if [[ -z "${EXTENSIONS##*,wddx,*}" ]]; then
echo "---------- Install wddx ----------"
apk add --no-cache libxslt-dev
apk add --no-cache libxml2-dev libxslt-dev
docker-php-ext-install ${MC} wddx
fi

Expand Down Expand Up @@ -356,9 +392,7 @@ if [[ -z "${EXTENSIONS##*,mysql,*}" ]]; then
isPhpVersionGreaterOrEqual 7 0

if [[ "$?" = "1" ]]; then
echo
echo "---------- mysql was REMOVED from PHP 7.0.0 ----------"
echo
else
echo "---------- Install mysql ----------"
docker-php-ext-install ${MC} mysql
Expand All @@ -381,14 +415,12 @@ fi
if [[ -z "${EXTENSIONS##*,amqp,*}" ]]; then
echo "---------- Install amqp ----------"
apk add --no-cache rabbitmq-c-dev
printf "\n" | pecl install amqp-1.9.4.tgz
docker-php-ext-enable amqp
installExtensionFromTgz amqp-1.9.4
fi

if [[ -z "${EXTENSIONS##*,redis,*}" ]]; then
echo "---------- Install redis ----------"
printf "\n" | pecl install redis-4.1.1.tgz
docker-php-ext-enable redis
installExtensionFromTgz redis-4.1.1
fi

if [[ -z "${EXTENSIONS##*,memcached,*}" ]]; then
Expand All @@ -410,16 +442,15 @@ if [[ -z "${EXTENSIONS##*,xdebug,*}" ]]; then
isPhpVersionGreaterOrEqual 7 0

if [[ "$?" = "1" ]]; then
printf "\n" | pecl install xdebug-2.6.1.tgz
installExtensionFromTgz xdebug-2.6.1
else
printf "\n" | pecl install xdebug-2.5.5.tgz
installExtensionFromTgz xdebug-2.5.5
fi

docker-php-ext-enable xdebug
fi

if [[ -z "${EXTENSIONS##*,event,*}" ]]; then
echo "---------- Install event ----------"
apk add --no-cache libevent-dev
export is_sockets_installed=$(php -r "echo extension_loaded('sockets');")

if [[ "${is_sockets_installed}" = "" ]]; then
Expand All @@ -428,14 +459,12 @@ if [[ -z "${EXTENSIONS##*,event,*}" ]]; then
fi

echo "---------- Install event again ----------"
printf "\n" | pecl install event-2.5.3.tgz
docker-php-ext-enable --ini-name event.ini event
installExtensionFromTgz event-2.5.3 "--ini-name event.ini"
fi

if [[ -z "${EXTENSIONS##*,mongodb,*}" ]]; then
echo "---------- Install mongodb ----------"
printf "\n" | pecl install mongodb-1.5.5.tgz
docker-php-ext-enable mongodb
installExtensionFromTgz mongodb-1.5.5
fi

if [[ -z "${EXTENSIONS##*,yaf,*}" ]]; then
Expand All @@ -444,28 +473,22 @@ if [[ -z "${EXTENSIONS##*,yaf,*}" ]]; then

if [[ "$?" = "1" ]]; then
printf "\n" | pecl install yaf
docker-php-ext-enable yaf
else
# install by pecl may cause error:
# can't create directory 'configs/.libs': No such file or directory
mkdir yaf
tar -xf yaf-2.3.5.tgz -C yaf --strip-components=1
( cd yaf && phpize && ./configure && make ${MC} && make install )
installExtensionFromTgz yaf-2.3.5
fi

docker-php-ext-enable yaf
fi


if [[ -z "${EXTENSIONS##*,swoole,*}" ]]; then
echo "---------- Install swoole ----------"
isPhpVersionGreaterOrEqual 7 0

if [[ "$?" = "1" ]]; then
printf "\n" | pecl install swoole-4.4.2.tgz
installExtensionFromTgz swoole-4.4.2
else
printf "\n" | pecl install swoole-2.0.11.tgz
installExtensionFromTgz swoole-2.0.11
fi

docker-php-ext-enable swoole
fi

if [[ -z "${EXTENSIONS##*,zip,*}" ]]; then
Expand Down

0 comments on commit d5ef6b4

Please sign in to comment.