FROM rhel8/go-toolset:1.13.4 AS builder

WORKDIR /opt/app-root/src/go/src/github.com/tektoncd/pipeline
COPY . .
RUN CGO_ENABLED=0 \
    go build -mod=vendor -v -o /tmp/openshift-pipelines-webhook \
    ./cmd/webhook

FROM ubi8-minimal:8-released

ENV WEBHOOK=/usr/local/bin/openshift-pipelines-webhook \
    KO_APP=/ko-app \
    USER_UID=1001 \
    USER_NAME=openshift-pipelines-webhook

COPY --from=builder /tmp/openshift-pipelines-webhook ${WEBHOOK}
COPY --from=builder /tmp/openshift-pipelines-webhook ${KO_APP}/webhook

LABEL \
      com.redhat.component="openshift-pipelines-webhook-rhel8-container" \
      name="openshift-pipelines-tech-preview/pipelines-webhook-rhel8" \
      version="v1.0.0" \
      summary="Red Hat OpenShift Pipelines Webhook" \
      maintainer="vdemeest@redhat.com" \
      description="Red Hat OpenShift Pipelines Webhook" \
      io.k8s.display-name="Red Hat OpenShift Pipelines Webhook"

ENTRYPOINT ["/usr/local/bin/openshift-pipelines-webhook"]
