add cross-platform docker build support

This commit is contained in:
Nick Sweeting 2023-03-13 11:57:20 +00:00
parent 606fa397a4
commit e5eee4e0b6

View file

@ -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