From 6cba7d22e91672bd4cd1be82600562bd04e902ad Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 19 Nov 2022 02:36:13 +0100 Subject: [PATCH] Dockerfile: add cross compilation helper Signed-off-by: CrazyMax --- Dockerfile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9de5d0b7b9..9a082b6bf2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,28 @@ # syntax=docker/dockerfile:1 +ARG GO_VERSION=1.19.4 +ARG BASE_DEBIAN_DISTRO="bullseye" +ARG GOLANG_IMAGE="golang:${GO_VERSION}-${BASE_DEBIAN_DISTRO}" +ARG XX_VERSION=1.1.2 + +ARG VPNKIT_VERSION=0.5.0 + ARG CROSS="false" ARG SYSTEMD="false" -ARG GO_VERSION=1.19.4 ARG DEBIAN_FRONTEND=noninteractive -ARG VPNKIT_VERSION=0.5.0 -ARG BASE_DEBIAN_DISTRO="bullseye" -ARG GOLANG_IMAGE="golang:${GO_VERSION}-${BASE_DEBIAN_DISTRO}" +# cross compilation helper +FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx -FROM ${GOLANG_IMAGE} AS base +# base +FROM --platform=$BUILDPLATFORM ${GOLANG_IMAGE} AS base +COPY --from=xx / / RUN echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache ARG APT_MIRROR RUN sed -ri "s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g" /etc/apt/sources.list \ && sed -ri "s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g" /etc/apt/sources.list +ARG DEBIAN_FRONTEND +RUN apt-get update && apt-get install --no-install-recommends -y file ENV GO111MODULE=off FROM base AS criu