2021-02-10 11:58:02 -05:00
|
|
|
#!/bin/bash
|
2021-02-18 16:15:49 -05:00
|
|
|
# Official docker image build script.
|
2021-02-10 11:58:02 -05:00
|
|
|
|
2021-11-09 08:15:16 -05:00
|
|
|
# docker buildx create --name multiarch \
|
|
|
|
# --platform linux/arm/v7,linux/arm/v6,linux/arm64,linux/amd64 \
|
|
|
|
# --config ./buildkit.toml --use --driver-opt image=moby/buildkit:master
|
|
|
|
|
2021-02-18 18:59:08 -05:00
|
|
|
|
|
|
|
usage() {
|
|
|
|
cat << EOF
|
|
|
|
usage: $0 options
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-t The tag/version (${TAG}) (default = master)
|
|
|
|
-d Use Dockerfile-dev for a git clone build
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ALL_PLATFORMS=0
|
|
|
|
DEV=0
|
2021-10-07 10:56:09 -04:00
|
|
|
TAG="latest"
|
|
|
|
BRANCH="master"
|
2021-02-18 18:59:08 -05:00
|
|
|
|
2021-10-07 10:56:09 -04:00
|
|
|
while getopts “t:dab:” OPTION
|
2021-02-18 18:59:08 -05:00
|
|
|
do
|
|
|
|
case $OPTION in
|
|
|
|
t)
|
|
|
|
TAG=$OPTARG
|
|
|
|
;;
|
2021-10-07 10:56:09 -04:00
|
|
|
b)
|
|
|
|
BRANCH=$OPTARG
|
|
|
|
;;
|
2021-02-18 18:59:08 -05:00
|
|
|
a)
|
|
|
|
ALL_PLATFORMS=1
|
|
|
|
;;
|
|
|
|
d)
|
|
|
|
DEV=1
|
|
|
|
;;
|
|
|
|
?)
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2021-11-09 08:15:16 -05:00
|
|
|
VERSION="2.4.2"
|
2021-02-16 10:05:11 -05:00
|
|
|
|
2021-02-18 18:59:08 -05:00
|
|
|
if [ $ALL_PLATFORMS -eq 1 ]
|
|
|
|
then
|
2021-11-09 08:15:16 -05:00
|
|
|
PLATFORMS="linux/arm/v7,linux/arm64,linux/amd64"
|
|
|
|
#PLATFORMS="linux/arm/v7,linux/arm/v6,linux/amd64"
|
2021-02-18 18:59:08 -05:00
|
|
|
else
|
|
|
|
PLATFORMS="linux/amd64"
|
|
|
|
fi
|
|
|
|
|
2021-10-07 10:56:09 -04:00
|
|
|
echo "Build with tag=${TAG} BRANCH=${BRANCH} dev?=${DEV} platforms?=${PLATFORMS}"
|
|
|
|
|
|
|
|
|
|
|
|
echo "Destroying old multiarch build container"
|
|
|
|
docker buildx rm multiarch
|
2021-11-09 08:15:16 -05:00
|
|
|
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
2021-10-07 10:56:09 -04:00
|
|
|
echo "Creating new buildx container"
|
2021-11-09 08:15:16 -05:00
|
|
|
docker buildx create --name multiarch --driver docker-container --use --platform linux/arm/v7,linux/arm/v6,linux/arm64,linux/amd64 --config ./buildkit.toml --use --driver-opt image=moby/buildkit:master
|
|
|
|
docker buildx inspect --bootstrap
|
2021-10-07 10:56:09 -04:00
|
|
|
|
2021-02-18 18:59:08 -05:00
|
|
|
if [ $DEV -eq 1 ]
|
|
|
|
then
|
2021-10-07 10:56:09 -04:00
|
|
|
echo "Build -DEV- with tag=${TAG} BRANCH=${BRANCH} platforms?=${PLATFORMS}"
|
2021-02-18 18:59:08 -05:00
|
|
|
# Use this script to locally build the docker image
|
|
|
|
docker buildx build --push --platform $PLATFORMS \
|
|
|
|
-t harbor.hemna.com/hemna6969/aprsd:$TAG \
|
2021-10-07 10:56:09 -04:00
|
|
|
-f Dockerfile-dev --build-arg branch=$BRANCH --no-cache .
|
2021-02-18 18:59:08 -05:00
|
|
|
else
|
|
|
|
# Use this script to locally build the docker image
|
2021-10-07 10:56:09 -04:00
|
|
|
echo "Build with tag=${TAG} BRANCH=${BRANCH} platforms?=${PLATFORMS}"
|
2021-02-18 18:59:08 -05:00
|
|
|
docker buildx build --push --platform $PLATFORMS \
|
2021-11-09 08:15:16 -05:00
|
|
|
--allow security.insecure \
|
2021-02-18 18:59:08 -05:00
|
|
|
-t hemna6969/aprsd:$VERSION \
|
2021-10-07 10:56:09 -04:00
|
|
|
-t hemna6969/aprsd:$TAG \
|
|
|
|
-t harbor.hemna.com/hemna6969/aprsd:$TAG \
|
2021-02-18 18:59:08 -05:00
|
|
|
-t harbor.hemna.com/hemna6969/aprsd:$VERSION \
|
|
|
|
-f Dockerfile .
|
|
|
|
fi
|