Add DFSET & PACKAGER ARGs to Exporter Dockerfile (#1827)
Add DFSET & PACKAGER ARGs to Exporter Dockerfile (#1827)

Adds the DFSET and PACKAGER ARG instructions to the
crunchy-postgres-exporter Dockerfile as needed to ensure the proper
detection of "rhel" or "centos" for the DFSET env var, and the use of
the proper package manager when installing the packages required by the
Crunchy PostgreSQL Exporter.
ARG BASEOS
ARG BASEVER
ARG PREFIX
FROM ${PREFIX}/pgo-base:${BASEOS}-${BASEVER}

ARG PGVERSION

LABEL name="crunchy-postgres-exporter" \
summary="Metrics exporter for PostgreSQL" \
description="When run with the crunchy-postgres family of containers, crunchy-postgres-exporter reads the PostgreSQL data directory and has a SQL interface to a database to allow for metrics collection." \
io.k8s.description="Crunchy PostgreSQL Exporter" \
io.k8s.display-name="Crunchy PostgreSQL Exporter" \
io.openshift.tags="postgresql,postgres,monitoring,database,crunchy"

RUN if [ "$DFSET" = "centos" ] ; then \
${PACKAGER} -y install epel-release \
    && ${PACKAGER} install -y \
        --setopt=skip_missing_names_on_install=False \
        postgresql${PGVERSION} \
    && ${PACKAGER} -y clean all ; \
fi

RUN if [ "$DFSET" = "rhel" ] ; then \
${PACKAGER} install -y \
        --setopt=skip_missing_names_on_install=False \
        postgresql${PGVERSION} \
    && ${PACKAGER} -y clean all ; \
fi

RUN mkdir -p /opt/cpm/bin /opt/cpm/conf

ADD postgres_exporter.tar.gz /opt/cpm/bin
ADD tools/pgmonitor/exporter/postgres /opt/cpm/conf
ADD bin/crunchy-postgres-exporter /opt/cpm/bin
ADD bin/uid_daemon.sh /opt/cpm/bin

RUN chgrp -R 0 /opt/cpm/bin /opt/cpm/conf && \
chmod -R g=u /opt/cpm/bin/ opt/cpm/conf

# postgres_exporter
EXPOSE 9187

RUN chmod g=u /etc/passwd

# The VOLUME directive must appear after all RUN directives to ensure the proper
# volume permissions are applied when building the image
VOLUME ["/conf"]

ENTRYPOINT ["/opt/cpm/bin/uid_daemon.sh"]

USER 2

CMD ["/opt/cpm/bin/start.sh"]
