my homelab is using this setup, I configured porkbun API, compiled caddy with the DNS challenge plugin and configured it.
- https://codeberg.org/Disco-Robot/homelab
- https://codeberg.org/Disco-Robot/homelab/src/branch/master/ansible/coreTasks/caddy.yaml
- https://codeberg.org/Disco-Robot/homelab/src/branch/master/configs/caddyfile.j2
I am using ansible with jinja templates there, if you are not familiar with it or have any doubt feel free to ask.