Docker buildx setup for multiple architectures

This commit is contained in:
eikek
2021-06-08 01:58:05 +02:00
parent ecc1e44e29
commit 76e47310ce
5 changed files with 50 additions and 49 deletions

View File

@ -10,27 +10,52 @@ if [[ $version == v* ]]; then
version="${version:1}"
fi
push=""
if [ -z "$2" ] || [ "$2" == "--push" ]; then
push="$2"
if [ ! -z "$push" ]; then
echo "Running with $push !"
fi
else
echo "Don't understand second argument: $2"
exit 1
fi
if ! docker buildx version > /dev/null; then
echo "The docker buildx command is required."
echo "See: https://github.com/docker/buildx#binary-release"
exit 1
fi
set -e
cd "$(dirname "$0")"
trap "{ docker buildx rm docspell-builder; }" EXIT
platforms="linux/amd64,linux/aarch64,linux/arm/v7"
docker buildx create --name docspell-builder --use
if [[ $version == *SNAPSHOT* ]]; then
echo ">>>> Building nightly images for $version <<<<<"
url_base="https://github.com/eikek/docspell/releases/download/nightly"
echo "============ Building Tools ============"
docker build \
docker buildx build \
--platform="$platforms" $push \
--build-arg tools_url="$url_base/docspell-tools-$version.zip" \
--tag docspell/tools:nightly \
-f tools.dockerfile .
echo "============ Building Restserver ============"
docker build \
docker buildx build \
--platform="$platforms" $push \
--build-arg restserver_url="$url_base/docspell-restserver-$version.zip" \
--tag docspell/restserver:nightly \
-f restserver.dockerfile .
echo "============ Building Joex ============"
docker build \
docker buildx build \
--platform="$platforms" $push \
--build-arg joex_url="$url_base/docspell-joex-$version.zip" \
--tag docspell/joex:nightly \
-f joex.dockerfile .
@ -38,6 +63,7 @@ else
echo ">>>> Building release images for $version <<<<<"
echo "============ Building Tools ============"
docker build \
--platform="$platforms" $push \
--build-arg version=$version \
--tag docspell/tools:v$version \
--tag docspell/tools:latest \
@ -45,6 +71,7 @@ else
echo "============ Building Restserver ============"
docker build \
--platform="$platforms" $push \
--build-arg version=$version \
--tag docspell/restserver:v$version \
--tag docspell/restserver:latest \
@ -52,6 +79,7 @@ else
echo "============ Building Joex ============"
docker build \
--platform="$platforms" $push \
--build-arg version=$version \
--tag docspell/joex:v$version \
--tag docspell/joex:latest \