10 months ago
I'm trying to run a Laravel 11 app that uses imagemagick to shrink images.
I did installed imagemagick through apt-get and using nix pkg php82Extensions.imagick but got no success, always get "Imagick PHP extension must be installed to use this driver." back when I try to run it.
Currently I have this nixpacks config set:
[variables]
UPLOAD_MAX_FILESIZE = '100M'
POST_MAX_SIZE = '100M'
[phases.setup]
aptPkgs = ["...", "jpegoptim", "optipng", "pngquant", "gifsicle", "webp", "libavif-bin", "php-mbstring", "autoconf", "g++", "imagemagick", "libtool", "make"]
nixPkgs = ["...", "php82Extensions.imagick"]
cmds = ['UPLOAD_INI_PATH=$(find /nix/store/*-php-*/lib -name php.ini -print0 | head -z -n 1 | rev | cut -c 9- | rev)/upload.ini; echo "upload_max_filesize=${UPLOAD_MAX_FILESIZE};" >> $UPLOAD_INI_PATH; echo "post_max_size=${POST_MAX_SIZE};" >> $UPLOAD_INI_PATH']
[phases.prepare]
dependsOn = ["build"]
cmds = ["php artisan storage:link"]
7 Replies
10 months ago
Same issue here.
[phases.setup]
aptPkgs = ['imagemagick', 'libssl-dev', 'libmagickwand-dev', 'libimagemagick-dev']
nixPkgs = ['php81', 'php81Extensions.imagick', 'nginx', 'curl', 'nodejs', 'imagemagick', 'openssl', 'composer']
PHP reports the extension is not installed.
10 months ago
I don't have experience with PHP but you both would likely have better luck developing a Dockerfile to run your app how you want and with that extensions you want, than configuring nixpacks.
10 months ago
Okay, perhaps I will try that. Thanks.
10 months ago
If I could, I would help you write that Dockerfile but I just don't have the PHP experience needed.
10 months ago
For Nixpacks, you also need to install them in the composer.json
file. More information is found here, nixpacks.com/docs/providers/php.
10 months ago
Hey Jr. I will test that.
Tried rolling my own docker file. Funny is that it was working locally and same package not found was happening on the deploy.
10 months ago
Thanks both. I was able to get it working with a Dockerfile. I may investigate the Nixpacks approach in the future but need to get this to production by tomorrow :)
Status changed to Solved jr • 10 months ago