Skip to content

Commit

Permalink
Add common binaries for multus
Browse files Browse the repository at this point in the history
These are the common cnis:
https://www.cni.dev/plugins/current/main/

Signed-off-by: Manuel Buil <[email protected]>
  • Loading branch information
manuelbuil committed Apr 14, 2021
1 parent 1164072 commit 3984187
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 7 deletions.
25 changes: 25 additions & 0 deletions 0001-Add-all-important-multus-binaries.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From fc5241fa9c9b3025e27b93ccbb3a6d8e6fd9160e Mon Sep 17 00:00:00 2001
From: Manuel Buil <[email protected]>
Date: Fri, 9 Apr 2021 17:03:29 +0200
Subject: [PATCH] Add all important multus binaries

Signed-off-by: Manuel Buil <[email protected]>
---
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

44 changes: 37 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit 3984187

Please sign in to comment.