Skip to content

Commit 3984187

Browse files
committed
Add common binaries for multus
These are the common cnis: https://www.cni.dev/plugins/current/main/ Signed-off-by: Manuel Buil <[email protected]>
1 parent 1164072 commit 3984187

File tree

2 files changed

+62
-7
lines changed

2 files changed

+62
-7
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From fc5241fa9c9b3025e27b93ccbb3a6d8e6fd9160e Mon Sep 17 00:00:00 2001
2+
From: Manuel Buil <[email protected]>
3+
Date: Fri, 9 Apr 2021 17:03:29 +0200
4+
Subject: [PATCH] Add all important multus binaries
5+
6+
Signed-off-by: Manuel Buil <[email protected]>
7+
---
8+
images/entrypoint.sh | 1 +
9+
1 file changed, 1 insertion(+)
10+
11+
diff --git a/images/entrypoint.sh b/images/entrypoint.sh
12+
index de88edce..5549058b 100755
13+
--- a/images/entrypoint.sh
14+
+++ b/images/entrypoint.sh
15+
@@ -177,6 +177,7 @@ done
16+
if [ "$SKIP_BINARY_COPY" = false ]; then
17+
cp -f $MULTUS_BIN_FILE $CNI_BIN_DIR/_multus
18+
mv -f $CNI_BIN_DIR/_multus $CNI_BIN_DIR/multus
19+
+ mv -f /opt/cni/bin/* $CNI_BIN_DIR/
20+
else
21+
log "Entrypoint skipped copying Multus binary."
22+
fi
23+
--
24+
2.26.2
25+

Dockerfile

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,54 @@ ARG TAG="v3.7.1"
33
ARG UBI_IMAGE=registry.access.redhat.com/ubi7/ubi-minimal:latest
44
ARG GO_IMAGE=rancher/hardened-build-base:v1.15.8b5
55

6-
# Build the project
6+
# Build the multus project
77
FROM ${GO_IMAGE} as builder
88
RUN set -x \
99
&& apk --no-cache add \
10-
git
10+
patch
1111
ARG ARCH
1212
ARG TAG
1313
ENV GOARCH ${ARCH}
1414
ENV GOOS "linux"
15-
RUN git clone --depth=1 https://github.com/k8snetworkplumbingwg/multus-cni
16-
WORKDIR multus-cni
17-
RUN git fetch --all --tags --prune
18-
RUN git checkout tags/${TAG} -b ${TAG}
19-
RUN ./hack/build-go.sh
15+
COPY 0001-Add-all-important-multus-binaries.patch .
16+
RUN git clone --depth=1 https://github.com/k8snetworkplumbingwg/multus-cni \
17+
&& cd multus-cni \
18+
&& git fetch --all --tags --prune \
19+
&& git checkout tags/${TAG} -b ${TAG} \
20+
&& patch -p1 < ../0001-Add-all-important-multus-binaries.patch \
21+
&& ./hack/build-go.sh
22+
23+
### Build the CNI plugins ###
24+
FROM ${GO_IMAGE} as cni_plugins
25+
ARG TAG
26+
ARG CNI_PLUGINS_VERSION="v0.9.1"
27+
RUN git clone --depth=1 https://github.com/containernetworking/plugins.git $GOPATH/src/github.com/containernetworking/plugins \
28+
&& cd $GOPATH/src/github.com/containernetworking/plugins \
29+
&& git fetch --all --tags --prune \
30+
&& git checkout tags/${CNI_PLUGINS_VERSION} -b ${CNI_PLUGINS_VERSION} \
31+
&& sh -ex ./build_linux.sh -v \
32+
-gcflags=-trimpath=/go/src \
33+
-ldflags " \
34+
-X github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=${CNI_PLUGINS_VERSION} \
35+
-linkmode=external -extldflags \"-static -Wl,--fatal-warnings\" \
36+
"
37+
WORKDIR $GOPATH/src/github.com/containernetworking/plugins
38+
RUN go-assert-static.sh bin/* \
39+
&& go-assert-boring.sh \
40+
bin/bridge \
41+
bin/dhcp \
42+
bin/host-device \
43+
bin/host-local \
44+
bin/ipvlan \
45+
bin/macvlan \
46+
bin/ptp \
47+
&& mkdir -vp /opt/cni/bin \
48+
&& install -D -s bin/* /opt/cni/bin
2049

2150
# Create the multus image
2251
FROM ${UBI_IMAGE}
2352
COPY --from=builder /go/multus-cni /usr/src/multus-cni
53+
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/
2454
WORKDIR /
2555
RUN cp /usr/src/multus-cni/images/entrypoint.sh /entrypoint.sh
2656
ENTRYPOINT ["entrypoint.sh"]

0 commit comments

Comments
 (0)