FROM openshift/golang-builder:1.12 AS builder
ENV __doozer=update BUILD_RELEASE=202006230600.p0 BUILD_VERSION=v4.2.36 OS_GIT_MAJOR=4 OS_GIT_MINOR=2 OS_GIT_PATCH=36 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.2.36-202006230600.p? 
ENV __doozer=merge OS_GIT_COMMIT=52650c0 OS_GIT_VERSION=4.2.36-202006230600.p?-52650c0 SOURCE_DATE_EPOCH=1571711754 SOURCE_GIT_COMMIT=52650c0fd84e82e20b5dcfa283c69a9e7ada16cb SOURCE_GIT_TAG=golang-github-prometheus-prometheus-4.0.0-0.102.0-482-g52650c0f SOURCE_GIT_URL=https://github.com/openshift/prometheus 
WORKDIR /go/src/github.com/prometheus/prometheus
COPY . .
RUN if yum install -y prometheus-promu; then export BUILD_PROMU=false; fi && make build 

FROM openshift/ose-base:ubi7
ENV __doozer=update BUILD_RELEASE=202006230600.p0 BUILD_VERSION=v4.2.36 OS_GIT_MAJOR=4 OS_GIT_MINOR=2 OS_GIT_PATCH=36 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.2.36-202006230600.p? 
ENV __doozer=merge OS_GIT_COMMIT=52650c0 OS_GIT_VERSION=4.2.36-202006230600.p?-52650c0 SOURCE_DATE_EPOCH=1571711754 SOURCE_GIT_COMMIT=52650c0fd84e82e20b5dcfa283c69a9e7ada16cb SOURCE_GIT_TAG=golang-github-prometheus-prometheus-4.0.0-0.102.0-482-g52650c0f SOURCE_GIT_URL=https://github.com/openshift/prometheus 

ARG FROM_DIRECTORY=/go/src/github.com/prometheus/prometheus
COPY --from=builder ${FROM_DIRECTORY}/prometheus                            /bin/prometheus
COPY --from=builder ${FROM_DIRECTORY}/promtool                              /bin/promtool
COPY --from=builder ${FROM_DIRECTORY}/documentation/examples/prometheus.yml /etc/prometheus/prometheus.yml
COPY --from=builder ${FROM_DIRECTORY}/console_libraries/                    /usr/share/prometheus/console_libraries/
COPY --from=builder ${FROM_DIRECTORY}/consoles/                             /usr/share/prometheus/consoles/

RUN ln -s /usr/share/prometheus/console_libraries /usr/share/prometheus/consoles/ /etc/prometheus/
RUN mkdir -p /prometheus && \
    chgrp -R 0 /etc/prometheus /prometheus && \
    chmod -R g=u /etc/prometheus /prometheus

USER       nobody
EXPOSE     9090
WORKDIR    /prometheus
ENTRYPOINT [ "/bin/prometheus" ]
CMD        [ "--config.file=/etc/prometheus/prometheus.yml", \
             "--storage.tsdb.path=/prometheus", \
             "--web.console.libraries=/usr/share/prometheus/console_libraries", \
             "--web.console.templates=/usr/share/prometheus/consoles" ]

LABEL \
        io.k8s.display-name="Prometheus" \
        io.k8s.description="This is the Prometheus base image." \
        io.openshift.tags="openshift,prometheus" \
        maintainer="OpenShift Development <dev@lists.openshift.redhat.com>" \
        version="v4.2.36" \
        License="ASL 2.0" \
        vendor="Red Hat" \
        name="openshift/ose-prometheus" \
        com.redhat.component="golang-github-prometheus-prometheus-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="Monitoring" \
        release="202006230600.p0" \
        io.openshift.build.commit.id="52650c0fd84e82e20b5dcfa283c69a9e7ada16cb" \
        io.openshift.build.source-location="https://github.com/openshift/prometheus" \
        io.openshift.build.commit.url="https://github.com/openshift/prometheus/commit/52650c0fd84e82e20b5dcfa283c69a9e7ada16cb"

