From bcfb033af22bd2f9430e8e94afeae69cb14be961 Mon Sep 17 00:00:00 2001 From: Wen Zhou Date: Mon, 2 Dec 2024 17:51:52 +0100 Subject: [PATCH] [Sync]: incubation to rhoai (#1405) * update: owners (#1376) Signed-off-by: Wen Zhou (cherry picked from commit 4a15a8fd21f87213d65fe1786827945afa8d410d) Signed-off-by: Wen Zhou * 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) * Makefile: make USE_LOCAL overridable (#1384) Get USE_LOCAL image build flag from makefile variable to make it overridable with `make USE_LOCAL=true image` Do not allow to get its value for environment be default due to pretty generic name. This is shorter than the old recommendation of overriding IMAGE_BUILD_FLAGS. And since now CGO_ENABLED is also a flag, does not mess up with it. * USE_LOCAL=true uses existing manifests from opt/manifests for the produced image without downloading them with get_all_manifests.sh making it possible to both save time and make local amendments. Signed-off-by: Yauheni Kaliuta (cherry picked from commit cea41dc8c32c6cd61495c19002e9b61345654139) * Dockerfile: merges manifests builder stages to one (#1381) We can combine two build stages into one, as there is no need to always build both images (not done by podman) to only then decide from which one we want to copy manifests to the target image. Instead manifests stage will either copy local manifests or fetches using the script based on USE_LOCAL argument. Move USE_LOCAL and OVERWIRTE_MANIFESTS args under FROM since args have scope of the FROM they are declared in. It requires opt/manifests directory to exist, but since it's a part of git repo, it's fine. Original patch from: Bartosz Majsak [1] [1] https://github.com/opendatahub-io/opendatahub-operator/pull/773 Signed-off-by: Yauheni Kaliuta (cherry picked from commit c1671ab5fd11baea814f8acdee1bc448d502fb1c) * fix: rhoai build has extra manifests than odh's - changes made in odh, missing manifests for rhoai since it is only using builder for main and others from manifests stage Signed-off-by: Wen Zhou --------- Signed-off-by: Wen Zhou Co-authored-by: Yauheni Kaliuta --- Dockerfiles/Dockerfile | 43 +++++++++++++++++++----------------------- Makefile | 6 ++++-- OWNERS_ALIASES | 4 ++-- README.md | 4 ++-- 4 files changed, 27 insertions(+), 30 deletions(-) diff --git a/Dockerfiles/Dockerfile b/Dockerfiles/Dockerfile index 0958dcfa042..53fc7f27ca0 100644 --- a/Dockerfiles/Dockerfile +++ b/Dockerfiles/Dockerfile @@ -1,27 +1,29 @@ # Build the manager binary ARG GOLANG_VERSION=1.21 -ARG USE_LOCAL=false -ARG OVERWRITE_MANIFESTS="" ################################################################################ -FROM registry.access.redhat.com/ubi8/go-toolset:$GOLANG_VERSION as builder_local_false -ARG OVERWRITE_MANIFESTS -# Get all manifests from remote git repo to builder_local_false by script +FROM registry.access.redhat.com/ubi8/toolbox as manifests +ARG USE_LOCAL=false +ARG OVERWRITE_MANIFESTS="" USER root WORKDIR / -COPY get_all_manifests.sh get_all_manifests.sh -RUN ./get_all_manifests.sh ${OVERWRITE_MANIFESTS} - -################################################################################ -FROM registry.access.redhat.com/ubi8/go-toolset:$GOLANG_VERSION as builder_local_true -# Get all manifests from local to builder_local_true -USER root -WORKDIR /opt -# copy local manifests to build COPY opt/manifests/ /opt/manifests/ +COPY get_all_manifests.sh get_all_manifests.sh +RUN if [ "${USE_LOCAL}" != "true" ]; then \ + rm -rf /opt/manifests/*; \ + ./get_all_manifests.sh ${OVERWRITE_MANIFESTS}; \ + fi + +# Copy monitoring config +COPY config/monitoring/ /opt/manifests/monitoring +# Copy partners config +COPY config/partners/ /opt/manifests/partners +# Copy ods-configs +COPY config/osd-configs/ /opt/manifests/osd-configs ################################################################################ -FROM builder_local_${USE_LOCAL} as builder +FROM registry.access.redhat.com/ubi8/go-toolset:$GOLANG_VERSION as builder +ARG CGO_ENABLED=1 USER root WORKDIR /workspace # Copy the Go Modules manifests @@ -38,21 +40,14 @@ COPY controllers/ controllers/ COPY main.go main.go COPY pkg/ pkg/ -# Copy monitoring config -COPY config/monitoring/ /opt/manifests/monitoring/ -# Copy partners config -COPY config/partners/ /opt/manifests/partners/ -# Copy ods-configs -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 WORKDIR / COPY --from=builder /workspace/manager . -COPY --chown=1001:0 --from=builder /opt/manifests /opt/manifests +COPY --chown=1001:0 --from=manifests /opt/manifests /opt/manifests # Recursive change all files RUN chown -R 1001:0 /opt/manifests &&\ chmod -R g=u /opt/manifests diff --git a/Makefile b/Makefile index 7c841242998..16220b86c34 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,9 @@ 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" +USE_LOCAL = false # CHANNELS define the bundle channels used in the bundle. # Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable") @@ -93,7 +94,8 @@ E2E_TEST_FLAGS = "--skip-deletion=false" -timeout 25m # See README.md, default g # Default image-build is to not use local odh-manifests folder # set to "true" to use local instead # see target "image-build" -IMAGE_BUILD_FLAGS ?= --build-arg USE_LOCAL=false +IMAGE_BUILD_FLAGS ?= --build-arg USE_LOCAL=$(USE_LOCAL) +IMAGE_BUILD_FLAGS += --build-arg CGO_ENABLED=$(CGO_ENABLED) # Prometheus-Unit Tests Parameters PROMETHEUS_CONFIG_YAML = ./config/monitoring/prometheus/apps/prometheus-configs.yaml diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES index f7f3153ed45..21eccbed454 100644 --- a/OWNERS_ALIASES +++ b/OWNERS_ALIASES @@ -2,7 +2,6 @@ aliases: platform: - adelton - AjayJagan - - ajaypratap003 - asanzgom - biswassri - CFSNM @@ -10,13 +9,14 @@ aliases: - grdryn - gzaronikas - jackdelahunt - - LaVLaS - lburgazzoli - lphiri - MarianMacik - mattmahoneyrh + - robotmaxtron - Sara4994 - StevenTobin + - ugiordan - VaishnaviHire - ykaliuta - zdtsw \ No newline at end of file diff --git a/README.md b/README.md index 1de5dba1e90..87e76eb9aed 100644 --- a/README.md +++ b/README.md @@ -133,8 +133,8 @@ make image-build By default, building an image without any local changes(as a clean build) This is what the production build system is doing. -In order to build an image with local `opt/manifests` folder, to set `IMAGE_BUILD_FLAGS ="--build-arg USE_LOCAL=true"` in make. -e.g `make image-build -e IMAGE_BUILD_FLAGS="--build-arg USE_LOCAL=true"` +In order to build an image with local `opt/manifests` folder set `USE_LOCAL` make variable to `true` +e.g `make image-build USE_LOCAL=true"` #### Build Image