fix(IMAGEMAGICK extension): implement building extension for PHP 8.0 from source

We need to build imagemagick extension from sources due the latest version, that supports PHP 8.0 has not been released to PECL.

Closes #2861
This commit is contained in:
Pavel Savushkin 2021-03-12 03:20:32 +02:00
parent fd203fba04
commit 67cc72da62
No known key found for this signature in database
GPG Key ID: BD2EDA3E125300DD
6 changed files with 98 additions and 13 deletions

View File

@ -152,6 +152,7 @@ services:
- YARN_VERSION=${WORKSPACE_YARN_VERSION}
- DRUSH_VERSION=${WORKSPACE_DRUSH_VERSION}
- AST_VERSION=${WORKSPACE_AST_VERSION}
- IMAGEMAGICK_VERSION=${WORKSPACE_IMAGEMAGICK_VERSION}
- TZ=${WORKSPACE_TIMEZONE}
- BLACKFIRE_CLIENT_ID=${BLACKFIRE_CLIENT_ID}
- BLACKFIRE_CLIENT_TOKEN=${BLACKFIRE_CLIENT_TOKEN}
@ -261,6 +262,7 @@ services:
- DOWNGRADE_OPENSSL_TLS_AND_SECLEVEL=${PHP_DOWNGRADE_OPENSSL_TLS_AND_SECLEVEL}
- PUID=${PHP_FPM_PUID}
- PGID=${PHP_FPM_PGID}
- IMAGEMAGICK_VERSION=${PHP_FPM_IMAGEMAGICK_VERSION}
- LOCALE=${PHP_FPM_DEFAULT_LOCALE}
- PHP_FPM_NEW_RELIC=${PHP_FPM_NEW_RELIC}
- PHP_FPM_NEW_RELIC_KEY=${PHP_FPM_NEW_RELIC_KEY}
@ -325,6 +327,7 @@ services:
- INSTALL_XMLRPC=${PHP_WORKER_INSTALL_XMLRPC}
- PUID=${PHP_WORKER_PUID}
- PGID=${PHP_WORKER_PGID}
- IMAGEMAGICK_VERSION=${PHP_WORKER_IMAGEMAGICK_VERSION}
volumes:
- ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG}
- ./php-worker/supervisord.d:/etc/supervisord.d
@ -358,6 +361,7 @@ services:
- INSTALL_AUDIOWAVEFORM=${LARAVEL_HORIZON_INSTALL_AUDIOWAVEFORM}
- PUID=${LARAVEL_HORIZON_PUID}
- PGID=${LARAVEL_HORIZON_PGID}
- IMAGEMAGICK_VERSION=${LARAVEL_HORIZON_IMAGEMAGICK_VERSION}
volumes:
- ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}
- ./laravel-horizon/supervisord.d:/etc/supervisord.d

View File

@ -157,6 +157,7 @@ WORKSPACE_INSTALL_POWERLINE=false
WORKSPACE_INSTALL_SUPERVISOR=false
WORKSPACE_INSTALL_IMAGE_OPTIMIZERS=false
WORKSPACE_INSTALL_IMAGEMAGICK=false
WORKSPACE_IMAGEMAGICK_VERSION=latest
WORKSPACE_INSTALL_TERRAFORM=false
WORKSPACE_INSTALL_DUSK_DEPS=false
WORKSPACE_INSTALL_PG_CLIENT=false
@ -204,6 +205,7 @@ PHP_FPM_INSTALL_BCMATH=true
PHP_FPM_INSTALL_MYSQLI=true
PHP_FPM_INSTALL_INTL=true
PHP_FPM_INSTALL_IMAGEMAGICK=true
PHP_FPM_IMAGEMAGICK_VERSION=latest
PHP_FPM_INSTALL_OPCACHE=true
PHP_FPM_INSTALL_IMAGE_OPTIMIZERS=true
PHP_FPM_INSTALL_PHPREDIS=true
@ -272,6 +274,7 @@ PHP_FPM_NEW_RELIC_APP_NAME=app_name
PHP_WORKER_INSTALL_BZ2=false
PHP_WORKER_INSTALL_GD=false
PHP_WORKER_INSTALL_IMAGEMAGICK=false
PHP_WORKER_IMAGEMAGICK_VERSION=latest
PHP_WORKER_INSTALL_GMP=false
PHP_WORKER_INSTALL_PGSQL=false
PHP_WORKER_INSTALL_BCMATH=false
@ -312,6 +315,7 @@ LARAVEL_HORIZON_INSTALL_BZ2=false
LARAVEL_HORIZON_INSTALL_GD=false
LARAVEL_HORIZON_INSTALL_GMP=false
LARAVEL_HORIZON_INSTALL_IMAGEMAGICK=false
LARAVEL_HORIZON_IMAGEMAGICK_VERSION=latest
LARAVEL_HORIZON_INSTALL_SOCKETS=false
LARAVEL_HORIZON_INSTALL_YAML=false
LARAVEL_HORIZON_INSTALL_ZIP_ARCHIVE=false

