Skip to content

Commit

Permalink
Dockerfile, Makefile: make CGO_ENABLED configurable (#1382)
Browse files Browse the repository at this point in the history
The commit
a107703 ("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 <ykaliuta@redhat.com>
  • Loading branch information
ykaliuta authored Nov 19, 2024
1 parent 77b6db8 commit 2d94349
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 @@ -39,7 +40,7 @@ COPY main.go main.go
COPY pkg/ pkg/

# 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 ?= opendatahub-operator-system
DEFAULT_MANIFESTS_PATH ?= opt/manifests

CGO_ENABLED ?= 1

CHANNELS="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)

# Read any custom variables overrides from a local.mk file. This will only be read if it exists in the
# same directory as this Makefile. Variables can be specified in the standard format supported by
Expand Down

0 comments on commit 2d94349

Please sign in to comment.