FROM rhel8/go-toolset:1.13.4 AS builder

WORKDIR /opt/app-root/src/github.com/openshift/tektoncd-pipeline-operator
COPY . .
RUN GOARCH="amd64";case $(uname -m) in s390x)GOARCH="s390x";; \
    ppc64le)GOARCH="ppc64le";;x86_64)GOARCH="amd64";;esac; \
    CGO_ENABLED=0 GOOS=linux \
    go build  -mod=vendor -o /tmp/openshift-pipelines-operator \
    ./cmd/manager

FROM registry.redhat.io/ubi8/ubi-minimal:latest

ENV OPERATOR=/usr/local/bin/openshift-pipelines-operator \
    USER_UID=1001 \
    USER_NAME=openshift-pipelines-operator

COPY --from=builder /tmp/openshift-pipelines-operator ${OPERATOR}
COPY build/bin /usr/local/bin
RUN /usr/local/bin/user_setup
COPY deploy/resources /deploy/resources
RUN cat /proc/sys/kernel/random/uuid > /deploy/uuid
LABEL \
      com.redhat.component="openshift-pipelines-rhel8-operator-container" \
      name="openshift-pipelines-tech-preview/pipelines-rhel8-operator" \
      version="v1.2.2" \
      summary="Red Hat OpenShift Pipelines Operator" \
      maintainer="kbaig@redhat.com" \
      description="Red Hat OpenShift Pipelines Operator" \
      io.k8s.display-name="Red Hat OpenShift Pipelines Operator"

ENTRYPOINT ["/usr/local/bin/entrypoint"]

USER ${USER_UID}
