Below are my build instructions for GnuPG 2.2.20, released on April 1st, 2020. These instructions are built for a headless Centos 7 LTS server (specificaly the offical centos docker image https://hub.docker.com/_/centos).
You use the below install script to install GnuPG 2.2.x by running the following commands:
# if you are root in a docker image:
curl -OL "https://gist.githubusercontent.com/MirkoManojlovic/56f563271eca43c67606b5991f32edd4/raw/1358b87214312e41fd2e28a49a34869a699fb06f/install-gnupg22.sh" && bash ./install-gnupg22.sh
# else if you need to sudo to do the installs: