Skip to content

Commit

Permalink
Dockerfile, Makefile: make CGO_ENABLED configurable (opendatahub-io#1382
Browse files Browse the repository at this point in the history
)

The commit
a107703 ("feat(fips): enable GO_ENABLED in build (opendatahub-io#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 <[email protected]>
(cherry picked from commit 2d94349)
  • Loading branch information
ykaliuta authored and zdtsw committed Nov 29, 2024
1 parent 8106554 commit 73fc527
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 73fc527

Please sign in to comment.