-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathbuild
executable file
·55 lines (46 loc) · 1.2 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
set -o errexit
set -o xtrace
test_dir="$(dirname $0)"
. $(dirname $0)/functions
src_dir="$(realpath ${test_dir}/..)"
IMAGE=$(echo "$IMAGE" | sed -e 's#percona/#perconalab/#')
if [[ ${DOCKER_NOCACHE:-0} == 1 ]]; then
no_cache="--no-cache"
fi
if [[ ${DOCKER_SQUASH:-1} == 1 ]]; then
squash="--squash"
fi
if [[ ${DOCKER_PUSH:-1} == 1 ]]; then
imgresult="--push=true"
else
imgresult="--load"
fi
build_operator() {
if [ "${RELEASE:-1}" = 0 ]; then
GO_LDFLAGS="-race"
fi
export IMAGE
export DOCKER_DEFAULT_PLATFORM=${DOCKER_DEFAULT_PLATFORM:-"linux/amd64"}
export GO_LDFLAGS="-w -s -trimpath $GO_LDFLAGS"
if echo "$DOCKER_DEFAULT_PLATFORM" | grep -q ','; then
if [ "${DOCKER_PUSH:-1}" = 0 ]; then
echo "'docker $build_command' doesn't support DOCKER_PUSH=0 option in case of multi-arch builds, please use DOCKER_PUSH=1"
exit 1
fi
fi
pushd ${src_dir}
docker buildx build \
--platform $DOCKER_DEFAULT_PLATFORM \
--build-arg GIT_COMMIT=$GIT_COMMIT \
--build-arg GIT_BRANCH=$GIT_BRANCH \
--build-arg GO_LDFLAGS="$GO_LDFLAGS" \
--progress plain \
$squash \
$imgresult \
$no_cache \
-t "${IMAGE}" -f build/Dockerfile .
popd
}
until docker ps; do sleep 1; done
build_operator