# This Dockerfile is partially AUTOGENERATED!
# please run
# ./update.sh TAG
# example: ./update.sh v0.4.5
# *BEFORE* to edit and commit it.
#
FROM ubi8:8-released AS builder

ENV GOPATH=/go

RUN dnf install -y git sed go-compilers-golang-compiler 

COPY kubevirt-template-validator-*.tar.gz /
RUN mkdir -p /go/src/github.com/fromanirh/kubevirt-template-validator && \
    tar -xzf /kubevirt-template-validator-*.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.1

FROM ubi8-minimal:8-released
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.0.0" \
      upstream-version="v0.6.1" \
      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."
