FROM openshift/golang-builder:rhel_8_golang_1.15 AS builder
ENV __doozer=update BUILD_RELEASE=202107070256.p0.git.f97d7ec BUILD_VERSION=v4.6.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=6 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.6.0-202107070256.p0.git.f97d7ec SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=f97d7ec OS_GIT_VERSION=4.6.0-202107070256.p0.git.f97d7ec-f97d7ec SOURCE_DATE_EPOCH=1610697867 SOURCE_GIT_COMMIT=f97d7ec81d51522546a076095c141b2d1eb21030 SOURCE_GIT_TAG=golang-github-prometheus-prometheus-4.0.0-0.102.0-2901-gf97d7ec81 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.6.0.20210707.033320
ENV __doozer=update BUILD_RELEASE=202107070256.p0.git.f97d7ec BUILD_VERSION=v4.6.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=6 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.6.0-202107070256.p0.git.f97d7ec SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=f97d7ec OS_GIT_VERSION=4.6.0-202107070256.p0.git.f97d7ec-f97d7ec SOURCE_DATE_EPOCH=1610697867 SOURCE_GIT_COMMIT=f97d7ec81d51522546a076095c141b2d1eb21030 SOURCE_GIT_TAG=golang-github-prometheus-prometheus-4.0.0-0.102.0-2901-gf97d7ec81 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="202107070256.p0.git.f97d7ec" \
        io.openshift.build.commit.id="f97d7ec81d51522546a076095c141b2d1eb21030" \
        io.openshift.build.source-location="https://github.com/openshift/prometheus" \
        io.openshift.build.commit.url="https://github.com/openshift/prometheus/commit/f97d7ec81d51522546a076095c141b2d1eb21030" \
        version="v4.6.0"

