https://github.com/mlocati/docker-php-extension-installer can also be an approach. Your Dockerfile then might look like:
FROM php:8.2-fpm
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
RUN install-php-extensions @composer http (and other extensions supported by the installer)
...