FROM openshift/golang-builder:1.12 AS builder
ENV OS_GIT_MAJOR=4 OS_GIT_MINOR=3 OS_GIT_PATCH=5 OS_GIT_VERSION=4.3.5-202003020549-c086098 OS_GIT_TREE_STATE=clean SOURCE_GIT_COMMIT=c086098da5f01ab9565bdda772d3459bea2913f2 SOURCE_GIT_TAG=golang-github-prometheus-prometheus-4.0.0-0.102.0-443-gc086098d SOURCE_GIT_URL=https://github.com/openshift/prometheus SOURCE_DATE_EPOCH=1576074003 OS_GIT_COMMIT=c086098 BUILD_VERSION=v4.3.5 BUILD_RELEASE=202003020549
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/ose-base:ubi7
ENV OS_GIT_MAJOR=4 OS_GIT_MINOR=3 OS_GIT_PATCH=5 OS_GIT_VERSION=4.3.5-202003020549-c086098 OS_GIT_TREE_STATE=clean SOURCE_GIT_COMMIT=c086098da5f01ab9565bdda772d3459bea2913f2 SOURCE_GIT_TAG=golang-github-prometheus-prometheus-4.0.0-0.102.0-443-gc086098d SOURCE_GIT_URL=https://github.com/openshift/prometheus SOURCE_DATE_EPOCH=1576074003 OS_GIT_COMMIT=c086098 BUILD_VERSION=v4.3.5 BUILD_RELEASE=202003020549

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}/tsdbtool                              /bin/tsdb
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.3.5" \
        License="ASL 2.0" \
        vendor="Red Hat" \
        name="openshift/ose-prometheus" \
        com.redhat.component="golang-github-prometheus-prometheus-container" \
        release="202003020549" \
        io.openshift.build.commit.id="c086098da5f01ab9565bdda772d3459bea2913f2" \
        io.openshift.build.source-location="https://github.com/openshift/prometheus" \
        io.openshift.build.commit.url="https://github.com/openshift/prometheus/commit/c086098da5f01ab9565bdda772d3459bea2913f2"

