|
| 1 | +ARG UBUNTU_VERSION=18.04 |
| 2 | +ARG BASE_IMAGE=ubuntu:${UBUNTU_VERSION} |
1 | 3 | ARG GO_VERSION |
2 | 4 | ARG GO_IMAGE=golang:${GO_VERSION} |
3 | 5 | FROM --platform=$BUILDPLATFORM $GO_IMAGE AS go |
| 6 | +FROM --platform=$BUILDPLATFORM tonistiigi/xx@sha256:425941eb25cc113009b1c651bd275e04593cea12c48311fe8ace6ceeecdcc645 AS xx |
4 | 7 |
|
5 | | -FROM --platform=$BUILDPLATFORM ubuntu:18.04 AS base |
| 8 | +FROM --platform=$BUILDPLATFORM ${BASE_IMAGE} AS base |
| 9 | +COPY --from=xx / / |
6 | 10 | SHELL ["/bin/bash", "-xec"] |
7 | | -# Ubuntu has entirely separate repos for non-amd64 architectures |
8 | | -# Because of this we can't just add new arches, we need to update the repo list first |
9 | | -RUN \ |
10 | | - echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ bionic main multiverse restricted universe > /etc/apt/sources.list; \ |
11 | | - echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ bionic-updates main multiverse restricted universe >> /etc/apt/sources.list; \ |
12 | | - echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ bionic-security main multiverse restricted universe >> /etc/apt/sources.lis; \ |
13 | | - echo deb [arch=arm64,armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic main multiverse restricted universe >> /etc/apt/sources.list; \ |
14 | | - echo deb [arch=arm64,armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main multiverse restricted universe >> /etc/apt/sources.list |
15 | | -RUN dpkg --add-architecture arm64 |
16 | | -RUN apt-get update && apt-get install -y \ |
17 | | - binutils-mingw-w64 \ |
18 | | - crossbuild-essential-arm64 \ |
19 | | - g++-mingw-w64-x86-64 \ |
20 | | - git \ |
21 | | - libseccomp-dev:amd64 \ |
22 | | - libseccomp-dev:arm64 \ |
23 | | - pkg-config |
24 | | -ARG TARGETARCH |
25 | | -ARG TARGETVARIANT |
26 | | -ARG TARGETOS |
27 | | -# btrfs-progs cannot have multiple arch versions installed at the same time |
28 | | -# Unfortunately this is also means we can't share a build cache between arches beyond this point. |
29 | | -# |
30 | | -# Also note this won't work with 32bit arm versions, and likely some other things such as ppc. |
31 | | -# For that we'd need to translate $TARGETARCH and $TARGETVARIANT into Ubuntu specific values. |
32 | | -# Since we don't support these architectures right now this is good enough. |
33 | | -RUN \ |
34 | | - if [ "$TARGETOS" = "linux" ]; then \ |
35 | | - apt-get update && \ |
36 | | - apt-get install -y btrfs-progs:${TARGETARCH}; \ |
37 | | - fi |
| 11 | +RUN apt-get update && \ |
| 12 | + apt-get install -y git pkg-config |
| 13 | +ARG TARGETPLATFORM |
| 14 | +RUN xx-apt-get install -y libseccomp-dev btrfs-progs gcc |
38 | 15 | ENV PATH=/usr/local/go/bin:$PATH |
39 | 16 | ENV GOPATH=/go |
40 | 17 | ENV CGO_ENABLED=1 |
41 | 18 |
|
42 | | -FROM base AS linux-arm64 |
43 | | -ENV CC=aarch64-linux-gnu-gcc |
44 | | -RUN \ |
45 | | - PKG_CONFIG_PATH="$(pkg-config --variable pc_path pkg-config)"; \ |
46 | | - for i in $(find /usr/lib -name 'pkgconfig'); do \ |
47 | | - PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$i"; \ |
48 | | - done; \ |
49 | | - echo export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}" > /tmp/pkgconfig |
50 | | - |
51 | | -FROM base AS linux-amd64 |
52 | | - |
53 | | -FROM base AS windows-amd64 |
54 | | -ENV CC=x86_64-w64-mingw32-gcc |
| 19 | +FROM base AS linux |
| 20 | +FROM base AS windows |
55 | 21 | # Set variables used by cni script which would otherwise shell out to powershell |
56 | 22 | ARG GATEWAY |
57 | | -ENV GATEWAY=$GATEWAY |
58 | 23 | ARG PREFIX_LEN |
59 | | -ENV PREFIX_LEN=$PREFIX_LEN |
60 | 24 |
|
61 | | -FROM ${TARGETOS}-${TARGETARCH}${TARGETVARIANT} AS target |
62 | | -COPY . /go/src/github.com/containerd/containerd |
| 25 | +FROM ${TARGETOS} AS target |
63 | 26 | WORKDIR /go/src/github.com/containerd/containerd |
64 | | -ARG TARGETARCH |
65 | | -ARG TARGETOS |
66 | | -ENV GOARCH=$TARGETARCH |
67 | | -ENV GOOS=$TARGETOS |
68 | | -ENV OS=$TARGETOS |
| 27 | +COPY . . |
| 28 | +ARG TARGETPLATFORM |
69 | 29 | ARG RELEASE_VER |
70 | 30 | ENV VERSION=$RELEASE_VER |
71 | 31 | RUN \ |
72 | 32 | --mount=type=bind,from=go,source=/usr/local/go,target=/usr/local/go \ |
73 | 33 | --mount=type=cache,target=/root/.cache/go-build \ |
74 | | - [ -f /tmp/pkgconfig ] && . /tmp/pkgconfig; \ |
75 | | - make release cri-release cri-cni-release |
| 34 | + --mount=type=cache,target=/go/pkg \ |
| 35 | + export CC=$(xx-info)-gcc && xx-go --wrap && \ |
| 36 | + make release cri-release cri-cni-release && \ |
| 37 | + for f in $(find bin -executable -type f); do xx-verify $f; done |
76 | 38 |
|
77 | 39 | FROM scratch AS release |
78 | 40 | COPY --from=target /go/src/github.com/containerd/containerd/releases/ / |
0 commit comments