Skip to content

Commit d0ca313

Browse files
authored
fix: make images install-all works on macos (#3797)
Signed-off-by: Calum Murray <cmurray@redhat.com>
1 parent 14175bc commit d0ca313

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
# Target architecture and OS for image builds
2+
# Defaults to amd64/linux for OpenShift clusters, but can be overridden for local development
3+
TARGET_ARCH ?= amd64
4+
TARGET_OS ?= linux
5+
16
# Useful for local development
27
dev:
38
./hack/dev.sh
49

510
# General purpose targets
611
images:
7-
./hack/images.sh $(DOCKER_REPO_OVERRIDE)
12+
TARGET_ARCH=$(TARGET_ARCH) TARGET_OS=$(TARGET_OS) ./hack/images.sh $(DOCKER_REPO_OVERRIDE)
813

914
install: install-tools
1015
./hack/install.sh
@@ -18,7 +23,7 @@ install-all: install-tools
1823
SCALE_UP=4 INSTALL_KAFKA="true" ENABLE_TRACING=true ./hack/install.sh
1924

2025
install-release-next: install-tools generated-files-release-next
21-
ON_CLUSTER_BUILDS=true ./hack/images.sh image-registry.openshift-image-registry.svc:5000/openshift-marketplace
26+
ON_CLUSTER_BUILDS=true TARGET_ARCH=$(TARGET_ARCH) TARGET_OS=$(TARGET_OS) ./hack/images.sh image-registry.openshift-image-registry.svc:5000/openshift-marketplace
2227
USE_RELEASE_NEXT=true DOCKER_REPO_OVERRIDE=image-registry.openshift-image-registry.svc:5000/openshift-marketplace ./hack/install.sh
2328

2429
install-tracing:

hack/images.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ fi
1717

1818
repo=$1
1919

20+
# Set default target architecture and OS if not provided
21+
TARGET_ARCH=${TARGET_ARCH:-amd64}
22+
TARGET_OS=${TARGET_OS:-linux}
23+
2024
on_cluster_builds=${ON_CLUSTER_BUILDS:-false}
2125
echo "On cluster builds: ${on_cluster_builds}"
26+
echo "Target platform: ${TARGET_OS}/${TARGET_ARCH}"
2227

2328
if [[ $on_cluster_builds = true ]]; then
2429
# image-registry.openshift-image-registry.svc:5000/openshift-marketplace/openshift-knative-operator:latest
@@ -32,14 +37,14 @@ if [[ $on_cluster_builds = true ]]; then
3237

3338
else
3439
tmp_dockerfile=$(replace_images openshift-knative-operator/Dockerfile)
35-
podman build -t "$repo/serverless-openshift-knative-operator" -f "${tmp_dockerfile}" .
40+
podman build --platform="${TARGET_OS}/${TARGET_ARCH}" -t "$repo/serverless-openshift-knative-operator" -f "${tmp_dockerfile}" .
3641
podman push "$repo/serverless-openshift-knative-operator"
3742

3843
tmp_dockerfile=$(replace_images knative-operator/Dockerfile)
39-
podman build -t "$repo/serverless-knative-operator" -f "${tmp_dockerfile}" .
44+
podman build --platform="${TARGET_OS}/${TARGET_ARCH}" -t "$repo/serverless-knative-operator" -f "${tmp_dockerfile}" .
4045
podman push "$repo/serverless-knative-operator"
4146

4247
tmp_dockerfile=$(replace_images serving/ingress/Dockerfile)
43-
podman build -t "$repo/serverless-ingress" -f "${tmp_dockerfile}" .
48+
podman build --platform="${TARGET_OS}/${TARGET_ARCH}" -t "$repo/serverless-ingress" -f "${tmp_dockerfile}" .
4449
podman push "$repo/serverless-ingress"
4550
fi

hack/lib/images.bash

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,12 @@ function image_with_sha {
407407
image=${1:?"Provide image"}
408408
return_input_on_empty=${2:-"false"}
409409

410+
# Use TARGET_OS and TARGET_ARCH if set, otherwise default to linux/amd64
411+
target_os=${TARGET_OS:-linux}
412+
target_arch=${TARGET_ARCH:-amd64}
413+
410414
# shellcheck disable=SC2086
411-
digest=$(skopeo inspect --retry-times=10 --no-tags=true ${SKOPEO_EXTRA_FLAGS} "docker://${image}" | jq -r '.Digest' || echo "")
415+
digest=$(skopeo inspect --retry-times=10 --override-os "${target_os}" --override-arch "${target_arch}" --no-tags=true ${SKOPEO_EXTRA_FLAGS} "docker://${image}" | jq -r '.Digest' || echo "")
412416
if [ "${digest}" = "" ]; then
413417
if [ "${return_input_on_empty}" = "true" ]; then
414418
echo "${image}"
@@ -425,7 +429,12 @@ function image_with_sha {
425429

426430
function bundle_image_version {
427431
image=${1:?"Provide image"}
428-
version=$(skopeo inspect --no-tags=true "docker://${image}" | jq -r '.Labels.version')
432+
433+
# Use TARGET_OS and TARGET_ARCH if set, otherwise default to linux/amd64
434+
target_os=${TARGET_OS:-linux}
435+
target_arch=${TARGET_ARCH:-amd64}
436+
437+
version=$(skopeo inspect --no-tags=true --override-os "${target_os}" --override-arch "${target_arch}" "docker://${image}" | jq -r '.Labels.version')
429438
echo "${version}"
430439
}
431440

0 commit comments

Comments
 (0)