2023-08-13 14:05:00 +08:00
|
|
|
#!/bin/bash
|
|
|
|
#########################
|
|
|
|
# 一键推送dockerhub多架构脚本
|
|
|
|
# @auther: iamtsm
|
|
|
|
# @version: v1.0.0
|
|
|
|
#########################
|
|
|
|
|
|
|
|
build_and_push_manifest() {
|
|
|
|
local image_name=$1
|
|
|
|
local tag=$2
|
|
|
|
local target_name=$3
|
|
|
|
local image_prefix="iamtsm/tl-rtc-file"
|
|
|
|
local arch_arm64="arm64"
|
2023-08-13 14:47:29 +08:00
|
|
|
local arch_amd64="amd64"
|
2023-08-13 14:05:00 +08:00
|
|
|
|
2023-08-13 14:37:50 +08:00
|
|
|
echo "###################################### craete manifest $image_prefix-$target_name:$tag"
|
2023-08-13 14:05:00 +08:00
|
|
|
docker manifest create $image_prefix-$target_name:$tag \
|
|
|
|
$image_prefix-$target_name-$arch_arm64:$tag \
|
2023-08-13 14:47:29 +08:00
|
|
|
$image_prefix-$target_name-$arch_amd64:$tag --amend
|
2023-08-13 14:37:50 +08:00
|
|
|
|
|
|
|
echo "###################################### push manifest $image_prefix-$target_name:$tag"
|
|
|
|
docker manifest push $image_prefix-$target_name:$tag
|
2023-08-13 14:05:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
latest_version=latest
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
# 如果没有传入参数,默认执行所有镜像的打包发布逻辑
|
|
|
|
echo "Please input args"
|
|
|
|
else
|
|
|
|
# 有传入参数时,遍历处理每个参数
|
|
|
|
for image_arg in "$@"; do
|
|
|
|
case $image_arg in
|
|
|
|
api)
|
2023-08-13 14:37:50 +08:00
|
|
|
build_and_push_manifest "api" $latest_version "api"
|
2023-08-13 14:05:00 +08:00
|
|
|
;;
|
|
|
|
socket)
|
2023-08-13 14:37:50 +08:00
|
|
|
build_and_push_manifest "socket" $latest_version "socket"
|
2023-08-13 14:05:00 +08:00
|
|
|
;;
|
|
|
|
mysql)
|
2023-08-13 14:37:50 +08:00
|
|
|
build_and_push_manifest "mysql" $latest_version "mysql"
|
2023-08-13 14:05:00 +08:00
|
|
|
;;
|
|
|
|
coturn)
|
2023-08-13 14:37:50 +08:00
|
|
|
build_and_push_manifest "coturn" $latest_version "coturn"
|
2023-08-13 14:05:00 +08:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Invalid argument: $image_arg"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
fi
|