View File

@ -74,10 +74,28 @@ RUN if [ ${INSTALL_GMP} = true ]; then \
#Install ImageMagick package:
ARG INSTALL_IMAGEMAGICK=false
ARG IMAGEMAGICK_VERSION=latest
ENV IMAGEMAGICK_VERSION ${IMAGEMAGICK_VERSION}
RUN set -eux; \
if [ ${INSTALL_IMAGEMAGICK} = true ]; then \
apk add --update --no-cache imagemagick-dev; \
pecl install imagick; \
if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \
apk add --update --no-cache git && \
cd /tmp && \
if [ ${IMAGEMAGICK_VERSION} = "latest" ]; then \
git clone https://github.com/Imagick/imagick; \
else \
git clone --branch ${IMAGEMAGICK_VERSION} https://github.com/Imagick/imagick; \
fi && \
cd imagick && \
phpize && \
./configure && \
make && \
make install && \
rm -r /tmp/imagick; \
else \
pecl install imagick; \
fi && \
docker-php-ext-enable imagick; \
php -m | grep -q 'imagick'; \
fi

View File

@ -684,10 +684,28 @@ RUN if [ ${INSTALL_IMAGE_OPTIMIZERS} = true ]; then \
USER root
ARG INSTALL_IMAGEMAGICK=false
ARG IMAGEMAGICK_VERSION=latest
ENV IMAGEMAGICK_VERSION ${IMAGEMAGICK_VERSION}
RUN if [ ${INSTALL_IMAGEMAGICK} = true ]; then \
apt-get install -y libmagickwand-dev imagemagick && \
pecl install imagick && \
if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \
apt-get install -y git && \
cd /tmp && \
if [ ${IMAGEMAGICK_VERSION} = "latest" ]; then \
git clone https://github.com/Imagick/imagick; \
else \
git clone --branch ${IMAGEMAGICK_VERSION} https://github.com/Imagick/imagick; \
fi && \
cd imagick && \
phpize && \
./configure && \
make && \
make install && \
rm -r /tmp/imagick; \
else \
pecl install imagick; \
fi && \
docker-php-ext-enable imagick \
;fi

View File

@ -69,11 +69,31 @@ RUN if [ ${INSTALL_GD} = true ]; then \
#Install ImageMagick:
ARG INSTALL_IMAGEMAGICK=false
RUN if [ ${INSTALL_IMAGEMAGICK} = true ]; then \
apk add --update imagemagick-dev imagemagick; \
pecl install imagick; \
docker-php-ext-enable imagick \
;fi
ARG IMAGEMAGICK_VERSION=latest
ENV IMAGEMAGICK_VERSION ${IMAGEMAGICK_VERSION}
RUN set -eux; \
if [ ${INSTALL_IMAGEMAGICK} = true ]; then \
apk add --update --no-cache imagemagick-dev; \
if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \
apk add --update --no-cache git && \
cd /tmp && \
if [ ${IMAGEMAGICK_VERSION} = "latest" ]; then \
git clone https://github.com/Imagick/imagick; \
else \
git clone --branch ${IMAGEMAGICK_VERSION} https://github.com/Imagick/imagick; \
fi && \
cd imagick && \
phpize && \
./configure && \
make && \
make install && \
rm -r /tmp/imagick; \
else \
pecl install imagick; \
fi && \
docker-php-ext-enable imagick; \
php -m | grep -q 'imagick'; \
fi
#Install GMP package:
ARG INSTALL_GMP=false

View File

@ -1200,9 +1200,30 @@ USER laradock
USER root
ARG INSTALL_IMAGEMAGICK=false
ARG IMAGEMAGICK_VERSION=latest
ENV IMAGEMAGICK_VERSION ${IMAGEMAGICK_VERSION}
RUN if [ ${INSTALL_IMAGEMAGICK} = true ]; then \
apt-get install -y imagemagick php-imagick \
apt-get install -y libmagickwand-dev imagemagick && \
if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \
apt-get install -y git && \
cd /tmp && \
if [ ${IMAGEMAGICK_VERSION} = "latest" ]; then \
git clone https://github.com/Imagick/imagick; \
else \
git clone --branch ${IMAGEMAGICK_VERSION} https://github.com/Imagick/imagick; \
fi && \
cd imagick && \
phpize && \
./configure && \
make && \
make install && \
rm -r /tmp/imagick; \
else \
pecl install imagick; \
fi && \
echo "extension=imagick.so" >> /etc/php/${LARADOCK_PHP_VERSION}/mods-available/imagick.ini && \
ln -s /etc/php/${LARADOCK_PHP_VERSION}/mods-available/imagick.ini /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/20-imagick.ini \
;fi
###########################################################################