krrish 7 anni fa
parent
commit
85e849ddf3
3 ha cambiato i file con 52 aggiunte e 22 eliminazioni
  1. 12 12
      build/build_images.sh
  2. 13 0
      build/pushToRemote.sh.sh
  3. 27 10
      deploy/deploy_latest.sh

+ 12 - 12
build/build_images.sh

@@ -73,15 +73,15 @@ function fn_build_images()
     docker push "${MIRROR_ADDRESS}"/"${PROJECT_NAME}"/"${WANGYUAN_NAME}"/"${images_name}":"${IMAGE_VERSION}" >"${ERROR_LOG}" 2>&1
     if [ $? -ne 0 ]
     then
-  echo "retry pushing after 3 seconds..."
-  sleep 3
+	echo "retry pushing after 3 seconds..."
+	sleep 3 
         docker push "${MIRROR_ADDRESS}"/"${PROJECT_NAME}"/"${WANGYUAN_NAME}"/"${images_name}":"${IMAGE_VERSION}" >"${ERROR_LOG}" 2>&1
         if [ $? -ne 0 ]; then
-      fn_print_err "docker push ${MIRROR_ADDRESS}/${PROJECT_NAME}/${WANGYUAN_NAME}/${images_name}:${IMAGE_VERSION}  failure." || return $?
+	    fn_print_err "docker push ${MIRROR_ADDRESS}/${PROJECT_NAME}/${WANGYUAN_NAME}/${images_name}:${IMAGE_VERSION}  failure." || return $?
         fi
     fi
 
-    echo
+    echo 
     echo "Ready to push latest image"
     sleep 3
 
@@ -90,19 +90,19 @@ function fn_build_images()
     if [ $? -ne 0 ]
     then
         echo "retry push latest after 3 seconds..."
-  sleep 3
+	sleep 3 
         docker push "${MIRROR_ADDRESS}"/"${PROJECT_NAME}"/"${WANGYUAN_NAME}"/"${images_name}":"latest" >"${ERROR_LOG}" 2>&1
         if [ $? -ne 0 ]; then
-      fn_print_err "docker push ${MIRROR_ADDRESS}/${PROJECT_NAME}/${WANGYUAN_NAME}/${images_name}:latest  failure." || return $?
+	    fn_print_err "docker push ${MIRROR_ADDRESS}/${PROJECT_NAME}/${WANGYUAN_NAME}/${images_name}:latest  failure." || return $?
         fi
     fi
 
     sleep 5
     docker pull "${MIRROR_ADDRESS}"/"${PROJECT_NAME}"/"${WANGYUAN_NAME}"/"${images_name}":"latest" >"${ERROR_LOG}" 2>&1
-    if [ $? -ne 0 ]
+    if [ $? -ne 0 ] 
     then
         fn_print_err "Pull<${MIRROR_ADDRESS}/${PROJECT_NAME}/${WANGYUAN_NAME}/${images_name}:latest> failure." || return $?
-    fi
+    fi  
 
     return 0
 
@@ -150,12 +150,12 @@ fn_main()
     MODUL_NAME=$1
     local svn_number=$2
     PROJECT_NAME=$3
-
+    
     #定义日志打印的路径
     BUILD_LOG=/tmp/${MODUL_NAME}/build.log
     ERROR_LOG=/tmp/${MODUL_NAME}/error.log
-
-    #创建日志文件
+   
+    #创建日志文件 
     [ -d /tmp/${MODUL_NAME} ] && rm -rf /tmp/${MODUL_NAME}
     mkdir -p /tmp/${MODUL_NAME}
     cd /tmp/${MODUL_NAME} && touch build.log error.log
@@ -198,7 +198,7 @@ fn_main()
     #build镜像
     cd /tmp/${MODUL_NAME}
     tms_success "Start build ${MODUL_NAME} images."
-
+   
     # modify by dongcj
     fn_build_images "${images_name}" >"${ERROR_LOG}" 2>&1
     if [ $? -ne 0 ]

+ 13 - 0
build/pushToRemote.sh.sh

@@ -1,4 +1,5 @@
 #!/bin/bash
+# 
 
 # check input
 if [ -z "$1" ]; then
@@ -35,6 +36,16 @@ while true; do
 
 done
 
+# feature
+echo
+echo "  在这台服务器上推拉镜像到法国,会比其它服务器快至少 10 倍的速度 :)"
+echo "  点解...?"
+echo
+which cstream &>/dev/nulll &&  \
+  echo "  科学上网,你值得拥有! --- Need help? QQ: 85509336" | cstream -b1 -t10 || \
+  echo "  科学上网,你值得拥有! --- Need help? QQ: 85509336" && sleep 1 
+echo 
+
 # make a host entry
 if ! grep -q "registry.svicloud.com" /etc/hosts; then
     echo "151.106.8.135 registry.svicloud.com" >>/etc/hosts
