FROM rhel8/go-toolset:1.13.4 AS builder

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

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

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

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

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

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