mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
Merge pull request #1958 from amani-lei/patch-1
使用docker buildx, 用于支持跨平台build
This commit is contained in:
commit
c094751f17
@ -1,31 +1,36 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
while getopts c:t:m:v: opt
|
while getopts c:t:p:m:v: opt
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
t)
|
t)
|
||||||
type=$OPTARG
|
type=$OPTARG
|
||||||
;;
|
;;
|
||||||
v)
|
v)
|
||||||
version=$OPTARG
|
version=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
p)
|
||||||
|
platform=$OPTARG
|
||||||
|
;;
|
||||||
m)
|
m)
|
||||||
model=$OPTARG
|
model=$OPTARG
|
||||||
;;
|
;;
|
||||||
?)
|
?)
|
||||||
echo "unkonwn"
|
echo "unkonwn"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
help_string=".sh [-t build|push] [-p (amd64|arm64|...,default is `arch`) ] [-m Debug|Release] [-v [version]]"
|
||||||
|
|
||||||
if [[ ! -n $type ]];then
|
if [[ ! -n $type ]];then
|
||||||
echo ".sh [-t build|push] [-m Debug|Release] [-v [version]]"
|
echo $help_string
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -n $model ]];then
|
if [[ ! -n $model ]];then
|
||||||
echo ".sh [-t build|push] [-m Debug|Release] [-v [version]]"
|
echo $help_string
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -34,16 +39,36 @@ if [[ ! -n $version ]];then
|
|||||||
version="latest"
|
version="latest"
|
||||||
fi
|
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
|
||||||
|
|
||||||
case $model in
|
case $model in
|
||||||
'Debug')
|
'Debug')
|
||||||
;;
|
;;
|
||||||
'Release')
|
'Release')
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "unkonwn model"
|
echo "unkonwn model"
|
||||||
echo ".sh [-t build|push] [-m Debug|Release] [-v [version]]"
|
echo $help_string
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
namespace="zlmediakit"
|
namespace="zlmediakit"
|
||||||
@ -53,7 +78,8 @@ case $type in
|
|||||||
'build')
|
'build')
|
||||||
rm -rf ./build/CMakeCache.txt
|
rm -rf ./build/CMakeCache.txt
|
||||||
# 以腾讯云账号为例
|
# 以腾讯云账号为例
|
||||||
docker build --network=host --build-arg MODEL=$model -t $namespace/$packagename:$model.$version .
|
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 .
|
||||||
;;
|
;;
|
||||||
'push')
|
'push')
|
||||||
echo "push to dst registry"
|
echo "push to dst registry"
|
||||||
@ -62,8 +88,8 @@ case $type in
|
|||||||
docker push $namespace/$packagename:$model.$version
|
docker push $namespace/$packagename:$model.$version
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "unkonwn type"
|
echo "unkonwn type"
|
||||||
echo ".sh [-t build|push] [-m Debug|Release] [-v [version]]"
|
echo $help_string
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user