FROM ubi8-minimal:8.2-339 AS builder

ENV GOPATH=/go

RUN microdnf install -y git sed go-compilers-golang-compiler tar gzip

COPY kubevirt-template-validator-eeabcb1a1a1c56e90d5e3dafdb2504f4cc640ea0.tar.gz /
RUN mkdir -p /go/src/github.com/fromanirh/kubevirt-template-validator && \
    tar -xzf /kubevirt-template-validator-eeabcb1a1a1c56e90d5e3dafdb2504f4cc640ea0.tar.gz --strip-components 1 \
        -C /go/src/github.com/fromanirh/kubevirt-template-validator
WORKDIR ${GOPATH}/src/github.com/fromanirh/kubevirt-template-validator

RUN ./hack/build/build.sh v0.6.6

FROM ubi8-minimal:8.2-339
RUN mkdir -p /etc/webhook/certs
COPY --from=builder /go/src/github.com/fromanirh/kubevirt-template-validator/cmd/kubevirt-template-validator/kubevirt-template-validator /usr/sbin/kubevirt-template-validator
ENTRYPOINT [ "/usr/sbin/kubevirt-template-validator" ]

LABEL com.redhat.component="kubevirt-template-validator-container" \
      name="container-native-virtualization/kubevirt-template-validator" \
      version="v2.4.0" \
      upstream-version="v0.6.6" \
      summary="validating webhook to check templates sent to the cluster" \
      upstream-vcs-type="git" \
      io.openshift.expose-services="" \
      io.openshift.tags="cnv,kubevirt,template,validation" \
      io.k8s.display-name="kubevirt-template-validator" \
      maintainer="The KubeVirt Project <kubevirt-dev@googlegroups.com" \
      description="kubevirt-template-validator is a kubevirt addon to check the annotations on templates and reject them if unvalid. It is implemented using a validating webhook."
