Skip to content

Commit 81bcf73

Browse files
authored
Merge pull request #3024 from robnester-rh/EC-1520
optimize build and cross-compiling.
2 parents f183be1 + 53a768d commit 81bcf73

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

build.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ BUILDS="${1}"
2424
# Generally blank, but will be set to "redhat" for Konflux builds
2525
BUILD_SUFFIX="${2:-""}"
2626

27+
# When building multi-arch images, only the linux/amd64 build needs to cross-compile all platform/arch combinations for download.
28+
# The other platforms only need their native binary. This reduces builds from 28 (7 binaries × 4 platforms) to 10 (7 + 1 + 1 + 1).
29+
30+
# Check if TARGETOS and TARGETARCH are set (Dockerfile sets these via buildah --platform)
31+
if [[ -n "${TARGETOS:-}" && -n "${TARGETARCH:-}" ]]; then
32+
# We're in a Dockerfile build with TARGETOS/TARGETARCH set
33+
if [[ "${TARGETOS}" == "linux" && "${TARGETARCH}" == "amd64" ]]; then
34+
# amd64 builds ALL binaries for download availability
35+
echo "Platform linux/amd64: Building all cross-compiled binaries for download"
36+
else
37+
# Other platforms only build their native binary
38+
echo "Platform ${TARGETOS}/${TARGETARCH}: Building only native binary"
39+
BUILDS="${TARGETOS}_${TARGETARCH}"
40+
fi
41+
fi
42+
2743
EC_FULL_VERSION=$(hack/derive-version.sh "${BUILD_SUFFIX}")
2844

2945
echo "EC_FULL_VERSION=$EC_FULL_VERSION"

0 commit comments

Comments
 (0)