ローカル環境で帳票を出力しようしたときに、GDが入っていないエラーで怒られたのでGDをインストールするコマンドを忘備録として記事化しました。
The PHP GD extension is required, but is not installed. in /application/vendor/dompdf/dompdf/lib/Cpdf.php:5825
手順は以下の通りです。
1. コンテナに入る
docker exec -it <コンテナid> /bin/sh
2. パッケージリストの更新と必要なパッケージのインストール
apk update && apk add --no-cache \
freetype-dev \
jpeg-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd
3. サービスの再起動(必要に応じて)
service nginx restart # または systemctl restart nginx
service php-fpm restart # または systemctl restart php-fpm
上記の手順により、PHP GD拡張がインストールされ、有効にすることができます。