After your remark, I found that vault-agent have an option to run a command to run composer dump-env prod when .env is actually modified.
command(string: "") - This is the optional command to run when the template is rendered. The command will only run if the resulting template changes. The command must return within 30s (configurable), and it must have a successful exit code. Vault Agent is not a replacement for a process monitor or init system.
After your remark, I found that vault-agent have an option to run a command to run
composer dump-env prod
when.env
is actually modified.