forked from ZLMediaKit/ZLMediaKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_docker_images.sh
95 lines (86 loc) · 1.57 KB
/
build_docker_images.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
set -e
while getopts c:t:p:m:v: opt
do
case $opt in
t)
type=$OPTARG
;;
v)
version=$OPTARG
;;
p)
platform=$OPTARG
;;
m)
model=$OPTARG
;;
?)
echo "unkonwn"
exit
;;
esac
done
help_string=".sh [-t build|push] [-p (amd64|arm64|...,default is `arch`) ] [-m Debug|Release] [-v [version]]"
if [[ ! -n $type ]];then
echo $help_string
exit
fi
if [[ ! -n $model ]];then
echo $help_string
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
case $model in
'Debug')
;;
'Release')
;;
*)
echo "unkonwn model"
echo $help_string
exit
;;
esac
namespace="zlmediakit"
packagename="zlmediakit"
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 .
;;
'push')
echo "push to dst registry"
# 以腾讯云账号为例
docker login --username=zlmediakit
docker push $namespace/$packagename:$model.$version
;;
*)
echo "unkonwn type"
echo $help_string
exit
;;
esac