ARG PHP_APACHE_TAG=2.4.69-8.5.11
FROM registry.brunner.ninja/feedc0de/php-apache:${PHP_APACHE_TAG}

ARG PHPPGADMIN_VERSION=7.14.7

RUN curl --fail --show-error --location \
      --output /tmp/phppgadmin.tar.gz \
      "https://github.com/ReimuHakurei/phpPgAdmin/archive/refs/tags/v${PHPPGADMIN_VERSION}-mod.tar.gz" \
 && install -d /usr/share/webapps/phppgadmin /etc/phppgadmin \
 && tar --extract --gzip --file /tmp/phppgadmin.tar.gz \
      --strip-components=1 --directory /usr/share/webapps/phppgadmin \
 && cp /usr/share/webapps/phppgadmin/conf/config.inc.php-dist \
      /etc/phppgadmin/config.inc.php \
 && rm -f /usr/share/webapps/phppgadmin/conf/config.inc.php \
 && ln -s /etc/phppgadmin/config.inc.php \
      /usr/share/webapps/phppgadmin/conf/config.inc.php \
 && rm /tmp/phppgadmin.tar.gz

COPY phppgadmin.conf /etc/httpd/conf/extra/phppgadmin.conf

RUN printf '%s\n' 'Include conf/extra/phppgadmin.conf' >> /etc/httpd/conf/httpd.conf