@@ -51,6 +62,8 @@ docker login -u admin -p Changeme_123 registry.svicloud.com &>/dev/null || \
 if docker pull $1; then
     sed -i "/^[#].*registry.svicloud.com/s/^#//" /etc/hosts
     sleep 2
+    echo "checking remote registry status with ping 5 packages"
+    ping registry.svicloud.com -c 5
     docker login -u admin -p "Gocm5]WeqaSufg" registry.svicloud.com &>/dev/null || \
       { echo "docker login to remote repo failed" && echo && exit 1; } 
     echo

+ 27 - 10
deploy/deploy_latest.sh

@@ -6,7 +6,7 @@
 # deploy specify app:                                   ./$1 --module="modle1,module2,module3"
 # deploy to specify env:                                ./$1 --env="test"
 # deploy with specify git branch, default master        ./$1 --git-branch="dev"
-
+# deploy with specify version, default 0                ./$1 --compose_version=1
 
 # deploy base dir
 WORKDIR="/tmp/wisecloud_deploy"
@@ -71,7 +71,7 @@ if git branch -a | grep -wq "${GIT_BRANCH}"; then
     current_branch=`git branch | grep "\*" | awk '{print $2}'`
     if [ "${GIT_BRANCH}" != "${current_branch}" ]; then
         # checkout 
-        git checkout -b ${GIT_BRANCH}
+        git checkout -b ${GIT_BRANCH} &>/dev/null
     fi
     
     # reset hard the branch
@@ -88,18 +88,25 @@ fi
 
 ENV=`echo $* | xargs -n 1 | grep "\-env" | awk -F"=" '{print $2}' | tr ',' ' '`
 echo "deploy to env=$ENV"
-if [ "$ENV" == "powercloudtest" ]; then
-    RANCHER_ACCESS_KEY=0CA5094E8E4562442D99
-    RANCHER_SECRET_KEY=7TH5j64DSUPFbf6b9cFr4mp7Brq5iUrPBSx6sJxM
-elif [ "$ENV" == "test" ]; then
-    RANCHER_ACCESS_KEY=C98222E5206624BFB807
-    RANCHER_SECRET_KEY=LBg2tF96miU8rBPgN2kR9uXV2qbrKKuQTrTEy5Wq
-elif [ "$ENV" == "cs" ]; then
+if [ "$ENV" == "cs" ]; then
     RANCHER_ACCESS_KEY=344E9FA150DD81B6F254
     RANCHER_SECRET_KEY=9tBspbMqp3ny8ZzXbBBTpYNke5fhgLPWfXyvqqTi
+
 elif [ "$ENV" == "powercloud" ]; then
     RANCHER_ACCESS_KEY=DB9833C639BCA696277F
     RANCHER_SECRET_KEY=dJBSgKxYUSXTm2n7dvijsjdndt8P37srrhZxwgqE
+    
+elif [ "$ENV" == "powercloudtest" ]; then
+    RANCHER_ACCESS_KEY=DDB533DC33E600A4862F
+    RANCHER_SECRET_KEY=iLSsbdpf3FR5ThFDW2S4XsX6j2WZtu1zmw4nopU2
+    
+elif [ "$ENV" == "test" ]; then
+    RANCHER_ACCESS_KEY=C98222E5206624BFB807
+    RANCHER_SECRET_KEY=LBg2tF96miU8rBPgN2kR9uXV2qbrKKuQTrTEy5Wq
+
+elif [ "$ENV" == "wmsdev" ]; then
+    RANCHER_ACCESS_KEY=3DD561A59A4648A7CA6E
+    RANCHER_SECRET_KEY=z7Nxtad8UmdsTacRiBn1A2BqNEyQNW2xNzXpar2o
 else
     echo "#####################################"
     echo "Please specify the right env that has access key and secret key, exit!"
@@ -156,7 +163,17 @@ for module in $APP; do
         # fi
     # fi
 
-    cd ${WORKDIR}/wisecloud-catalog/templates/$module/0
+    COMPOSE_VERSION=`echo $* | xargs -n 1 | grep "\-compose_version" | awk -F"=" '{print $2}' | tr ',' ' '`
+    if [ -z "$COMPOSE_VERSION" ]; then
+        compose_version_number=0
+    else
+        compose_version_number=$COMPOSE_VERSION
+    fi
+    if ! cd ${WORKDIR}/wisecloud-catalog/templates/$module/${compose_version_number}; then
+        echo "  Maybe you have input the wrong compose_version"
+        exit 1
+    fi
+    
     #curl -OL ${GIT_TEMPLATE_URL}/$module/0/rancher-compose.yml . 2>/dev/null
     #curl -OL ${GIT_TEMPLATE_URL}/$module/0/docker-compose.yml . 2>/dev/null