ZLMediaKit/build_docker_images.sh

96 lines
1.6 KiB
Bash
Raw Normal View History

#!/bin/bash
2020-04-06 23:52:45 +08:00
set -e
while getopts c:t:p:m:v: opt
2021-09-13 21:16:22 +08:00
do
case $opt in
t)
type=$OPTARG
;;
v)
2021-09-13 21:16:22 +08:00
version=$OPTARG
;;
p)
platform=$OPTARG
;;
2021-09-13 21:16:22 +08:00
m)
model=$OPTARG
;;
?)
echo "unkonwn"
exit
;;
2021-09-13 21:16:22 +08:00
esac
done
help_string=".sh [-t build|push] [-p (amd64|arm64|...,default is `arch`) ] [-m Debug|Release] [-v [version]]"
2021-09-13 21:16:22 +08:00
if [[ ! -n $type ]];then
echo $help_string
2021-09-13 21:16:22 +08:00
exit
fi
if [[ ! -n $model ]];then
echo $help_string
2021-09-13 21:16:22 +08:00
exit
fi
if [[ ! -n $version ]];then
echo "use latest no version set"
version="latest"
fi
if [[ ! -n $platform ]];then
platform=`arch`
echo "auto select arch:${platform}"
fi
case $platform in
"arm64")
#eg:osx
platform="linux/arm64"
;;
"x86_64"|"amd64")
platform="linux/amd64"
;;
*)
echo "unknown cpu-arch ${platform}"
echo "Use 'docker buildx ls' to get supported ARCH"
exit
;;
esac
2021-09-13 21:16:22 +08:00
case $model in
'Debug')
;;
'Release')
;;
*)
echo "unkonwn model"
echo $help_string
exit
;;
2021-09-13 21:16:22 +08:00
esac
2022-02-24 09:40:58 +08:00
namespace="zlmediakit"
packagename="zlmediakit"
2021-09-13 21:16:22 +08:00
case $type in
'build')
rm -rf ./build/CMakeCache.txt
# 以腾讯云账号为例
docker buildx build --platform=$platform --network=host --build-arg MODEL=$model -t $namespace/$packagename:$model.$version .
#docker build --network=host --build-arg MODEL=$model -t $namespace/$packagename:$model.$version .
2021-09-13 21:16:22 +08:00
;;
'push')
echo "push to dst registry"
# 以腾讯云账号为例
2022-02-24 09:40:58 +08:00
docker login --username=zlmediakit
docker push $namespace/$packagename:$model.$version
2021-09-13 21:16:22 +08:00
;;
*)
echo "unkonwn type"
echo $help_string
exit
;;
2021-09-13 21:16:22 +08:00
esac