Why does deploying to production fail using Vapor - Unable to load dynamic library 'imagick'

1.2k Views Asked by At

I have a basic Laravel 7.x application that I'm trying to deploy to production using Vapor. when it reaches the Running Deployment Hooks section of deployment it fails with the following message.

An error occurred during deployment.

Message: Deployment hook failed.

A deployment hook failed. You may review its logs using the hook:log command.

I checked the logs for more details and it suggests there is an issue with imagick

Loaded Composer autoload filePreparing to add secrets to runtimePreparing to boot FPMEnsuring ready to start FPMStarting FPM Process...[14-Sep-2020 00:57:50] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'imagick' (tried: /opt/bin/imagick (/opt/bin/imagick: cannot open shared object file: No such file or directory), /opt/bin/imagick.so (libMagickWand.so.5: cannot open shared object file: No such file or directory)) in Unknown on line 0

1

There are 1 best solutions below

0
On

Starting today, you can add Imagick support to your projects by importing an external Lambda layer. This change decreases the size of the default Vapor runtime layer and allows customers that don't use Imagick to upload larger applications without worrying about AWS Lambda application size limits.

You can add it like this in your vapor.yml:

environments:
    staging:
        layers:
          - vapor:php-7.4
          - vapor:php-7.4:imagick

Source: https://blog.laravel.com/vapor-adding-imagick-as-a-separate-lambda-layer