FROM openshift/golang-builder:rhel_8_golang_1.16 AS builder
ENV __doozer=update BUILD_RELEASE=202110182323.p0.git.f3882d6.assembly.stream BUILD_VERSION=v4.9.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=9 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.9.0-202110182323.p0.git.f3882d6.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=f3882d6 OS_GIT_VERSION=4.9.0-202110182323.p0.git.f3882d6.assembly.stream-f3882d6 SOURCE_DATE_EPOCH=1634225755 SOURCE_GIT_COMMIT=f3882d62c20ffb636f89d32189f803288432671c SOURCE_GIT_TAG=v0.0.0-alpha.0-393-gf3882d62c SOURCE_GIT_URL=https://github.com/openshift/sdn 
WORKDIR /go/src/github.com/openshift/sdn
COPY . .
RUN make build --warn-undefined-variables
RUN CGO_ENABLED=0 GO_BUILD_FLAGS="-tags no_openssl" make build GO_BUILD_PACKAGES="github.com/openshift/sdn/cmd/openshift-sdn-cni" --warn-undefined-variables

FROM openshift/ose-base:v4.9.0.20211018.233142
ENV __doozer=update BUILD_RELEASE=202110182323.p0.git.f3882d6.assembly.stream BUILD_VERSION=v4.9.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=9 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.9.0-202110182323.p0.git.f3882d6.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=f3882d6 OS_GIT_VERSION=4.9.0-202110182323.p0.git.f3882d6.assembly.stream-f3882d6 SOURCE_DATE_EPOCH=1634225755 SOURCE_GIT_COMMIT=f3882d62c20ffb636f89d32189f803288432671c SOURCE_GIT_TAG=v0.0.0-alpha.0-393-gf3882d62c SOURCE_GIT_URL=https://github.com/openshift/sdn 
COPY --from=builder /go/src/github.com/openshift/sdn/openshift-sdn-node /usr/bin/
COPY --from=builder /go/src/github.com/openshift/sdn/openshift-sdn-controller /usr/bin/
COPY --from=builder /go/src/github.com/openshift/sdn/openshift-sdn-cni /opt/cni/bin/openshift-sdn
COPY --from=builder /go/src/github.com/openshift/sdn/host-local /usr/bin/cni/osdn-host-local

RUN INSTALL_PKGS=" \
      openvswitch2.13 container-selinux socat ethtool nmap-ncat \
      libmnl libnetfilter_conntrack conntrack-tools \
      libnfnetlink iproute procps-ng openssl \
      iputils binutils xz util-linux dbus nftables \
      tcpdump" && \
    yum install -y --setopt=tsflags=nodocs --setopt=skip_missing_names_on_install=False $INSTALL_PKGS && \
    mkdir -p /etc/sysconfig/cni/net.d && \
    yum clean all && rm -rf /var/cache/*

COPY ./images/iptables-scripts/iptables /usr/sbin/
COPY ./images/iptables-scripts/iptables-save /usr/sbin/
COPY ./images/iptables-scripts/iptables-restore /usr/sbin/
COPY ./images/iptables-scripts/ip6tables /usr/sbin/
COPY ./images/iptables-scripts/ip6tables-save /usr/sbin/
COPY ./images/iptables-scripts/ip6tables-restore /usr/sbin/

LABEL \
        io.k8s.display-name="OpenShift SDN" \
        io.k8s.description="This is a component of OpenShift and contains the default SDN implementation." \
        io.openshift.tags="openshift,sdn,sdn-controller" \
        name="openshift/ose-sdn" \
        com.redhat.component="ose-node-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="Networking" \
        io.openshift.maintainer.subcomponent="openshift-sdn" \
        release="202110182323.p0.git.f3882d6.assembly.stream" \
        io.openshift.build.commit.id="f3882d62c20ffb636f89d32189f803288432671c" \
        io.openshift.build.source-location="https://github.com/openshift/sdn" \
        io.openshift.build.commit.url="https://github.com/openshift/sdn/commit/f3882d62c20ffb636f89d32189f803288432671c" \
        version="v4.9.0"

