#@follow_tag(registry.redhat.io/ubi8/ubi-minimal:8.2)
FROM registry.redhat.io/ubi8/ubi-minimal:8.2-349 AS builder

ENV GOPATH=/go

RUN echo -e "[go-toolset]\nname=go-toolset\nprofiles=\nstate=enabled\nstream=rhel8" > /etc/dnf/modules.d/go-toolset.module \
    && microdnf install -y go-compilers-golang-compiler tar gzip
COPY ovs-cni-*.tar.gz /go/src/github.com/kubevirt/
RUN \
    cd /go/src/github.com/kubevirt/ && \
    tar -xzf ovs-cni-*.tar.gz && \
    rm ovs-cni-*.tar.gz && \
    mv ovs-cni-* ovs-cni

WORKDIR /go/src/github.com/kubevirt/ovs-cni/

RUN \
    GOOS=linux \
    GOARCH=amd64 \
    CGO_ENABLED=0 \
    GOFLAGS=-mod=vendor \
    go build -tags no_openssl -i -o /ovs ./cmd/plugin

#@follow_tag(registry.redhat.io/ubi8/ubi-minimal:8.2)
FROM registry.redhat.io/ubi8/ubi-minimal:8.2-349

COPY --from=builder /ovs /ovs

LABEL com.redhat.component="ovs-cni-plugin-container" \
      name="container-native-virtualization/ovs-cni-plugin" \
      version="v2.5.0" \
      summary="OVS CNI Plugin" \
      io.openshift.expose-services="" \
      io.openshift.tags="cnv,cni,ovs" \
      io.k8s.display-name="ovs-cni-plugin" \
      maintainer="phoracek@redhat.com" \
      description="OVS CNI Plugin"
