1
0
mirror of https://github.com/craigerl/aprsd.git synced 2026-06-17 13:18:52 -04:00
Files
aprsd/docker/build.sh
T

107 lines
2.5 KiB
Bash
Raw Normal View History

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
# 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:
2022-11-25 10:05:16 -05:00
-h Show help
2021-02-18 18:59:08 -05:00
-t The tag/version (${TAG}) (default = master)
-d Use Dockerfile-dev for a git clone build
2022-11-25 10:05:16 -05:00
-b Branch to use (default = master)
2022-12-12 19:29:45 -05:00
-r Destroy and rebuild the buildx environment
2023-01-31 17:36:39 +00:00
-v aprsd version to build
2021-02-18 18:59:08 -05:00
EOF
}
ALL_PLATFORMS=0
DEV=0
2022-12-12 19:29:45 -05:00
REBUILD_BUILDX=0
2021-10-07 10:56:09 -04:00
TAG="latest"
2022-11-25 10:05:16 -05:00
BRANCH=${BRANCH:-master}
2024-04-23 09:38:37 -04:00
VERSION="3.3.4"
2021-02-18 18:59:08 -05:00
2022-12-12 19:29:45 -05:00
while getopts “hdart:b:v:” 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
;;
2022-12-12 19:29:45 -05:00
r)
REBUILD_BUILDX=1
;;
2021-02-18 18:59:08 -05:00
d)
DEV=1
;;
2022-12-12 19:29:45 -05:00
v)
VERSION=$OPTARG
;;
2022-11-25 10:05:16 -05:00
h)
usage
exit 0
;;
2021-02-18 18:59:08 -05:00
?)
usage
2022-11-25 10:05:16 -05:00
exit -1
2021-02-18 18:59:08 -05:00
;;
esac
done
2021-02-16 10:05:11 -05:00
2021-02-18 18:59:08 -05:00
if [ $ALL_PLATFORMS -eq 1 ]
then
2023-01-31 17:36:39 +00:00
PLATFORMS="linux/arm64,linux/amd64"
#PLATFORMS="linux/arm/v7,linux/arm/v6,linux/amd64"
2023-01-31 17:36:39 +00:00
#PLATFORMS="linux/arm64"
2021-02-18 18:59:08 -05:00
else
2022-12-12 19:29:45 -05:00
PLATFORMS="linux/amd64"
2021-02-18 18:59:08 -05:00
fi
2021-10-07 10:56:09 -04:00
2022-12-12 19:29:45 -05:00
if [ $REBUILD_BUILDX -eq 1 ]
then
echo "Destroying old multiarch build container"
docker buildx rm multiarch
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
echo "Creating new buildx container"
docker buildx create --name multiarch --driver docker-container --use \
--config ./buildkit.toml --use \
--driver-opt image=moby/buildkit:master
docker buildx inspect --bootstrap
fi
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 \
2023-04-17 15:45:49 +00:00
-t hemna6969/aprsd:$TAG \
2024-05-23 09:59:41 -04:00
--build-arg INSTALL_TYPE=github \
--build-arg branch=$BRANCH \
--build-arg BUILDX_QEMU_ENV=true \
--no-cache .
2021-02-18 18:59:08 -05:00
else
# Use this script to locally build the docker image
2022-12-12 19:29:45 -05:00
echo "Build with tag=${TAG} BRANCH=${BRANCH} dev?=${DEV} platforms?=${PLATFORMS} VERSION=${VERSION}"
2021-02-18 18:59:08 -05:00
docker buildx build --push --platform $PLATFORMS \
2022-12-12 19:29:45 -05:00
--build-arg VERSION=$VERSION \
--build-arg BUILDX_QEMU_ENV=true \
2021-02-18 18:59:08 -05:00
-t hemna6969/aprsd:$VERSION \
2021-10-07 10:56:09 -04:00
-t hemna6969/aprsd:$TAG \
2024-05-23 09:59:41 -04:00
-t hemna6969/aprsd:latest .
2021-02-18 18:59:08 -05:00
fi