FROM openshift/golang-builder:1.10 AS builder
ENV SOURCE_GIT_COMMIT=2ea5517e5d33531ee8b838c70666e484a79cd49d SOURCE_DATE_EPOCH=1551375602 BUILD_VERSION=v4.1.23 SOURCE_GIT_URL=https://github.com/openshift/grafana SOURCE_GIT_TAG=v5.2.0-beta3-464-g2ea5517e BUILD_RELEASE=201911050122

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
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.1.23.20191105.012243
ENV SOURCE_GIT_COMMIT=2ea5517e5d33531ee8b838c70666e484a79cd49d SOURCE_DATE_EPOCH=1551375602 BUILD_VERSION=v4.1.23 SOURCE_GIT_URL=https://github.com/openshift/grafana SOURCE_GIT_TAG=v5.2.0-beta3-464-g2ea5517e BUILD_RELEASE=201911050122

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

