1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616
17- # Build container images for KCP using Docker
17+ # Build container images for kcp using Docker
1818#
1919# This script builds container images using Docker (with or without buildx).
2020#
2121# Usage examples:
2222# # Build locally with default settings (uses current git commit hash)
2323# ./hack/build-image-docker.sh
24- #
24+ #
2525# # Build locally with custom repository name
2626# REPOSITORY=my-registry/kcp ./hack/build-image-docker.sh
27- #
27+ #
2828# # Build locally without pushing (dry run)
2929# DRY_RUN=1 ./hack/build-image-docker.sh
30- #
30+ #
3131# # Build for specific architectures only
3232# ARCHITECTURES="amd64" ./hack/build-image-docker.sh
3333#
3838# KCP_GHCR_USERNAME/KCP_GHCR_PASSWORD - Registry credentials for pushing
3939#
4040# Build tool support:
41- # - docker + buildx: Multi-arch support with intelligent platform handling
41+ # - docker + buildx: Multi-arch support with intelligent platform handling
4242# - docker only: Single architecture fallback
4343
4444set -euo pipefail
@@ -105,7 +105,7 @@ echo "Building container image $image ..."
105105# Function to build images with docker buildx
106106build_with_docker_buildx () {
107107 echo " Building multi-arch image $image ..."
108-
108+
109109 # Create platforms string for buildx
110110 platforms=" "
111111 for arch in $architectures ; do
@@ -115,7 +115,7 @@ build_with_docker_buildx() {
115115 platforms=" linux/$arch "
116116 fi
117117 done
118-
118+
119119 # For push builds, use multi-platform; for local builds, build per arch
120120 if [ -z " ${DRY_RUN:- } " ]; then
121121 # Building for push - use multi-platform with --push
@@ -151,7 +151,7 @@ build_with_docker() {
151151 # Use only the first architecture for regular docker
152152 arch=$( echo $architectures | cut -d' ' -f1)
153153 fullTag=" $image -$arch "
154-
154+
155155 echo " Building single-arch image $fullTag (docker without buildx) ..."
156156 docker build \
157157 --file Dockerfile \
@@ -160,7 +160,7 @@ build_with_docker() {
160160 --build-arg " TARGETOS=linux" \
161161 --build-arg " TARGETARCH=$arch " \
162162 .
163-
163+
164164 # Tag it as the main image too
165165 docker tag " $fullTag " " $image "
166166}
191191# push images, except in dry runs
192192if [ -z " ${DRY_RUN:- } " ]; then
193193 echo " Logging into GHCR ..."
194-
194+
195195 if [ " $DOCKER_BUILDX " = true ]; then
196196 # buildx with --push already pushed during build
197197 echo " Images already pushed during buildx build"
@@ -202,7 +202,7 @@ if [ -z "${DRY_RUN:-}" ]; then
202202 else
203203 echo " Skipping login (GHCR_USERNAME/GHCR_PASSWORD not provided)"
204204 fi
205-
205+
206206 echo " Pushing images ..."
207207 docker push " $image "
208208
0 commit comments