|
11 | 11 | # docker build -t containerd-test --build-arg RUNC_VERSION=v1.0.0-rc94 -f Dockerfile.test ../ |
12 | 12 |
|
13 | 13 | ARG GOLANG_VERSION=1.16.6 |
| 14 | +ARG GOLANG_IMAGE=golang |
14 | 15 |
|
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 |
| 16 | +FROM ${GOLANG_IMAGE}:${GOLANG_VERSION} AS golang |
31 | 17 |
|
32 | 18 | # Install runc |
33 | | -FROM golang-base AS runc |
34 | | -RUN apt-get update && apt-get install -y \ |
35 | | - curl \ |
| 19 | +FROM golang AS runc |
| 20 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
36 | 21 | libseccomp-dev \ |
37 | | - --no-install-recommends |
| 22 | + && rm -rf /var/lib/apt/lists/* |
38 | 23 |
|
39 | 24 | COPY script/setup/runc-version script/setup/install-runc ./ |
40 | 25 | # Allow overriding the version of runc to install through build-args |
41 | 26 | ARG RUNC_VERSION |
42 | 27 | ARG GOPROXY=direct |
| 28 | +ARG DESTDIR=/build |
43 | 29 | RUN ./install-runc |
44 | 30 |
|
45 | | -FROM golang-base AS dev |
46 | | -RUN apt-get update && apt-get install -y \ |
| 31 | +FROM golang AS build-env |
| 32 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
47 | 33 | libbtrfs-dev \ |
48 | 34 | btrfs-progs \ |
49 | | - gcc \ |
50 | | - git \ |
51 | 35 | libseccomp-dev \ |
52 | | - make \ |
53 | 36 | xfsprogs \ |
54 | | - --no-install-recommends |
| 37 | + && rm -rf /var/lib/apt/lists/* |
| 38 | +RUN mkdir -p /go/src/github.com/containerd/containerd |
| 39 | +WORKDIR /go/src/github.com/containerd/containerd |
55 | 40 |
|
56 | | -COPY --from=proto3 /usr/local/bin/protoc /usr/local/bin/protoc |
57 | | -COPY --from=proto3 /usr/local/include/google /usr/local/include/google |
58 | | -COPY --from=runc /usr/local/sbin/runc /usr/local/go/bin/runc |
| 41 | +FROM golang AS cni |
| 42 | +ENV DESTDIR=/build |
| 43 | +COPY script/setup/install-cni ./ |
| 44 | +COPY go.mod /go/src/github.com/containerd/containerd/go.mod |
| 45 | +RUN ./install-cni |
59 | 46 |
|
| 47 | +FROM golang AS critools |
| 48 | +ARG DESTDIR=/build |
| 49 | +COPY script/setup/install-critools script/setup/critools-version ./ |
| 50 | +RUN GOBIN=$DESTDIR/usr/local/bin ./install-critools |
| 51 | + |
| 52 | +FROM build-env AS containerd |
| 53 | +ARG DESTDIR=/build |
60 | 54 | COPY . . |
| 55 | +RUN make BUILDTAGS="no_btrfs no_devmapper" binaries install |
61 | 56 |
|
62 | 57 | # cri-in-userns stage is for testing "CRI-in-UserNS", which should be used in conjunction with |
63 | 58 | # "Kubelet-in-UserNS": https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2033-kubelet-in-userns-aka-rootless |
64 | 59 | # This feature is mostly expected to be used for `kind` and `minikube`. |
65 | 60 | # |
66 | 61 | # Requires Rootless Docker/Podman/nerdctl with cgroup v2 delegation: https://rootlesscontaine.rs/getting-started/common/cgroup2/ |
67 | 62 | # (Rootless Docker/Podman/nerdctl prepares the UserNS, so we do not need to create UserNS by ourselves) |
68 | | -FROM dev AS cri-in-userns |
69 | | -RUN make BUILDTAGS="no_btrfs no_devmapper" binaries install |
70 | | -RUN apt-get update && apt-get install -y iptables |
71 | | -RUN ./script/setup/install-cni |
72 | | -RUN ./script/setup/install-critools |
| 63 | +FROM build-env AS cri-in-userns |
| 64 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 65 | + iptables \ |
| 66 | + && rm -rf /var/lib/apt/lists/* |
73 | 67 | COPY contrib/Dockerfile.test.d/cri-in-userns/etc_containerd_config.toml /etc/containerd/config.toml |
74 | | -COPY contrib/Dockerfile.test.d/cri-in-userns/docker-entrypoint.sh /docker-entrypoint.sh |
| 68 | +COPY contrib/Dockerfile.test.d/cri-in-userns/docker-entrypoint.sh /docker-entrypoint.sh |
| 69 | +COPY --from=runc /build/ / |
| 70 | +COPY --from=cni /build/ / |
| 71 | +COPY --from=critools /build/ / |
| 72 | +COPY --from=containerd /build/ / |
75 | 73 | VOLUME /var/lib/containerd |
76 | 74 | ENTRYPOINT ["/docker-entrypoint.sh"] |
77 | 75 | # 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` |
78 | 76 | # 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` |
79 | 77 | # 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) }] |
80 | 78 | CMD ["critest", "--ginkgo.skip=should support unsafe sysctls|should support safe sysctls|should allow privilege escalation when false"] |
81 | 79 |
|
82 | | -FROM dev AS default |
| 80 | +# Install proto3 |
| 81 | +FROM golang AS proto3 |
| 82 | +ARG DESTDIR=/build |
| 83 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 84 | + autoconf \ |
| 85 | + automake \ |
| 86 | + g++ \ |
| 87 | + libtool \ |
| 88 | + unzip \ |
| 89 | + && rm -rf /var/lib/apt/lists/* |
| 90 | + |
| 91 | +COPY script/setup/install-protobuf install-protobuf |
| 92 | +RUN ./install-protobuf \ |
| 93 | + && mv /usr/local/bin/protoc $DESTDIR/usr/local/bin/protoc \ |
| 94 | + && mv /usr/local/include/google $DESTDIR/usr/local/include/google |
| 95 | + |
| 96 | +FROM build-env AS dev |
| 97 | +COPY --from=proto3 /build/ / |
| 98 | +COPY --from=runc /build/ / |
| 99 | +COPY . . |
0 commit comments