From 6e76c8b7c6ad6aa132edc7757b6819fc3c9a8d55 Mon Sep 17 00:00:00 2001 From: xZero707 Date: Sat, 9 Jul 2022 00:55:30 +0200 Subject: [PATCH] Add support for multi-arch Platforms: - linux/i386 - linux/amd64 - linux/armhf - linux/aarch64 --- Dockerfile | 17 ++++++++++++++--- build/docker-bake.hcl | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index fb39f80..402563a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,23 @@ ARG BBKCLI_VERSION=1.0 -FROM scratch AS bbkcli + +FROM --platform=${TARGETPLATFORM} alpine:3.16 AS bbkcli # See: http://www.bredbandskollen.se/bredbandskollen-cli/ ARG BBKCLI_VERSION -ADD ["https://frontend.bredbandskollen.se/download/bbk_cli_linux_amd64-${BBKCLI_VERSION}", "/bbk_cli"] + +ARG TARGETPLATFORM +RUN case ${TARGETPLATFORM} in \ + "linux/amd64") BBKCLI_ARCH=amd64 ;; \ + "linux/arm64") BBKCLI_ARCH=aarch64 ;; \ + "linux/arm/v7") BBKCLI_ARCH=armhf ;; \ + "linux/386") BBKCLI_ARCH=i386 ;; \ + esac \ + && wget -q https://frontend.bredbandskollen.se/download/bbk_cli_linux_${BBKCLI_ARCH:-amd64}-${BBKCLI_VERSION} -O /bbk_cli # Main image -FROM alpine:3.16 +FROM --platform=${TARGETPLATFORM} alpine:3.16 LABEL net.northern-lights.image.authors="aleksandar@puharic.com" LABEL net.northern-lights.image.version="${BBKCLI_VERSION}" @@ -20,5 +29,7 @@ RUN apk add --update --no-cache gcompat libstdc++ tzdata \ COPY --from=bbkcli --chmod=0775 ["/bbk_cli", "/usr/local/bin/"] ARG BBKCLI_VERSION +ARG TARGETPLATFORM ENV BBKCLI_VERSION=${BBKCLI_VERSION} +ENV PLATFORM_ARCH=${TARGETPLATFORM} ENV TZ=Europe/Stockholm diff --git a/build/docker-bake.hcl b/build/docker-bake.hcl index 7c958a3..07f54ff 100644 --- a/build/docker-bake.hcl +++ b/build/docker-bake.hcl @@ -7,7 +7,7 @@ target "build-dockerfile" { } target "build-platforms" { - platforms = ["linux/amd64"] + platforms = ["linux/i386", "linux/amd64", "linux/armhf", "linux/aarch64"] } target "build-common" {