github.com/percona/percona-xtradb-cluster-operator@v1.14.0/e2e-tests/build (about)

     1  #!/bin/bash
     2  
     3  set -o errexit
     4  
     5  test_dir="$(dirname $0)"
     6  . $(dirname $0)/functions
     7  src_dir="$(realpath ${test_dir}/..)"
     8  
     9  set_debug
    10  
    11  IMAGE=$(echo "$IMAGE" | sed -e 's#percona/#perconalab/#')
    12  
    13  if [[ ${DOCKER_NOCACHE:-0} == 1 ]]; then
    14  	no_cache="--no-cache"
    15  fi
    16  if [[ ${DOCKER_SQUASH:-1} == 1 ]]; then
    17  	squash="--squash"
    18  fi
    19  
    20  if [[ ${DOCKER_PUSH:-1} == 1 ]]; then
    21  	imgresult="--push=true"
    22  else
    23  	imgresult="--load"
    24  fi
    25  
    26  build_operator() {
    27  	if [ "${RELEASE:-1}" = 0 ]; then
    28  		GO_LDFLAGS="-race"
    29  	fi
    30  
    31  	export IMAGE
    32  	export DOCKER_DEFAULT_PLATFORM=${DOCKER_DEFAULT_PLATFORM:-"linux/amd64,linux/arm64"}
    33  	export GO_LDFLAGS="-w -s -trimpath $GO_LDFLAGS"
    34  	pushd ${src_dir}
    35  	docker buildx build \
    36  		--platform $DOCKER_DEFAULT_PLATFORM \
    37  		--build-arg GIT_COMMIT=$GIT_COMMIT \
    38  		--build-arg GIT_BRANCH=$GIT_BRANCH \
    39  		--build-arg BUILD_TIME=$BUILD_TIME \
    40  		--build-arg GO_LDFLAGS="$GO_LDFLAGS" \
    41  		$imgresult \
    42  		$squash \
    43  		$no_cache \
    44  		-t "${IMAGE}" -f build/Dockerfile .
    45  	popd
    46  
    47  }
    48  
    49  if [[ $BUILD == "0" ]]; then
    50  	exit 0
    51  fi
    52  
    53  until docker ps; do sleep 1; done
    54  build_operator