forked from rancher/image-build-cni-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
50 lines (47 loc) · 1.85 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
ARG ARCH="amd64"
ARG TAG="v1.0.1"
ARG UBI_IMAGE=registry.access.redhat.com/ubi7/ubi-minimal:latest
ARG GO_IMAGE=rancher/hardened-build-base:v1.16.12b7
### Build the cni-plugins ###
FROM ${GO_IMAGE} as cni_plugins
ARG ARCH
ARG TAG
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/${TAG} -b ${TAG} \
&& sh -ex ./build_linux.sh -v \
-gcflags=-trimpath=/go/src \
-ldflags " \
-X github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=${TAG} \
-linkmode=external -extldflags \"-static -Wl,--fatal-warnings\" \
"
RUN git clone --depth=1 https://github.com/flannel-io/cni-plugin $GOPATH/src/github.com/flannel-io/cni-plugin \
&& cd $GOPATH/src/github.com/flannel-io/cni-plugin \
&& git fetch --all --tags --prune \
&& git checkout tags/${TAG} -b ${TAG} \
&& make build_linux \
&& mv $GOPATH/src/github.com/flannel-io/cni-plugin/dist/flannel-${ARCH} $GOPATH/src/github.com/containernetworking/plugins/bin/flannel
WORKDIR $GOPATH/src/github.com/containernetworking/plugins
RUN go-assert-static.sh bin/* \
&& if [ "${ARCH}" != "s390x" ]; then \
go-assert-boring.sh bin/bandwidth \
bin/bridge \
bin/dhcp \
bin/firewall \
bin/host-device \
bin/host-local \
bin/ipvlan \
bin/macvlan \
bin/portmap \
bin/ptp \
bin/vlan ; \
fi \
&& mkdir -vp /opt/cni/bin \
&& install -D -s bin/* /opt/cni/bin
# Create image with the cni-plugins
FROM ${UBI_IMAGE}
COPY --from=cni_plugins /opt/cni/ /opt/cni/
WORKDIR /
COPY install-cnis.sh .
ENTRYPOINT ["./install-cnis.sh"]