From 6e7cc3b7e392e1147326583387fa024a58b3aea3 Mon Sep 17 00:00:00 2001 From: Kevin Alvarez Date: Sat, 26 Nov 2022 03:22:30 +0100 Subject: [PATCH] Dockerfile: containerd cross build with TARGETPLATFORM Signed-off-by: CrazyMax (cherry picked from commit 81d704d15d69015c2c661ea600be8aab74957ba1) Signed-off-by: Sebastiaan van Stijn --- Dockerfile | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 069603669a..15ac6d377b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -209,17 +209,46 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ GOBIN=/build/ GO111MODULE=on go install "github.com/tc-hib/go-winres@${GOWINRES_VERSION}" \ && /build/go-winres --help -FROM dev-base AS containerd +# containerd +FROM base AS containerd-src +WORKDIR /usr/src/containerd +RUN git init . && git remote add origin "https://github.com/containerd/containerd.git" +# CONTAINERD_VERSION is used to build containerd binaries, and used for the +# integration tests. The distributed docker .deb and .rpm packages depend on a +# separate (containerd.io) package, which may be a different version as is +# specified here. The containerd golang package is also pinned in vendor.mod. +# When updating the binary version you may also need to update the vendor +# version to pick up bug fixes or new APIs, however, usually the Go packages +# are built from a commit from the master branch. +ARG CONTAINERD_VERSION=v1.6.13 +RUN git fetch -q --depth 1 origin "${CONTAINERD_VERSION}" +refs/tags/*:refs/tags/* && git checkout -q FETCH_HEAD + +FROM base AS containerd-build +WORKDIR /go/src/github.com/containerd/containerd ARG DEBIAN_FRONTEND +ARG TARGETPLATFORM RUN --mount=type=cache,sharing=locked,id=moby-containerd-aptlib,target=/var/lib/apt \ --mount=type=cache,sharing=locked,id=moby-containerd-aptcache,target=/var/cache/apt \ - apt-get update && apt-get install -y --no-install-recommends \ - libbtrfs-dev -ARG CONTAINERD_VERSION -COPY /hack/dockerfile/install/install.sh /hack/dockerfile/install/containerd.installer / -RUN --mount=type=cache,target=/root/.cache/go-build \ - --mount=type=cache,target=/go/pkg/mod \ - PREFIX=/build /install.sh containerd + apt-get update && xx-apt-get install -y --no-install-recommends \ + gcc libbtrfs-dev libsecret-1-dev +ARG DOCKER_STATIC +RUN --mount=from=containerd-src,src=/usr/src/containerd,rw \ + --mount=type=cache,target=/root/.cache/go-build,id=containerd-build-$TARGETPLATFORM <