Installing Imagick on php8 with Docker for Laravel Vapor

8.1k Views Asked by At

I see some posts to get Imagick working on php 8 using a Docker image with a commit from the Imagick repo. Imagick is not officially php 8 ready as it doesn't pass other tests but does work on php 8 as is.

Need a pointer to get this working on my local and then to Laravel Vapor. This is meant to work in the Dockerfile but docker-php-ext-install is not found when running sail build

Update: This works for Vapor. staging.dockerfile should look like this:

FROM laravelphp/vapor:php80

ARG IMAGICK_LAST_COMMIT='448c1cd0d58ba2838b9b6dff71c9b7e70a401b90'
RUN  mkdir -p /usr/src/php/ext/imagick \
    && curl -fsSL https://github.com/Imagick/imagick/archive/${IMAGICK_LAST_COMMIT}.tar.gz | tar xvz -C /usr/src/php/ext/imagick --strip 1 \
    && sed -i s/'#define PHP_IMAGICK_VERSION    "@PACKAGE_VERSION@"'/'#define PHP_IMAGICK_VERSION    "3.4.5rc"'/ /usr/src/php/ext/imagick/php_imagick.h \
    && docker-php-ext-configure imagick \
    && docker-php-ext-install imagick 

COPY . /var/task

So the issue I still have is getting this into my local. Using sail build

1

There are 1 best solutions below

0
On

Imagick is now available for PHP8 through pecl. http://pecl.php.net/package/imagick/3.5.0

With the official php alpine a simple setup would look like this:

FROM php:8-fpm-alpine

RUN apk add --no-cache ${PHPIZE_DEPS} imagemagick imagemagick-dev

RUN pecl install -o -f imagick\
    &&  docker-php-ext-enable imagick

RUN apk del --no-cache ${PHPIZE_DEPS}