From e5eee4e0b65ebcec7fa156eac0aa1b9efb723f6c Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Mon, 13 Mar 2023 11:57:20 +0000 Subject: [PATCH] add cross-platform docker build support --- bin/build_docker.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/bin/build_docker.sh b/bin/build_docker.sh index 57cb4637..39b7afb1 100755 --- a/bin/build_docker.sh +++ b/bin/build_docker.sh @@ -13,21 +13,35 @@ IFS=$'\n' REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )" VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" SHORT_VERSION="$(echo "$VERSION" | perl -pe 's/(\d+)\.(\d+)\.(\d+)/$1.$2/g')" +TAG_NAME="dev" cd "$REPO_DIR" which docker > /dev/null + +# Install QEMU binaries for cross-platform building +docker run --privileged --rm tonistiigi/binfmt --install all || true + +# Create Docker builder for cross-platform building +docker buildx use xbuilder || docker buildx create --name xbuilder --driver docker-container --bootstrap --use + +# Verify that amd64 and arm64 support are all present +docker buildx inspect | grep 'amd64.*arm64' || exit 1 + + echo "[+] Building archivebox:$VERSION docker image..." -docker build . -t archivebox \ - -t archivebox:latest \ +#docker build . \ +docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --push . \ + -t archivebox \ + -t archivebox:$TAG_NAME \ -t archivebox:$VERSION \ -t archivebox:$SHORT_VERSION \ - -t docker.io/nikisweeting/archivebox:latest \ + -t docker.io/nikisweeting/archivebox:$TAG_NAME \ -t docker.io/nikisweeting/archivebox:$VERSION \ -t docker.io/nikisweeting/archivebox:$SHORT_VERSION \ - -t docker.io/archivebox/archivebox:latest \ + -t docker.io/archivebox/archivebox:$TAG_NAME \ -t docker.io/archivebox/archivebox:$VERSION \ -t docker.io/archivebox/archivebox:$SHORT_VERSION \ - -t docker.pkg.github.com/archivebox/archivebox/archivebox:latest \ + -t docker.pkg.github.com/archivebox/archivebox/archivebox:$TAG_NAME \ -t docker.pkg.github.com/archivebox/archivebox/archivebox:$VERSION \ -t docker.pkg.github.com/archivebox/archivebox/archivebox:$SHORT_VERSION