From 04b1b8d4fcc189a7a6d617c224408cb56b14ac40 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Thu, 6 Jun 2024 21:30:12 -0400 Subject: buildx, asterisk --- build.sh | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'build.sh') diff --git a/build.sh b/build.sh index ba48e56..f0de4af 100755 --- a/build.sh +++ b/build.sh @@ -1,21 +1,35 @@ #!/bin/sh +set -e + remote="g.freya.cat" user="freya" +architectures="linux/amd64,linux/arm64" -docker login "$remote" -u "$user" +init() { + docker login "$remote" -u "$user" + current="$(docker buildx inspect | head -n 1 | awk '{ print $2 }')" + if [ "$current" != "builder" ]; then + docker buildx create --name builder + docker buildx use builder + fi +} build() { - image="$(echo "$1" | tr -d './')" - echo "building $image" - docker build "$image" -t "$remote/$user/$image:latest" - docker push "$remote/$user/$image" + docker buildx build --push --platform "$architectures" "$image" -t "$remote/$user/$image:latest" +} + +build_all() { + images="$(find . -mindepth 1 -maxdepth 1 -type d | grep -v '\./\.' | tr -d './')" + IFS=$'\n' + for image in $images; do + build "$image" + done } +init if [ "$#" -gt 0 ]; then build "$1" else - images="$(find . -mindepth 1 -type d \( -name '.*' -prune -o -print \))" - IFS=$'\n' - for image in $images; do build "$image"; done; + build_all fi -- cgit v1.2.3-freya