Skip to content

Commit

Permalink
[Sync]: incubation to rhoai (#1405)
Browse files Browse the repository at this point in the history
* update: owners (#1376)

Signed-off-by: Wen Zhou <[email protected]>
(cherry picked from commit 4a15a8f)
Signed-off-by: Wen Zhou <[email protected]>

* Dockerfile, Makefile: make CGO_ENABLED configurable (#1382)

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 <[email protected]>
(cherry picked from commit 2d94349)

* 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 <[email protected]>
(cherry picked from commit cea41dc)

* 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 <[email protected]> [1]

[1] #773

Signed-off-by: Yauheni Kaliuta <[email protected]>
(cherry picked from commit c1671ab)

* 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 <[email protected]>

---------

Signed-off-by: Wen Zhou <[email protected]>
Co-authored-by: Yauheni Kaliuta <[email protected]>
  • Loading branch information
zdtsw and ykaliuta authored Dec 2, 2024
1 parent 76cae1b commit bcfb033
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 30 deletions.
43 changes: 19 additions & 24 deletions Dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions OWNERS_ALIASES
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ aliases:
platform:
- adelton
- AjayJagan
- ajaypratap003
- asanzgom
- biswassri
- CFSNM
- etirelli
- grdryn
- gzaronikas
- jackdelahunt
- LaVLaS
- lburgazzoli
- lphiri
- MarianMacik
- mattmahoneyrh
- robotmaxtron
- Sara4994
- StevenTobin
- ugiordan
- VaishnaviHire
- ykaliuta
- zdtsw
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit bcfb033

Please sign in to comment.