1212
1313ARG GOLANG_VERSION=1.16.6
1414
15- FROM golang:${GOLANG_VERSION} AS golang-base
16- RUN mkdir -p /go/src/github.com/containerd/containerd
17- WORKDIR /go/src/github.com/containerd/containerd
18-
19- # Install proto3
20- FROM golang-base AS proto3
21- RUN apt-get update && apt-get install -y \
22- autoconf \
23- automake \
24- g++ \
25- libtool \
26- unzip \
27- --no-install-recommends
28-
29- COPY script/setup/install-protobuf install-protobuf
30- RUN ./install-protobuf
15+ FROM golang:${GOLANG_VERSION} AS golang
3116
3217# Install runc
33- FROM golang-base AS runc
18+ FROM golang AS runc
3419RUN apt-get update && apt-get install -y \
3520 libseccomp-dev \
3621 --no-install-recommends
@@ -41,38 +26,53 @@ ARG RUNC_VERSION
4126ARG GOPROXY=direct
4227RUN ./install-runc
4328
44- FROM golang-base AS dev
29+ FROM golang AS build-env
4530RUN apt-get update && apt-get install -y \
4631 libbtrfs-dev \
4732 btrfs-progs \
4833 libseccomp-dev \
4934 xfsprogs \
5035 --no-install-recommends
51-
52- COPY --from=proto3 /usr/local/bin/protoc /usr/local/bin/protoc
53- COPY --from=proto3 /usr/local/include/google /usr/local/include/google
54- COPY --from=runc /usr/local/sbin/runc /usr/local/go/bin/runc
55-
56- COPY . .
36+ RUN mkdir -p /go/src/github.com/containerd/containerd
37+ WORKDIR /go/src/github.com/containerd/containerd
5738
5839# cri-in-userns stage is for testing "CRI-in-UserNS", which should be used in conjunction with
5940# "Kubelet-in-UserNS": https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2033-kubelet-in-userns-aka-rootless
6041# This feature is mostly expected to be used for `kind` and `minikube`.
6142#
6243# Requires Rootless Docker/Podman/nerdctl with cgroup v2 delegation: https://rootlesscontaine.rs/getting-started/common/cgroup2/
6344# (Rootless Docker/Podman/nerdctl prepares the UserNS, so we do not need to create UserNS by ourselves)
64- FROM dev AS cri-in-userns
65- RUN make BUILDTAGS="no_btrfs no_devmapper" binaries install
45+ FROM build-env AS cri-in-userns
6646RUN apt-get update && apt-get install -y iptables
47+ COPY contrib/Dockerfile.test.d/cri-in-userns/etc_containerd_config.toml /etc/containerd/config.toml
48+ COPY contrib/Dockerfile.test.d/cri-in-userns/docker-entrypoint.sh /docker-entrypoint.sh
49+ COPY --from=runc /usr/local/sbin/runc /usr/local/go/bin/runc
50+ COPY . .
6751RUN ./script/setup/install-cni
6852RUN ./script/setup/install-critools
69- COPY contrib/Dockerfile.test.d/cri-in-userns/etc_containerd_config.toml /etc/containerd/config.toml
70- COPY contrib/Dockerfile.test.d/cri-in-userns/docker-entrypoint.sh /docker-entrypoint.sh
53+ RUN make BUILDTAGS="no_btrfs no_devmapper" binaries install
7154VOLUME /var/lib/containerd
7255ENTRYPOINT ["/docker-entrypoint.sh"]
7356# Skip "runtime should support unsafe sysctls": `container init caused: write sysctl key fs.mqueue.msg_max: open /proc/sys/fs/mqueue/msg_max: permission denied`
7457# Skip "runtime should support safe sysctls": `container init caused: write sysctl key kernel.shm_rmid_forced: open /proc/sys/kernel/shm_rmid_forced: permission denied`
7558# Skip "should allow privilege escalation when (NoNewPrivis is) false": expected log "Effective uid: 0\n" (stream="stdout") not found in logs [{timestamp:{wall:974487519 ext:63761339984 loc:<nil>} stream:stdout log:Effective uid: 1000) }]
7659CMD ["critest", "--ginkgo.skip=should support unsafe sysctls|should support safe sysctls|should allow privilege escalation when false"]
7760
78- FROM dev AS default
61+ # Install proto3
62+ FROM golang AS proto3
63+ RUN apt-get update && apt-get install -y \
64+ autoconf \
65+ automake \
66+ g++ \
67+ libtool \
68+ unzip \
69+ --no-install-recommends
70+
71+ COPY script/setup/install-protobuf install-protobuf
72+ RUN ./install-protobuf
73+
74+ FROM build-env AS dev
75+ COPY --from=proto3 /usr/local/bin/protoc /usr/local/bin/protoc
76+ COPY --from=proto3 /usr/local/include/google /usr/local/include/google
77+ COPY --from=runc /usr/local/sbin/runc /usr/local/go/bin/runc
78+ COPY . .
0 commit comments