代码拉取完成,页面将自动刷新
同步操作将从 好雨科技/Rainbond 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
set -o errexit
# define package name
PROGRAM="gr-rainbond"
WORK_DIR=/go/src/github.com/goodrain/rainbond
BASE_NAME=rainbond
releasedir=./.release
distdir=${releasedir}/dist
GO_VERSION=1.11
VERSION=$(git branch | grep '^*' | cut -d ' ' -f 2 | awk -F'V' '{print $2}')
buildTime=$(date +%F-%H)
git_commit=$(git log -n 1 --pretty --format=%h)
if [ -z "$VERSION" ];then
VERSION=cloud
fi
release_desc=${VERSION}-${git_commit}-${buildTime}
function prepare() {
rm -rf $releasedir
mkdir -pv $releasedir/{tmp,dist}
path=$PWD
[ ! -d "$distdir/usr/local/" ] && mkdir -p $distdir/usr/local/bin
}
function build() {
echo "---> Build Binary For RBD"
echo "rbd plugins version:$release_desc"
echo "build node"
docker run --rm -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:${GO_VERSION} go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -o $releasedir/dist/usr/local/bin/node ./cmd/node
echo "build grctl"
docker run --rm -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:${GO_VERSION} go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -o $releasedir/dist/usr/local/bin/grctl ./cmd/grctl
echo "build certutil"
docker run --rm -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:${GO_VERSION} go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -o $releasedir/dist/usr/local/bin/grcert ./cmd/certutil
cd $releasedir/dist/usr/local/
tar zcf pkg.tgz `find . -maxdepth 1|sed 1d`
cat >Dockerfile <<EOF
FROM alpine:3.6
COPY pkg.tgz /
EOF
docker build -t rainbond/cni:rbd_v$VERSION .
docker push rainbond/cni:rbd_v$VERSION
}
build_items=(api builder entrance grctl monitor mq node webcli worker eventlog)
image_build_items=(api chaos entrance monitor mq webcli worker eventlog)
function localbuild() {
if [ "$1" = "all" ];then
for item in ${build_items[@]}
do
echo "build ${item}"
go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -o _output/${VERSION}/rainbond-$item ./cmd/$item
done
else
echo "build $1"
go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -o _output/${VERSION}/rainbond-$1 ./cmd/$1
fi
}
function build::rpm() {
echo "---> Make Build RPM"
source "hack/build-rpm.sh"
}
function build::deb() {
echo "---> Make Build DEB"
source "hack/build-deb.sh"
}
function build::image() {
echo "---> Build Image:$1 FOR RBD"
DOCKER_PATH=./hack/contrib/docker/$1
HOME=`pwd`
if [ "$1" = "eventlog" ];then
docker build -t goodraim.me/event-build:v1 ${DOCKER_PATH}/build
docker run --rm -v `pwd`:${WORK_DIR} -w ${WORK_DIR} goodraim.me/event-build:v1 go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -o ${DOCKER_PATH}/${BASE_NAME}-$1 ./cmd/eventlog
elif [ "$1" = "chaos" ];then
docker run --rm -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:${GO_VERSION} go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -o ${DOCKER_PATH}/${BASE_NAME}-$1 ./cmd/builder
elif [ "$1" = "monitor" ];then
docker run --rm -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:${GO_VERSION} go build -ldflags "-w -s -extldflags '-static' -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -tags 'netgo static_build' -o ${DOCKER_PATH}/${BASE_NAME}-$1 ./cmd/$1
#go build -ldflags "-w -s -extldflags '-static'" -tags 'netgo static_build' -o ${DOCKER_PATH}/${BASE_NAME}-$1 ./cmd/monitor
else
docker run --rm -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:${GO_VERSION} go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -o ${DOCKER_PATH}/${BASE_NAME}-$1 ./cmd/$1
fi
cd ${DOCKER_PATH}
sed "s/__RELEASE_DESC__/${release_desc}/" Dockerfile > Dockerfile.release
docker build -t ${BASE_NAME}/rbd-$1:${VERSION} -f Dockerfile.release .
rm -f ./Dockerfile.release
rm -f ./${BASE_NAME}-$1
cd $HOME
}
case $1 in
build)
prepare
build
;;
pkg)
prepare
build
build::rpm
build::deb
;;
localbuild)
prepare
localbuild $2
;;
*)
if [ "$1" = "all" ];then
for item in ${image_build_items[@]}
do
echo "build image ${item}"
build::image ${item}
done
else
echo "build image $1"
build::image $1
fi
;;
esac
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。