Skip to content

Commit 95b2dab

Browse files
committed
release: improve dockerfile
Removes amd64 specifics and hardcoded arm64 package pulls. Signed-off-by: Tonis Tiigi <[email protected]>
1 parent cbda79e commit 95b2dab

1 file changed

Lines changed: 18 additions & 56 deletions

File tree

Lines changed: 18 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,40 @@
1+
ARG UBUNTU_VERSION=18.04
2+
ARG BASE_IMAGE=ubuntu:${UBUNTU_VERSION}
13
ARG GO_VERSION
24
ARG GO_IMAGE=golang:${GO_VERSION}
35
FROM --platform=$BUILDPLATFORM $GO_IMAGE AS go
6+
FROM --platform=$BUILDPLATFORM tonistiigi/xx@sha256:425941eb25cc113009b1c651bd275e04593cea12c48311fe8ace6ceeecdcc645 AS xx
47

5-
FROM --platform=$BUILDPLATFORM ubuntu:18.04 AS base
8+
FROM --platform=$BUILDPLATFORM ${BASE_IMAGE} AS base
9+
COPY --from=xx / /
610
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
3815
ENV PATH=/usr/local/go/bin:$PATH
3916
ENV GOPATH=/go
4017
ENV CGO_ENABLED=1
4118

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
5521
# Set variables used by cni script which would otherwise shell out to powershell
5622
ARG GATEWAY
57-
ENV GATEWAY=$GATEWAY
5823
ARG PREFIX_LEN
59-
ENV PREFIX_LEN=$PREFIX_LEN
6024

61-
FROM ${TARGETOS}-${TARGETARCH}${TARGETVARIANT} AS target
62-
COPY . /go/src/github.com/containerd/containerd
25+
FROM ${TARGETOS} AS target
6326
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
6929
ARG RELEASE_VER
7030
ENV VERSION=$RELEASE_VER
7131
RUN \
7232
--mount=type=bind,from=go,source=/usr/local/go,target=/usr/local/go \
7333
--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
7638

7739
FROM scratch AS release
7840
COPY --from=target /go/src/github.com/containerd/containerd/releases/ /

0 commit comments

Comments
 (0)