From 3984187843897bb1bf185020aa5964698ca2ce82 Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Fri, 9 Apr 2021 17:40:36 +0200 Subject: [PATCH] Add common binaries for multus These are the common cnis: https://www.cni.dev/plugins/current/main/ Signed-off-by: Manuel Buil --- 0001-Add-all-important-multus-binaries.patch | 25 +++++++++++ Dockerfile | 44 ++++++++++++++++---- 2 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 0001-Add-all-important-multus-binaries.patch diff --git a/0001-Add-all-important-multus-binaries.patch b/0001-Add-all-important-multus-binaries.patch new file mode 100644 index 0000000..eee3d83 --- /dev/null +++ b/0001-Add-all-important-multus-binaries.patch @@ -0,0 +1,25 @@ +From fc5241fa9c9b3025e27b93ccbb3a6d8e6fd9160e Mon Sep 17 00:00:00 2001 +From: Manuel Buil +Date: Fri, 9 Apr 2021 17:03:29 +0200 +Subject: [PATCH] Add all important multus binaries + +Signed-off-by: Manuel Buil +--- + images/entrypoint.sh | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/images/entrypoint.sh b/images/entrypoint.sh +index de88edce..5549058b 100755 +--- a/images/entrypoint.sh ++++ b/images/entrypoint.sh +@@ -177,6 +177,7 @@ done + if [ "$SKIP_BINARY_COPY" = false ]; then + cp -f $MULTUS_BIN_FILE $CNI_BIN_DIR/_multus + mv -f $CNI_BIN_DIR/_multus $CNI_BIN_DIR/multus ++ mv -f /opt/cni/bin/* $CNI_BIN_DIR/ + else + log "Entrypoint skipped copying Multus binary." + fi +-- +2.26.2 + diff --git a/Dockerfile b/Dockerfile index 89b91b1..5536e6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,24 +3,54 @@ ARG TAG="v3.7.1" ARG UBI_IMAGE=registry.access.redhat.com/ubi7/ubi-minimal:latest ARG GO_IMAGE=rancher/hardened-build-base:v1.15.8b5 -# Build the project +# Build the multus project FROM ${GO_IMAGE} as builder RUN set -x \ && apk --no-cache add \ - git + patch ARG ARCH ARG TAG ENV GOARCH ${ARCH} ENV GOOS "linux" -RUN git clone --depth=1 https://github.com/k8snetworkplumbingwg/multus-cni -WORKDIR multus-cni -RUN git fetch --all --tags --prune -RUN git checkout tags/${TAG} -b ${TAG} -RUN ./hack/build-go.sh +COPY 0001-Add-all-important-multus-binaries.patch . +RUN git clone --depth=1 https://github.com/k8snetworkplumbingwg/multus-cni \ + && cd multus-cni \ + && git fetch --all --tags --prune \ + && git checkout tags/${TAG} -b ${TAG} \ + && patch -p1 < ../0001-Add-all-important-multus-binaries.patch \ + && ./hack/build-go.sh + +### Build the CNI plugins ### +FROM ${GO_IMAGE} as cni_plugins +ARG TAG +ARG CNI_PLUGINS_VERSION="v0.9.1" +RUN git clone --depth=1 https://github.com/containernetworking/plugins.git $GOPATH/src/github.com/containernetworking/plugins \ + && cd $GOPATH/src/github.com/containernetworking/plugins \ + && git fetch --all --tags --prune \ + && git checkout tags/${CNI_PLUGINS_VERSION} -b ${CNI_PLUGINS_VERSION} \ + && sh -ex ./build_linux.sh -v \ + -gcflags=-trimpath=/go/src \ + -ldflags " \ + -X github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=${CNI_PLUGINS_VERSION} \ + -linkmode=external -extldflags \"-static -Wl,--fatal-warnings\" \ + " +WORKDIR $GOPATH/src/github.com/containernetworking/plugins +RUN go-assert-static.sh bin/* \ + && go-assert-boring.sh \ + bin/bridge \ + bin/dhcp \ + bin/host-device \ + bin/host-local \ + bin/ipvlan \ + bin/macvlan \ + bin/ptp \ + && mkdir -vp /opt/cni/bin \ + && install -D -s bin/* /opt/cni/bin # Create the multus image FROM ${UBI_IMAGE} COPY --from=builder /go/multus-cni /usr/src/multus-cni +COPY --from=cni_plugins /opt/cni/bin/bridge /opt/cni/bin/dhcp /opt/cni/bin/host-device /opt/cni/bin/host-local /opt/cni/bin/ipvlan /opt/cni/bin/macvlan /opt/cni/bin/ptp /opt/cni/bin/static /opt/cni/bin/tuning /opt/cni/bin/ WORKDIR / RUN cp /usr/src/multus-cni/images/entrypoint.sh /entrypoint.sh ENTRYPOINT ["entrypoint.sh"]