switch to using docker buildx with multi-arch
This commit is contained in:
+52
-17
@@ -1,20 +1,55 @@
|
||||
#!/bin/bash
|
||||
archs='amd64 i386 arm32v5 arm32v7 arm64v8'
|
||||
images='stretch buster bullseye'
|
||||
UPLOAD_URL='http://'`hostname`'/ebusdreleaseupload.php'
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "usage: $0 [release|UPLOADHOST]"
|
||||
echo " without arguments: build and push devel docker images"
|
||||
echo " release: build and push release docker images from latest release binaries"
|
||||
echo " UPLOADHOST: build Debian release packages (with and without MQTT) and upload them to UPLOADHOST"
|
||||
exit 1
|
||||
fi
|
||||
archs=linux/amd64,linux/386,linux/arm/v7,linux/arm64
|
||||
if [[ -z "$1" ]] || [[ "x$1" == "xrelease" ]]; then
|
||||
UPLOAD_URL=
|
||||
else
|
||||
UPLOAD_URL="http://$1/ebusdreleaseupload.php"
|
||||
fi
|
||||
UPLOAD_CREDENTIALS='anonymous:build'
|
||||
for image in $images; do
|
||||
dir=$image
|
||||
mkdir -p $dir
|
||||
BASE_IMAGE=debian:$image ./update.sh $dir/
|
||||
for arch in $archs; do
|
||||
if [ "$arch" != "amd64" ]; then
|
||||
suffix=".$arch"
|
||||
else
|
||||
suffix=''
|
||||
fi
|
||||
docker build $@ --target build --build-arg "UPLOAD_URL=$UPLOAD_URL" --build-arg "UPLOAD_CREDENTIALS=$UPLOAD_CREDENTIALS" --build-arg "UPLOAD_OS=$image" -f $dir/Dockerfile$suffix .
|
||||
done
|
||||
rm -rf $dir
|
||||
done
|
||||
version=`cat ../../VERSION`
|
||||
source='../..'
|
||||
images='bullseye'
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
namesuffix=''
|
||||
target=image
|
||||
outputFmt='-o type=docker,type=registry'
|
||||
tagsuffix=':devel'
|
||||
elif [[ "x$1" = "xrelease" ]]; then
|
||||
archs=linux/amd64
|
||||
namesuffix='.release'
|
||||
target=image
|
||||
outputFmt='-o type=docker,type=registry'
|
||||
tagsuffix=":v$version"
|
||||
else
|
||||
namesuffix='.build'
|
||||
target=build
|
||||
images='bullseye buster stretch'
|
||||
outputFmt=-q
|
||||
tagsuffix=":v$version-prep"
|
||||
fi
|
||||
|
||||
for image in $images; do
|
||||
output=$(echo "$outputFmt"|sed -e "s#%IMAGE%#$image#g")
|
||||
docker buildx build \
|
||||
--target $target \
|
||||
--progress pain \
|
||||
--platform $archs \
|
||||
-f Dockerfile${namesuffix} \
|
||||
--build-arg "BASE_IMAGE=debian:$image" \
|
||||
--build-arg "EBUSD_VERSION=$version" \
|
||||
--build-arg "EBUSD_IMAGE=$image" \
|
||||
--build-arg "UPLOAD_URL=$UPLOAD_URL" \
|
||||
--build-arg "UPLOAD_CREDENTIALS=$UPLOAD_CREDENTIALS" \
|
||||
--build-arg "UPLOAD_OS=$image" \
|
||||
-t ebusd$tagsuffix \
|
||||
$output \
|
||||
$source
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user