mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
fix(docker,buildx): 兼容本地registry 模式
This commit is contained in:
3
.editorconfig
Normal file
3
.editorconfig
Normal file
@@ -0,0 +1,3 @@
|
||||
[*.sh]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
@@ -6,24 +6,24 @@ set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
if [ "$DEBUG" == "true" ]; then
|
||||
set -ex ;export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
||||
set -ex
|
||||
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
||||
fi
|
||||
|
||||
readlink_mac() {
|
||||
cd `dirname $1`
|
||||
TARGET_FILE=`basename $1`
|
||||
cd $(dirname $1)
|
||||
TARGET_FILE=$(basename $1)
|
||||
|
||||
# Iterate down a (possible) chain of symlinks
|
||||
while [ -L "$TARGET_FILE" ]
|
||||
do
|
||||
TARGET_FILE=`readlink $TARGET_FILE`
|
||||
cd `dirname $TARGET_FILE`
|
||||
TARGET_FILE=`basename $TARGET_FILE`
|
||||
while [ -L "$TARGET_FILE" ]; do
|
||||
TARGET_FILE=$(readlink $TARGET_FILE)
|
||||
cd $(dirname $TARGET_FILE)
|
||||
TARGET_FILE=$(basename $TARGET_FILE)
|
||||
done
|
||||
|
||||
# Compute the canonicalized name by finding the physical path
|
||||
# for the directory we're in and appending the target file.
|
||||
PHYS_DIR=`pwd -P`
|
||||
PHYS_DIR=$(pwd -P)
|
||||
REAL_PATH=$PHYS_DIR/$TARGET_FILE
|
||||
}
|
||||
|
||||
@@ -40,12 +40,15 @@ get_current_arch() {
|
||||
echo $current_arch
|
||||
}
|
||||
|
||||
pushd $(cd "$(dirname "$0")"; pwd) > /dev/null
|
||||
pushd $(
|
||||
cd "$(dirname "$0")"
|
||||
pwd
|
||||
) >/dev/null
|
||||
readlink_mac $(basename "$0")
|
||||
cd "$(dirname "$REAL_PATH")"
|
||||
CUR_DIR=$(pwd)
|
||||
SRC_DIR=$(cd .. && pwd)
|
||||
popd > /dev/null
|
||||
popd >/dev/null
|
||||
|
||||
DOCKER_DIR="$SRC_DIR/build/docker"
|
||||
|
||||
@@ -85,7 +88,6 @@ build_bin() {
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
build_bundle_libraries() {
|
||||
for bundle_component in 'host-image'; do
|
||||
if [ $1 == $bundle_component ]; then
|
||||
@@ -99,8 +101,25 @@ build_image() {
|
||||
local tag=$1
|
||||
local file=$2
|
||||
local path=$3
|
||||
local arch
|
||||
if [[ "$tag" == *:5000/* ]]; then
|
||||
arch=$(arch)
|
||||
case $arch in
|
||||
x86_64)
|
||||
docker buildx build -t "$tag" -f "$2" "$3" --output type=docker --platform linux/amd64
|
||||
;;
|
||||
aarch64)
|
||||
docker buildx build -t "$tag" -f "$2" "$3" --output type=docker --platform linux/arm64
|
||||
;;
|
||||
*)
|
||||
echo wrong arch
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
docker buildx build -t "$tag" -f "$2" "$3" --push
|
||||
docker pull "$tag"
|
||||
fi
|
||||
}
|
||||
|
||||
buildx_and_push() {
|
||||
@@ -188,6 +207,12 @@ make_manifest_image() {
|
||||
echo "[$(readlink -f ${BASH_SOURCE}):${LINENO} ${FUNCNAME[0]}] return for DRY_RUN"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$img_name" == *:5000/* ]]; then
|
||||
docker push $img_name-amd64
|
||||
docker push $img_name-arm64
|
||||
fi
|
||||
|
||||
docker manifest create --amend --insecure $img_name \
|
||||
$img_name-amd64 \
|
||||
$img_name-arm64
|
||||
|
||||
Reference in New Issue
Block a user