
This moves all the release builds into a Dockerfile which is a bit cleaner for setting up our build environment. Non-linux/amd64 builds are cross-compiled. Currently onlinux linux/amd64, linux/arm64, and windows/amd64 are supported, but is easy to add more, provided their is a cross-compile toolchain available for it. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
93 lines
3.6 KiB
Docker
93 lines
3.6 KiB
Docker
# Copyright The containerd Authors.
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
ARG GO_VERSION
|
|
ARG GO_IMAGE=golang:${GO_VERSION}
|
|
FROM --platform=$BUILDPLATFORM $GO_IMAGE AS go
|
|
|
|
FROM --platform=$BUILDPLATFORM ubuntu:18.04 AS base
|
|
SHELL ["/bin/bash", "-xec"]
|
|
# Ubuntu has entirely separate repos for non-amd64 architectures
|
|
# Because of this we can't just add new arches, we need to update the repo list first
|
|
RUN \
|
|
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ bionic main multiverse restricted universe > /etc/apt/sources.list; \
|
|
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ bionic-updates main multiverse restricted universe >> /etc/apt/sources.list; \
|
|
echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ bionic-security main multiverse restricted universe >> /etc/apt/sources.lis; \
|
|
echo deb [arch=arm64,armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic main multiverse restricted universe >> /etc/apt/sources.list; \
|
|
echo deb [arch=arm64,armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main multiverse restricted universe >> /etc/apt/sources.list
|
|
RUN dpkg --add-architecture arm64
|
|
RUN apt-get update && apt-get install -y \
|
|
binutils-mingw-w64 \
|
|
crossbuild-essential-arm64 \
|
|
g++-mingw-w64-x86-64 \
|
|
git \
|
|
libseccomp-dev:amd64 \
|
|
libseccomp-dev:arm64 \
|
|
pkg-config
|
|
ARG TARGETARCH
|
|
ARG TARGETVARIANT
|
|
ARG TARGETOS
|
|
# btrfs-progs cannot have multiple arch versions installed at the same time
|
|
# Unfortunately this is also means we can't share a build cache between arches beyond this point.
|
|
#
|
|
# Also note this won't work with 32bit arm versions, and likely some other things such as ppc.
|
|
# For that we'd need to translate $TARGETARCH and $TARGETVARIANT into Ubuntu specific values.
|
|
# Since we don't support these architectures right now this is good enough.
|
|
RUN \
|
|
if [ "$TARGETOS" = "linux" ]; then \
|
|
apt-get update && \
|
|
apt-get install -y btrfs-progs:${TARGETARCH}; \
|
|
fi
|
|
ENV PATH=/usr/local/go/bin:$PATH
|
|
ENV GOPATH=/go
|
|
ENV CGO_ENABLED=1
|
|
|
|
FROM base AS linux-arm64
|
|
ENV CC=aarch64-linux-gnu-gcc
|
|
RUN \
|
|
PKG_CONFIG_PATH="$(pkg-config --variable pc_path pkg-config)"; \
|
|
for i in $(find /usr/lib -name 'pkgconfig'); do \
|
|
PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$i"; \
|
|
done; \
|
|
echo export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}" > /tmp/pkgconfig
|
|
|
|
FROM base AS linux-amd64
|
|
|
|
FROM base AS windows-amd64
|
|
ENV CC=x86_64-w64-mingw32-gcc
|
|
# Set variables used by cni script which would otherwise shell out to powershell
|
|
ARG GATEWAY
|
|
ENV GATEWAY=$GATEWAY
|
|
ARG PREFIX_LEN
|
|
ENV PREFIX_LEN=$PREFIX_LEN
|
|
|
|
FROM ${TARGETOS}-${TARGETARCH}${TARGETVARIANT} AS target
|
|
COPY . /go/src/github.com/containerd/containerd
|
|
WORKDIR /go/src/github.com/containerd/containerd
|
|
ARG TARGETARCH
|
|
ARG TARGETOS
|
|
ENV GOARCH=$TARGETARCH
|
|
ENV GOOS=$TARGETOS
|
|
ENV OS=$TARGETOS
|
|
ARG RELEASE_VER
|
|
ENV VERSION=$RELEASE_VER
|
|
RUN \
|
|
--mount=type=bind,from=go,source=/usr/local/go,target=/usr/local/go \
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
[ -f /tmp/pkgconfig ] && . /tmp/pkgconfig; \
|
|
make release cri-release cri-cni-release
|
|
|
|
FROM scratch AS release
|
|
COPY --from=target /go/src/github.com/containerd/containerd/releases/ /
|