After a number of searches, this is my working file to install PHP imagick extension on a docker container with the image: cimg/php:8.1-node.
Removing the policy.xml will get rid of the security error.
- run:
name: install imagick
command: sudo apt-get update && sudo apt-get install -y libmagickwand-dev --no-install-recommends && sudo rm -rf /var/lib/apt/lists/*
- run: sudo mkdir -p /usr/src/php/ext/imagick
- run: sudo chmod 777 /usr/src/php/ext/imagick
- run: sudo curl -fsSL https://github.com/Imagick/imagick/archive/refs/tags/3.7.0.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1
- run: sudo docker-php-ext-install imagick
- run: sudo rm /etc/ImageMagick-6/policy.xml