FROM openshift/golang-builder:1.11 AS builder
ENV OS_GIT_MAJOR=4 OS_GIT_MINOR=2 OS_GIT_PATCH=24 OS_GIT_VERSION=4.2.24-202003161048-91b439e OS_GIT_TREE_STATE=clean SOURCE_GIT_COMMIT=91b439eee0cf1ac742ef63cf2a8f7fc9ea3e1432 SOURCE_GIT_TAG=v5.2.0-beta3-448-g91b439ee SOURCE_GIT_URL=https://github.com/openshift/grafana SOURCE_DATE_EPOCH=1563198033 OS_GIT_COMMIT=91b439e BUILD_VERSION=v4.2.24 BUILD_RELEASE=202003161048

ENV GOPATH="/go"
ENV GOBIN="${GOPATH}/bin"
ENV PATH="${GOBIN}:${PATH}"
RUN mkdir -p $GOBIN

COPY . $GOPATH/src/github.com/grafana/grafana

#RUN yum install -y make git
ENV GOFLAGS="-mod=vendor"
RUN cd $GOPATH/src/github.com/grafana/grafana && go run build.go build
RUN cp $GOPATH/src/github.com/grafana/grafana/bin/linux-$(go env GOARCH)/grafana-server /usr/bin/
RUN rm -rf $GOPATH/src/github.com/grafana/grafana/.git

FROM openshift/ose-base:v4.2.24.20200316.104823
ENV OS_GIT_MAJOR=4 OS_GIT_MINOR=2 OS_GIT_PATCH=24 OS_GIT_VERSION=4.2.24-202003161048-91b439e OS_GIT_TREE_STATE=clean SOURCE_GIT_COMMIT=91b439eee0cf1ac742ef63cf2a8f7fc9ea3e1432 SOURCE_GIT_TAG=v5.2.0-beta3-448-g91b439ee SOURCE_GIT_URL=https://github.com/openshift/grafana SOURCE_DATE_EPOCH=1563198033 OS_GIT_COMMIT=91b439e BUILD_VERSION=v4.2.24 BUILD_RELEASE=202003161048

ENV GOPATH="/go"
ENV GOBIN="${GOPATH}/bin"
ENV PATH="${GOBIN}:${PATH}"
RUN mkdir -p $GOBIN

COPY --from=builder /usr/bin/grafana-server /usr/bin/grafana-server
COPY --from=builder $GOPATH/src/github.com/grafana/grafana $GOPATH/src/github.com/grafana/grafana


# doesn't require a root user.
USER 1001

WORKDIR $GOPATH/src/github.com/grafana/grafana
ENTRYPOINT ["/usr/bin/grafana-server"]

LABEL \
        io.k8s.display-name="Grafana" \
        io.k8s.description="Grafana is an open source, feature rich metrics dashboard and graph editor for Graphite, Elasticsearch, OpenTSDB, Prometheus and InfluxDB." \
        io.openshift.tags="openshift" \
        maintainer="Frederic Branczyk <fbranczy@redhat.com>" \
        License="GPLv2+" \
        vendor="Red Hat" \
        name="openshift/ose-grafana" \
        com.redhat.component="grafana-container" \
        version="v4.2.24" \
        release="202003161048" \
        io.openshift.build.commit.id="91b439eee0cf1ac742ef63cf2a8f7fc9ea3e1432" \
        io.openshift.build.source-location="https://github.com/openshift/grafana" \
        io.openshift.build.commit.url="https://github.com/openshift/grafana/commit/91b439eee0cf1ac742ef63cf2a8f7fc9ea3e1432"

