From 44b4682a320e5e2c978c97f4b4156d67871384ea Mon Sep 17 00:00:00 2001 From: ArkaSaha30 Date: Tue, 17 Jun 2025 22:32:55 +0530 Subject: [PATCH] Use jq docker image for pause windows build This commit will use jq docker image to parse `windows-pause-image-base` manifest for windows pause build. Signed-off-by: ArkaSaha30 --- build/pause/Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build/pause/Makefile b/build/pause/Makefile index 728e6ab67ee..53fb498ab25 100644 --- a/build/pause/Makefile +++ b/build/pause/Makefile @@ -35,12 +35,14 @@ BASE.linux := scratch BASE.windows := mcr.microsoft.com/oss/kubernetes/windows-pause-image-base:v0.4.1@sha256:37cc10768383b55611d724a05eb18564cb5184c89b0c2faa7d4eff63475092df BASE := ${BASE.${OS}} +JQ_IMAGE := ghcr.io/jqlang/jq@sha256:a186dcd84a1e28bb48cdf3d7768b890d08621a87bb651fadb7db6815a6bf5ad5 + ALL_OS = linux windows ALL_ARCH.linux = amd64 arm arm64 ppc64le s390x ALL_OS_ARCH.linux = $(foreach arch, ${ALL_ARCH.linux}, linux-$(arch)) ALL_ARCH.windows = amd64 # ALL_OSVERSIONS lists all os.versions in BASE.windows. -ALL_OSVERSIONS.windows := $(shell docker manifest inspect ${BASE.windows} | jq '.manifests' | jq -c '.[]' | jq '.platform."os.version"' | tr -d '"') +ALL_OSVERSIONS.windows := $(shell docker manifest inspect ${BASE.windows} | docker run --rm -i ${JQ_IMAGE} '.manifests | .[] | .platform."os.version"' | tr -d '"') ALL_OS_ARCH.windows = $(foreach arch, $(ALL_ARCH.windows), $(foreach osversion, ${ALL_OSVERSIONS.windows}, windows-$(arch)-${osversion})) ALL_OS_ARCH = $(foreach os, $(ALL_OS), ${ALL_OS_ARCH.${os}}) @@ -130,9 +132,9 @@ container: .container-${OS}-$(ARCH) .container-windows-$(ARCH): $(foreach binary, ${BIN}, bin/${binary}-${OS}-${ARCH}) # For Windows images, each "os.version" maps to a specific image "digest" that serves as a base to build corresponding windows-pause image variant. set -x; \ - image_manifests=$$(docker manifest inspect "${BASE.windows}" | jq '.manifests'); \ + image_manifests=$$(docker manifest inspect "${BASE.windows}" | docker run --rm -i ${JQ_IMAGE} '.manifests'); \ for osversion in $(ALL_OSVERSIONS.windows); do \ - digest=$$(echo "$${image_manifests}" | jq -r '.[]|select(.platform."os.version" | contains("'$${osversion}'"))' | jq '.digest' | awk -F\" '{print $$2}'); \ + digest=$$(echo "$${image_manifests}" | docker run --rm -i ${JQ_IMAGE} '.[]|select(.platform."os.version" | contains("'$${osversion}'")) | .digest' | awk -F\" '{print $$2}'); \ base_image=$$(echo "${BASE.windows}" | awk -F: '{print $$1}')@$${digest}; \ docker buildx build --provenance=false --sbom=false --pull --output=type=${OUTPUT_TYPE} --platform ${OS}/$(ARCH) \ -t $(IMAGE):$(TAG)-${OS}-$(ARCH)-$${osversion} --build-arg BASE=$${base_image} --build-arg ARCH=$(ARCH) -f Dockerfile_windows .; \