FROM openshift/golang-builder:rhel_8_golang_1.15 AS builder
ENV __doozer=update BUILD_RELEASE=202109210902.p0.git.cb5e53c.assembly.stream BUILD_VERSION=v4.7.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=7 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.7.0-202109210902.p0.git.cb5e53c.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=cb5e53c OS_GIT_VERSION=4.7.0-202109210902.p0.git.cb5e53c.assembly.stream-cb5e53c SOURCE_DATE_EPOCH=1610666920 SOURCE_GIT_COMMIT=cb5e53cdfedfee185feffcec13304dda87ff3055 SOURCE_GIT_TAG=golang-github-prometheus-prometheus-4.0.0-0.102.0-2992-gcb5e53cdf SOURCE_GIT_URL=https://github.com/openshift/prometheus 
WORKDIR /go/src/github.com/prometheus/prometheus
COPY . .
# NOTE(spasquie): the 'build' target regenerates the ReactJS code and the Go
# assets on the fly.  Build environments don't have access to Yarn and external
# package repositories so we use the 'common-build' target instead.
# It means that every time we update to a new Prometheus version, 'make assets'
# should be run locally and the resulting file (web/ui/assets_vfsdata.go)
# should be committed to the repository.
RUN if yum install -y prometheus-promu; then export BUILD_PROMU=false; fi && make common-build

FROM openshift/base-rhel8:v4.7.0.20210921.092550
ENV __doozer=update BUILD_RELEASE=202109210902.p0.git.cb5e53c.assembly.stream BUILD_VERSION=v4.7.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=7 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.7.0-202109210902.p0.git.cb5e53c.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=cb5e53c OS_GIT_VERSION=4.7.0-202109210902.p0.git.cb5e53c.assembly.stream-cb5e53c SOURCE_DATE_EPOCH=1610666920 SOURCE_GIT_COMMIT=cb5e53cdfedfee185feffcec13304dda87ff3055 SOURCE_GIT_TAG=golang-github-prometheus-prometheus-4.0.0-0.102.0-2992-gcb5e53cdf 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" \
        summary="The Prometheus monitoring system and time series database." \
        maintainer="OpenShift Monitoring Team <team-monitoring@redhat.com>" \
        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="202109210902.p0.git.cb5e53c.assembly.stream" \
        io.openshift.build.commit.id="cb5e53cdfedfee185feffcec13304dda87ff3055" \
        io.openshift.build.source-location="https://github.com/openshift/prometheus" \
        io.openshift.build.commit.url="https://github.com/openshift/prometheus/commit/cb5e53cdfedfee185feffcec13304dda87ff3055" \
        version="v4.7.0"

