FROM openshift/golang-builder:1.14 AS builder

ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GO111MODULE=off
ENV installsuffix=cgo
ENV VERSION_PKG="github.com/jaegertracing/jaeger/pkg/version"

ADD jaeger-*.tar.gz /

RUN mkdir -p $GOPATH/src/github.com/jaegertracing
RUN tar -xf /jaeger-*.tar.gz -C $GOPATH/src/github.com/jaegertracing

RUN export JAEGER_VERSION=`ls $GOPATH/src/github.com/jaegertracing | sed s/jaeger-//g` && \
	mv $GOPATH/src/github.com/jaegertracing/jaeger-${JAEGER_VERSION} $GOPATH/src/github.com/jaegertracing/jaeger && \
	export VERSION_DATE=`date -u +'%Y-%m-%dT%H:%M:%SZ'` && \
	cd $GOPATH/src/github.com/jaegertracing/jaeger && \
	go build -o "./cmd/ingester/ingester-linux" -ldflags "-s -w -X ${VERSION_PKG}.latestVersion=${JAEGER_VERSION} -X ${VERSION_PKG}.date=${VERSION_DATE}" ./cmd/ingester/main.go

FROM registry.redhat.io/ubi8/ubi

COPY --from=builder /go/src/github.com/jaegertracing/jaeger/cmd/ingester/ingester-linux /go/bin/ingester-linux

EXPOSE 14270 14271

ENTRYPOINT ["/go/bin/ingester-linux"]

LABEL com.redhat.component="jaeger-ingester-rhel8-container" \
      name="distributed-tracing/jaeger-ingester-rhel8" \
      summary="Jaeger Ingester" \
      description="Ingester for the Jaeger distributed tracing system" \
      io.openshift.expose-services="14270:health-http,14271:metrics-http" \
      io.openshift.tags="tracing" \
      io.k8s.display-name="Jaeger Ingester" \
      maintainer="Jaeger Team <jaeger-prod@redhat.com>" \
      version="1.20.3"

