Skip to content

Commit

Permalink
Merge pull request moby#5463 from AkihiroSuda/containerd-2.0
Browse files Browse the repository at this point in the history
Dockerfile: update containerd binary to v2.0.0
  • Loading branch information
AkihiroSuda authored Nov 15, 2024
2 parents 66996a6 + b1adeed commit 033a5ad
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 40 deletions.
1 change: 1 addition & 0 deletions .github/workflows/.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
- containerd
- containerd-rootless
- containerd-1.6
- containerd-1.7
- containerd-snapshotter-stargz
- oci
- oci-rootless
Expand Down
76 changes: 38 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

# Do not update runc to v1.2.x until https://github.com/opencontainers/runc/issues/4518 is resolved
ARG RUNC_VERSION=v1.1.15
ARG CONTAINERD_VERSION=v1.7.23
# CONTAINERD_ALT_VERSION_16 defines fallback containerd version for integration tests
ARG CONTAINERD_VERSION=v2.0.0
# CONTAINERD_ALT_VERSION_... defines fallback containerd version for integration tests
ARG CONTAINERD_ALT_VERSION_17=v1.7.23
ARG CONTAINERD_ALT_VERSION_16=v1.6.36
ARG REGISTRY_VERSION=v2.8.3
ARG ROOTLESSKIT_VERSION=v2.3.1
Expand Down Expand Up @@ -207,54 +208,52 @@ RUN apk add --no-cache fuse3 git openssh pigz xz iptables ip6tables \
COPY --link examples/buildctl-daemonless/buildctl-daemonless.sh /usr/bin/
VOLUME /var/lib/buildkit

FROM gobuild-base AS containerd
FROM gobuild-base AS containerd-build
WORKDIR /go/src/github.com/containerd/containerd
ARG CONTAINERD_VERSION
ADD --keep-git-dir=true "https://github.com/containerd/containerd.git#$CONTAINERD_VERSION" .
ARG TARGETPLATFORM
ENV CGO_ENABLED=1 BUILDTAGS=no_btrfs GO111MODULE=off
RUN xx-apk add musl-dev gcc && xx-go --wrap
RUN --mount=target=/root/.cache,type=cache <<EOT
set -ex
mkdir /out
ext=""
COPY --chmod=755 <<-EOT /build.sh
#!/bin/sh
set -ex
mkdir /out
if [ "$(xx-info os)" = "linux" ]; then
make bin/containerd
make bin/containerd-shim-runc-v2
mv bin/containerd bin/containerd-shim* /out
else
CGO_ENABLED=0 make STATIC=1 binaries
if [ "$(xx-info os)" = "windows" ]; then
ext=".exe"
fi
if [ "$(xx-info os)" = "linux" ]; then
make bin/containerd
make bin/containerd-shim-runc-v2
mv bin/containerd bin/containerd-shim* /out
mv bin/containerd.exe /out
else
CGO_ENABLED=0 make STATIC=1 binaries
mv bin/containerd${ext} bin/containerd-shim* /out
mv bin/containerd /out
fi
# No shim binary is built for FreeBSD, since containerd v2.0.
if ls bin/containerd-shim* >/dev/null 2>&1; then
mv bin/containerd-shim* /out
fi
fi
EOT

FROM containerd-build AS containerd
WORKDIR /go/src/github.com/containerd/containerd
ARG CONTAINERD_VERSION
ADD --keep-git-dir=true "https://github.com/containerd/containerd.git#$CONTAINERD_VERSION" .
RUN /build.sh

# containerd-alt-17 builds containerd v1.7 for integration tests
FROM containerd-build AS containerd-alt-17
WORKDIR /go/src/github.com/containerd/containerd
ARG CONTAINERD_ALT_VERSION_17
ADD --keep-git-dir=true "https://github.com/containerd/containerd.git#$CONTAINERD_ALT_VERSION_17" .
RUN /build.sh

# containerd-alt-16 builds containerd v1.6 for integration tests
FROM gobuild-base AS containerd-alt-16
FROM containerd-build AS containerd-alt-16
WORKDIR /go/src/github.com/containerd/containerd
ARG CONTAINERD_ALT_VERSION_16
ADD --keep-git-dir=true "https://github.com/containerd/containerd.git#$CONTAINERD_ALT_VERSION_16" .
ARG TARGETPLATFORM
ENV CGO_ENABLED=1 BUILDTAGS=no_btrfs GO111MODULE=off
RUN xx-apk add musl-dev gcc && xx-go --wrap
RUN --mount=target=/root/.cache,type=cache <<EOT
set -ex
mkdir /out
ext=""
if [ "$(xx-info os)" = "windows" ]; then
ext=".exe"
fi
if [ "$(xx-info os)" = "linux" ]; then
make bin/containerd
make bin/containerd-shim-runc-v2
mv bin/containerd bin/containerd-shim* /out
else
CGO_ENABLED=0 make STATIC=1 binaries
mv bin/containerd${ext} bin/containerd-shim* /out
fi
EOT
RUN /build.sh

FROM gobuild-base AS registry
WORKDIR /go/src/github.com/docker/distribution
Expand Down Expand Up @@ -391,7 +390,7 @@ RUN curl -Ls https://raw.githubusercontent.com/moby/moby/v25.0.1/hack/dind > /do
&& chmod 0755 /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
# musl is needed to directly use the registry binary that is built on alpine
ENV BUILDKIT_INTEGRATION_CONTAINERD_EXTRA="containerd-1.6=/opt/containerd-alt-16/bin"
ENV BUILDKIT_INTEGRATION_CONTAINERD_EXTRA="containerd-1.7=/opt/containerd-alt-17/bin,containerd-1.6=/opt/containerd-alt-16/bin"
ENV BUILDKIT_INTEGRATION_SNAPSHOTTER=stargz
ENV BUILDKIT_SETUP_CGROUPV2_ROOT=1
ENV CGO_ENABLED=0
Expand All @@ -402,6 +401,7 @@ COPY --link --from=minio-mc /usr/bin/mc /usr/bin/
COPY --link --from=nydus /out/nydus-static/* /usr/bin/
COPY --link --from=stargz-snapshotter /out/* /usr/bin/
COPY --link --from=rootlesskit /rootlesskit /usr/bin/
COPY --link --from=containerd-alt-17 /out/containerd* /opt/containerd-alt-17/bin/
COPY --link --from=containerd-alt-16 /out/containerd* /opt/containerd-alt-16/bin/
COPY --link --from=registry /out /usr/bin/
COPY --link --from=runc /usr/bin/runc /usr/bin/
Expand Down
5 changes: 3 additions & 2 deletions util/testutil/workers/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ func (c *Containerd) New(ctx context.Context, cfg *integration.BackendConfig) (b
deferF.Append(func() error { return os.RemoveAll(tmpdir) })

address := getContainerdSock(tmpdir)
config := fmt.Sprintf(`root = %q
config := fmt.Sprintf(`version = 2
root = %q
state = %q
# CRI plugins listens on 10010/tcp for stream server.
# We disable CRI plugin so that multiple instance can run simultaneously.
disabled_plugins = ["cri"]
disabled_plugins = ["io.containerd.grpc.v1.cri"]
[grpc]
address = %q
Expand Down

0 comments on commit 033a5ad

Please sign in to comment.