-
Notifications
You must be signed in to change notification settings - Fork 231
/
build-debezium-multiplatform.sh
executable file
·143 lines (119 loc) · 4.62 KB
/
build-debezium-multiplatform.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
set -eo pipefail
if [ -z "${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}" ]; then
DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME=quay.io/debezium
fi;
#
# Parameter 1: image name
# Parameter 2: path to component (if different)
# Parameter 3: image tag if different from versioned
#
build_docker_image () {
IMAGE_NAME=$1;
IMAGE_PATH=$2;
IMAGE_TAG=$3;
if [ -z "$IMAGE_PATH" ]; then
IMAGE_PATH=${IMAGE_NAME};
fi
if [ -z "$IMAGE_TAG" ]; then
IMAGE_TAG=${DEBEZIUM_VERSION};
fi
IMAGE_PATH="${IMAGE_PATH}/${IMAGE_TAG}"
if ! [ -d "$IMAGE_PATH" ]; then
echo ""
echo "****************************************************************"
echo "** Directory ${IMAGE_PATH} does not exist, skipping"
echo "****************************************************************"
echo ""
return
fi
PLATFORM_VAR=$(echo "$IMAGE_NAME" | tr '[:lower:]' '[:upper:]' | tr - _)_PLATFORM
PLATFORM=${!PLATFORM_VAR}
if [ -z "${PLATFORM}" ]; then
PLATFORM=${DEFAULT_PLATFORM};
fi;
echo ""
echo "****************************************************************"
echo "** Validating ${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/${IMAGE_NAME}"
echo "****************************************************************"
echo ""
docker run --rm -i hadolint/hadolint:latest < "${IMAGE_PATH}"
echo "****************************************************************"
echo "** Building ${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/${IMAGE_NAME}:${IMAGE_TAG}"
echo "****************************************************************"
TAGS=("-t ${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/${IMAGE_NAME}:latest")
if [ -z "$RELEASE_TAG" ]; then
echo "****************************************************************"
echo "** Stream Tag ${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/${IMAGE_NAME}:${IMAGE_TAG} "
echo "****************************************************************"
TAGS+=("-t ${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/${IMAGE_NAME}:${IMAGE_TAG}")
if [ -n "${DEBEZIUM_DOCKER_REGISTRY_SECONDARY_NAME}" ]; then
TAGS+=("-t ${DEBEZIUM_DOCKER_REGISTRY_SECONDARY_NAME}/${IMAGE_NAME}:${IMAGE_TAG}")
fi;
fi;
if [ -n "$RELEASE_TAG" ]; then
echo "****************************************************************"
echo "** Release Tag ${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/${IMAGE_NAME}:${RELEASE_TAG} "
echo "****************************************************************"
TAGS+=("-t ${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/${IMAGE_NAME}:${RELEASE_TAG}")
if [ -n "${DEBEZIUM_DOCKER_REGISTRY_SECONDARY_NAME}" ]; then
TAGS+=("-t ${DEBEZIUM_DOCKER_REGISTRY_SECONDARY_NAME}/${IMAGE_NAME}:${RELEASE_TAG}")
fi;
fi
echo "Build Image with Tags " "${TAGS[@]}" " and platform ${PLATFORM}"
# shellcheck disable=SC2068
docker buildx build --push --platform "${PLATFORM}" \
--progress=plain \
--build-arg DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME="$DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME" \
--label "build-at=$(date +%s)" \
${TAGS[@]} \
"${IMAGE_PATH}"
}
function usage() {
MSG=$1
echo ""
echo "$MSG"
echo ""
echo "Usage: build-debezium <version> <platform>";
echo ""
echo " Where platform can be for example:"
echo " linux/amd64"
echo " linux/amd64,linux/arm64"
echo " linux/arm64"
echo ""
echo " Note that you can specify platforms for each component"
echo " individually by setting an env variable <component-in-uppercase>_PLATFORM"
echo " (for example BASE_CONNECT_PLATFORM=amd/linux64)"
echo ""
exit 1;
}
if [[ -z "$1" ]]; then
usage "A version must be specified."
fi
if [[ -z "$2" ]]; then
usage "Platform must be specified."
fi
DEFAULT_PLATFORM=$2
DEBEZIUM_VERSION="$1"
build_docker_image base base latest
build_docker_image zookeeper
build_docker_image kafka
build_docker_image connect-base
build_docker_image connect
build_docker_image server
build_docker_image operator
if [[ "$SKIP_UI" != "true" ]]; then
build_docker_image debezium-ui ui
fi
build_docker_image example-mysql examples/mysql
build_docker_image example-mysql-gtids examples/mysql-gtids
build_docker_image example-mysql-master examples/mysql-replication/master
build_docker_image example-mysql-replica examples/mysql-replication/replica
build_docker_image example-mariadb examples/mariadb
build_docker_image example-postgres examples/postgres
build_docker_image example-mongodb examples/mongodb
echo ""
echo "**********************************"
echo "Successfully created Docker images"
echo "**********************************"
echo ""