github.com/polarismesh/polaris@v1.17.8/release/build_docker.sh (about)

     1  #!/bin/bash
     2  # Tencent is pleased to support the open source community by making Polaris available.
     3  #
     4  # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
     5  #
     6  # Licensed under the BSD 3-Clause License (the "License");
     7  # you may not use this file except in compliance with the License.
     8  # You may obtain a copy of the License at
     9  #
    10  # https://opensource.org/licenses/BSD-3-Clause
    11  #
    12  # Unless required by applicable law or agreed to in writing, software distributed
    13  # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
    14  # CONDITIONS OF ANY KIND, either express or implied. See the License for the
    15  # specific language governing permissions and limitations under the License.
    16  
    17  
    18  if [ $# != 1 ]; then
    19      echo "e.g.: bash $0 v1.0"
    20      exit 1
    21  fi
    22  
    23  docker_tag=$1
    24  
    25  docker_repository="${DOCKER_REPOSITORY}"
    26  if [[ "${docker_repository}" == "" ]]; then
    27      docker_repository="polarismesh"
    28  fi
    29  
    30  echo "docker repository : ${docker_repository}/polaris-server, tag : ${docker_tag}"
    31  
    32  arch_list=( "amd64" "arm64" )
    33  # arch_list=( "amd64" )
    34  platforms=""
    35  
    36  for arch in ${arch_list[@]}; do
    37      export GOARCH=${arch}
    38      make build VERSION=${docker_tag} ARCH=${arch}
    39  
    40      if [ $? != 0 ]; then
    41          echo "build polaris-server failed"
    42          exit 1
    43      fi
    44  
    45      mv polaris-server polaris-server-${arch}
    46      platforms+="linux/${arch},"
    47  done
    48  
    49  platforms=${platforms::-1}
    50  extra_tags=""
    51  
    52  pre_release=`echo ${docker_tag}|egrep "(alpha|beta|rc|[T|t]est)"|wc -l`
    53  if [ ${pre_release} == 0 ]; then
    54    extra_tags="-t ${docker_repository}/polaris-server:latest"
    55  fi
    56  
    57  docker buildx build -f ./release/Dockerfile -t ${docker_repository}/polaris-server:${docker_tag} ${extra_tags} --platform ${platforms} --push ./