From 0398f3b36f27b88fed239caa844a69517f0ed854 Mon Sep 17 00:00:00 2001 From: Olivier Cazade Date: Mon, 14 Oct 2024 13:41:10 +0000 Subject: [PATCH] Fix multiarch build with new buildah version (#100) --- ...ervability-cli-container-pull-request.yaml | 24 +------------------ ...work-observability-cli-container-push.yaml | 24 +------------------ Dockerfile | 6 ++--- Makefile | 6 ++--- 4 files changed, 7 insertions(+), 53 deletions(-) diff --git a/.tekton/network-observability-cli-container-pull-request.yaml b/.tekton/network-observability-cli-container-pull-request.yaml index fb97926e..91833e7e 100644 --- a/.tekton/network-observability-cli-container-pull-request.yaml +++ b/.tekton/network-observability-cli-container-pull-request.yaml @@ -94,7 +94,7 @@ spec: description: Skip checks against built image name: skip-checks type: string - - default: "false" + - default: "true" description: Execute the build with network isolation name: hermetic type: string @@ -405,28 +405,6 @@ spec: operator: in values: - "false" - - name: sbom-json-check - params: - - name: IMAGE_URL - value: $(tasks.build-container.results.IMAGE_URL) - - name: IMAGE_DIGEST - value: $(tasks.build-container.results.IMAGE_DIGEST) - runAfter: - - build-container - taskRef: - params: - - name: name - value: sbom-json-check - - name: bundle - value: quay.io/konflux-ci/tekton-catalog/task-sbom-json-check:0.1@sha256:acc9cb8a714f33c0e48d6ca219b6bd0191f09cdd767af4ef3a35d0a5cac53b5d - - name: kind - value: task - resolver: bundles - when: - - input: $(params.skip-checks) - operator: in - values: - - "false" - name: apply-tags params: - name: IMAGE diff --git a/.tekton/network-observability-cli-container-push.yaml b/.tekton/network-observability-cli-container-push.yaml index b1ac9a48..d1f06207 100644 --- a/.tekton/network-observability-cli-container-push.yaml +++ b/.tekton/network-observability-cli-container-push.yaml @@ -91,7 +91,7 @@ spec: description: Skip checks against built image name: skip-checks type: string - - default: "false" + - default: "true" description: Execute the build with network isolation name: hermetic type: string @@ -402,28 +402,6 @@ spec: operator: in values: - "false" - - name: sbom-json-check - params: - - name: IMAGE_URL - value: $(tasks.build-container.results.IMAGE_URL) - - name: IMAGE_DIGEST - value: $(tasks.build-container.results.IMAGE_DIGEST) - runAfter: - - build-container - taskRef: - params: - - name: name - value: sbom-json-check - - name: bundle - value: quay.io/konflux-ci/tekton-catalog/task-sbom-json-check:0.1@sha256:acc9cb8a714f33c0e48d6ca219b6bd0191f09cdd767af4ef3a35d0a5cac53b5d - - name: kind - value: task - resolver: bundles - when: - - input: $(params.skip-checks) - operator: in - values: - - "false" - name: apply-tags params: - name: IMAGE diff --git a/Dockerfile b/Dockerfile index bd5dc97d..da800360 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,8 @@ # We do not use --platform feature to auto fill this ARG because of incompatibility between podman and docker -ARG TARGETPLATFORM=linux/amd64 -ARG BUILDPLATFORM=linux/amd64 ARG TARGETARCH=amd64 # Build the manager binary -FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.22 as builder +FROM docker.io/library/golang:1.22 as builder ARG TARGETARCH ARG TARGETPLATFORM @@ -33,7 +31,7 @@ RUN USER=netobserv VERSION=main make oc-commands RUN mkdir -p output # Create final image from ubi + built binary and command -FROM --platform=$TARGETPLATFORM registry.access.redhat.com/ubi9/ubi:9.4 +FROM --platform=linux/$TARGETARCH registry.access.redhat.com/ubi9/ubi:9.4 WORKDIR / COPY --from=builder /opt/app-root/build . COPY --from=builder --chown=65532:65532 /opt/app-root/output /output diff --git a/Makefile b/Makefile index 323bef61..df93656d 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ MULTIARCH_TARGETS ?= amd64 # In CI, to be replaced by `netobserv` IMAGE_ORG ?= $(USER) -# Build output +# Build output NAME := network-observability-cli DIST_DIR ?= build FILES_OUTPUT_DIR ?= output @@ -31,7 +31,7 @@ OUTPUT := $(DIST_DIR)/$(NAME) # Available commands for development with args COMMANDS = flows packets cleanup -COMMAND_ARGS ?= +COMMAND_ARGS ?= # Get either oc (favorite) or kubectl paths K8S_CLI_BIN_PATH = $(shell which oc 2>/dev/null || which kubectl) @@ -58,7 +58,7 @@ YQ_VERSION = v4.43.1 # build a single arch target provided as argument define build_target echo 'building image for arch $(1)'; \ - DOCKER_BUILDKIT=1 $(OCI_BIN) buildx build --load --build-arg TARGETPLATFORM=linux/$(1) --build-arg TARGETARCH=$(1) --build-arg BUILDPLATFORM=linux/amd64 ${OCI_BUILD_OPTS} -t ${IMAGE}-$(1) -f Dockerfile .; + DOCKER_BUILDKIT=1 $(OCI_BIN) buildx build --load --build-arg TARGETARCH=$(1) ${OCI_BUILD_OPTS} -t ${IMAGE}-$(1) -f Dockerfile .; endef # push a single arch target image