#@follow_tag(registry.redhat.io/rhel8-2-els/rhel)
FROM registry.redhat.io/rhel8-2-els/rhel:8.2-7 AS builder

ENV GOPATH=/go

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

WORKDIR /go/src/github.com/containernetworking/plugins/

RUN GOFLAGS=-mod=vendor ./build_linux.sh

#@follow_tag(registry.redhat.io/rhel8-2-els/rhel)
FROM registry.redhat.io/rhel8-2-els/rhel:8.2-7

RUN mkdir -p /usr/src/containernetworking/plugins/bin
RUN dnf install -y findutils

COPY --from=builder /go/src/github.com/containernetworking/plugins/bin/bridge /usr/src/containernetworking/plugins/bin/cnv-bridge
COPY --from=builder /go/src/github.com/containernetworking/plugins/bin/tuning /usr/src/containernetworking/plugins/bin/cnv-tuning

LABEL com.redhat.component="cnv-containernetworking-plugins-container" \
      name="container-native-virtualization/cnv-containernetworking-plugins" \
      version="v2.4.6" \
      summary="Container Network Plugins" \
      io.openshift.expose-services="" \
      io.openshift.tags="cnv,cni" \
      io.k8s.display-name="cni plugins" \
      maintainer="phoracek@redhat.com" \
      description="Container Network Plugins"
