Installing imagick on PHP 8.1 docker

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 | 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


Thank you for sharing, we always appreciate any information shared by our community.

Kind Regards
Owen Oliver