Skip to content

Commit 7ec8e2d

Browse files
committed
Dockerfile.test: build cni in a separate stage
Building cni only requires the install script, and the go.mod (to determin the version to install). Moving it to a separate stage prevents it from being rebuilt if unrelated changes were made in the codebase. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent f9f423c commit 7ec8e2d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

contrib/Dockerfile.test

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ RUN apt-get update && apt-get install -y \
3737
RUN mkdir -p /go/src/github.com/containerd/containerd
3838
WORKDIR /go/src/github.com/containerd/containerd
3939

40+
FROM golang AS cni
41+
ENV DESTDIR=/build
42+
COPY script/setup/install-cni ./
43+
COPY go.mod /go/src/github.com/containerd/containerd/go.mod
44+
RUN ./install-cni
45+
4046
# cri-in-userns stage is for testing "CRI-in-UserNS", which should be used in conjunction with
4147
# "Kubelet-in-UserNS": https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2033-kubelet-in-userns-aka-rootless
4248
# This feature is mostly expected to be used for `kind` and `minikube`.
@@ -48,8 +54,8 @@ RUN apt-get update && apt-get install -y iptables
4854
COPY contrib/Dockerfile.test.d/cri-in-userns/etc_containerd_config.toml /etc/containerd/config.toml
4955
COPY contrib/Dockerfile.test.d/cri-in-userns/docker-entrypoint.sh /docker-entrypoint.sh
5056
COPY --from=runc /build/ /
57+
COPY --from=cni /build/ /
5158
COPY . .
52-
RUN ./script/setup/install-cni
5359
RUN ./script/setup/install-critools
5460
RUN make BUILDTAGS="no_btrfs no_devmapper" binaries install
5561
VOLUME /var/lib/containerd

0 commit comments

Comments
 (0)