Skip to content
Merged
39 changes: 38 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ ENVTEST_K8S_VERSION = 1.32 #refers to the version of kubebuilder assets to be do
GOLANGCI_LINT_VERSION ?= v2.9.0
KUSTOMIZE_VERSION ?= v5.2.1
CONTROLLER_TOOLS_VERSION ?= v0.16.5
OPM_VERSION ?= v1.23.0
# Also defined in build/Dockerfile.catalog — keep in sync
OPM_VERSION ?= v1.68.0
BRANCH_VERSION = oadp-dev
PREVIOUS_CHANNEL ?= oadp-1.5
PREVIOUS_CHANNEL_GO_VERSION ?= 1.23
Expand Down Expand Up @@ -417,6 +418,42 @@ catalog-build: opm ## Build a catalog image.
$(CONTAINER_TOOL) build --load $(DOCKER_BUILD_ARGS) -f catalog.Dockerfile -t $(CATALOG_IMG) .
rm -rf catalog.Dockerfile catalog/

# Build a catalog image using build/Dockerfile.catalog (self-contained, used by CI).
# Passes OPM_VERSION from this Makefile to keep the two in sync.
#
# Use case: test the same Dockerfile that CI uses, locally.
# make catalog-fbc-build BUNDLE_IMG=quay.io/konveyor/oadp-operator-bundle:latest
# make catalog-push
#
# Then install on-cluster:
# OLMv0 (CatalogSource + Subscription):
# make deploy-olm CATALOG_IMG=$(CATALOG_IMG)
Comment on lines +428 to +430
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use the variable that deploy-olm actually reads.

deploy-olm ignores CATALOG_IMG; the target-specific variable is THIS_CATALOG_IMAGE, so this example won't install the tag the reader just built. Please update this snippet, and the matching example in build/Dockerfile.catalog, to use the right variable.

Suggested doc fix
 # Then install on-cluster:
 #   OLMv0 (CatalogSource + Subscription):
-#     make deploy-olm CATALOG_IMG=$(CATALOG_IMG)
+#     make deploy-olm THIS_CATALOG_IMAGE=$(CATALOG_IMG)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Then install on-cluster:
# OLMv0 (CatalogSource + Subscription):
# make deploy-olm CATALOG_IMG=$(CATALOG_IMG)
# Then install on-cluster:
# OLMv0 (CatalogSource + Subscription):
# make deploy-olm THIS_CATALOG_IMAGE=$(CATALOG_IMG)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` around lines 427 - 429, The Makefile comment/example references
CATALOG_IMG but the deploy-olm target actually reads THIS_CATALOG_IMAGE; update
the example invocation (and the matching example in build/Dockerfile.catalog) to
use THIS_CATALOG_IMAGE instead of CATALOG_IMG so the built tag is passed into
the deploy-olm target; search for the deploy-olm target and any example usages
in build/Dockerfile.catalog and replace the variable name accordingly.

# OLMv1 (ClusterExtension):
# kubectl apply -f - <<EOF
# apiVersion: olm.operatorframework.io/v1
# kind: ClusterExtension
# metadata:
# name: oadp-operator
# spec:
# source:
# sourceType: Catalog
# catalog:
# packageName: oadp-operator
# install:
# namespace: openshift-adp
# serviceAccount:
# name: oadp-operator-controller-manager
# EOF
.PHONY: catalog-fbc-build
catalog-fbc-build: ## Build a catalog image from build/Dockerfile.catalog.
$(CONTAINER_TOOL) build --load $(DOCKER_BUILD_ARGS) \
-f build/Dockerfile.catalog \
--build-arg BUNDLE_IMG=$(BUNDLE_IMG) \
--build-arg OPM_VERSION=$(OPM_VERSION) \
--build-arg VERSION=$(VERSION) \
--build-arg DEFAULT_CHANNEL=$(DEFAULT_CHANNEL) \
-t $(CATALOG_IMG) .

# Push the catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
Expand Down
71 changes: 71 additions & 0 deletions build/Dockerfile.catalog
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# FBC (File-Based Catalog) image for OLM operator installation.
# Renders a bundle image into an FBC catalog with gRPC serving for OLMv0.
# OLMv1 only needs the /configs content (no serving required).
#
# Usage:
# make catalog-fbc-build BUNDLE_IMG=<bundle-image-ref>
#
# Or directly:
# podman build -f build/Dockerfile.catalog \
# --build-arg BUNDLE_IMG=<bundle-image-ref> \
# -t <catalog-image-tag> .
#
# After building, push and install on-cluster:
# make catalog-push
# OLMv0: make deploy-olm CATALOG_IMG=<catalog-image-tag>
# OLMv1: create a ClusterExtension referencing the oadp-operator package
# (see Makefile catalog-fbc-build comments for full example)
#
# ci-operator: set BUNDLE_IMG via build_args in the ci-operator config.
# The bundle image must be pushed to a registry accessible during the build.
#
# Reference: networking-incubator/coraza-kubernetes-operator catalog/Dockerfile

# Keep OPM_VERSION in sync with Makefile. Override via --build-arg or `make catalog-fbc-build`.
ARG OPM_VERSION=v1.68.0

FROM quay.io/operator-framework/opm:${OPM_VERSION} AS opm

FROM registry.access.redhat.com/ubi9/ubi-minimal AS builder

COPY --from=opm /bin/opm /bin/opm

# Allow opm to pull bundle images from CI registries without signature verification
RUN mkdir -p /etc/containers && \
echo '{"default":[{"type":"insecureAcceptAnything"}]}' > /etc/containers/policy.json

ARG BUNDLE_IMG
ARG VERSION=99.0.0
ARG DEFAULT_CHANNEL=dev

RUN test -n "${BUNDLE_IMG}" || (echo "BUNDLE_IMG build-arg is required" >&2; exit 1) && \
mkdir -p /configs/oadp-operator && \
/bin/opm render "${BUNDLE_IMG}" -o yaml > /configs/oadp-operator/index.yaml && \
cat >> /configs/oadp-operator/index.yaml <<EOF
---
schema: olm.package
name: oadp-operator
defaultChannel: ${DEFAULT_CHANNEL}
---
schema: olm.channel
name: ${DEFAULT_CHANNEL}
package: oadp-operator
entries:
- name: oadp-operator.v${VERSION}
EOF

RUN /bin/opm validate /configs/

FROM opm

COPY --from=builder /configs /configs

# OLMv0: pre-warm the serve cache and configure gRPC serving.
# OLMv1 reads /configs directly from the image and does not use the serve entrypoint.
RUN ["/bin/opm", "serve", "/configs", "--cache-dir=/tmp/cache", "--cache-only"]

LABEL operators.operatorframework.io.index.configs.v1=/configs

EXPOSE 50051
ENTRYPOINT ["/bin/opm"]
CMD ["serve", "/configs", "--cache-dir=/tmp/cache"]
Comment thread
coderabbitai[bot] marked this conversation as resolved.