From 60291d057f38ee0101d71fbfd973c725a722f2f2 Mon Sep 17 00:00:00 2001 From: Yauheni Kaliuta Date: Tue, 19 Nov 2024 16:24:33 +0200 Subject: [PATCH] Dockerfile, Makefile: make CGO_ENABLED configurable (#1382) The commit a107703442c6 ("feat(fips): enable GO_ENABLED in build (#1001)") enabled CGO which makes problems for builders on non-x86 platforms. Make it as an in the Dockerfile keeping default the same (enabled), but make it possible to override with either environment (`export CGO_ENABLED=0`) or make (`make CGO_ENABLED=0 image-build`) Signed-off-by: Yauheni Kaliuta (cherry picked from commit 2d943491e963df8b6c54d26cdc111091a8040253) --- Dockerfiles/Dockerfile | 3 ++- Makefile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfiles/Dockerfile b/Dockerfiles/Dockerfile index 0958dcfa042..5de4803a321 100644 --- a/Dockerfiles/Dockerfile +++ b/Dockerfiles/Dockerfile @@ -22,6 +22,7 @@ COPY opt/manifests/ /opt/manifests/ ################################################################################ FROM builder_local_${USE_LOCAL} as builder +ARG CGO_ENABLED=1 USER root WORKDIR /workspace # Copy the Go Modules manifests @@ -46,7 +47,7 @@ COPY config/partners/ /opt/manifests/partners/ COPY config/osd-configs/ /opt/manifests/osd-configs/ # Build -RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -o manager main.go +RUN CGO_ENABLED=${CGO_ENABLED} GOOS=linux GOARCH=amd64 go build -a -o manager main.go ################################################################################ FROM registry.access.redhat.com/ubi8/ubi-minimal:latest diff --git a/Makefile b/Makefile index 7c841242998..82c73f4c990 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION) IMAGE_BUILDER ?= podman OPERATOR_NAMESPACE ?= redhat-ods-operator DEFAULT_MANIFESTS_PATH ?= opt/manifests - +CGO_ENABLED ?= 1 CHANNELS="alpha,stable,fast" # CHANNELS define the bundle channels used in the bundle. @@ -94,6 +94,7 @@ E2E_TEST_FLAGS = "--skip-deletion=false" -timeout 25m # See README.md, default g # set to "true" to use local instead # see target "image-build" IMAGE_BUILD_FLAGS ?= --build-arg USE_LOCAL=false +IMAGE_BUILD_FLAGS += --build-arg CGO_ENABLED=$(CGO_ENABLED) # Prometheus-Unit Tests Parameters PROMETHEUS_CONFIG_YAML = ./config/monitoring/prometheus/apps/prometheus-configs.yaml