Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions scripts/docker_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ get_current_arch() {
echo $current_arch
}

ALLARCH=("amd64" "arm64" "riscv64")

pushd $(cd "$(dirname "$0")"; pwd) > /dev/null
readlink_mac $(basename "$0")
cd "$(dirname "$REAL_PATH")"
Expand Down Expand Up @@ -89,10 +91,8 @@ get_image_name() {
local arch=$2
local is_all_arch=$3
local img_name="$REGISTRY/$component:$TAG"
if [[ -n "$arch" ]]; then
if [[ "$is_all_arch" == "true" || "$arch" != "$CURRENT_ARCH" ]]; then
img_name="${img_name}-$arch"
fi
if [[ -n "$arch" && "$is_all_arch" == "true" ]]; then
img_name="${img_name}-$arch"
fi
echo $img_name
}
Expand All @@ -113,15 +113,20 @@ build_process_with_buildx() {

make_manifest_image() {
local component=$1
local arch=$2
local img_name=$(get_image_name $component "" "false")
if [[ "$DRY_RUN" == "true" ]]; then
echo "[$(readlink -f ${BASH_SOURCE}):${LINENO} ${FUNCNAME[0]}] return for DRY_RUN"
return
fi
docker buildx imagetools create -t $img_name \
$img_name-amd64 \
$img_name-arm64 \
$img_name-riscv64
CMD="docker buildx imagetools create -t ${img_name} "
for ac in "${ALLARCH[@]}"; do
if [[ "${arch}" == "all" || "${arch}" == *"$ac"* ]]; then
CMD="${CMD} ${img_name}-${ac}"
fi
done
echo "$CMD"
$CMD
}

show_update_cmd() {
Expand All @@ -134,16 +139,18 @@ cd $SRC_DIR

echo "Start to build for arch[$ARCH]"

case "$ARCH" in
all)
for arch in "arm64" "amd64" "riscv64"; do
build_process_with_buildx $arch "true"
done
make_manifest_image $image_keyword
;;
*)
multiarch=""
for ac in "${ALLARCH[@]}"; do
if [[ "$ARCH" == "$ac" ]]; then
# single arch
build_process_with_buildx $ARCH "false"
;;
esac
elif [[ "$ARCH" == "all" || "$ARCH" == *"$ac"* ]]; then
multiarch="true"
build_process_with_buildx $ac "true"
fi
done
if [[ "$multiarch" == "true" ]]; then
make_manifest_image "sdnagent" $ARCH
fi

show_update_cmd
Loading