FROM quay.io/openshift/origin-operator-registry:4.5

ARG FULL_OPERATOR_IMAGE=quay.io/openshift-kni/performance-addon-operator:4.5-snapshot
ARG OLM_SOURCE=deploy/olm-catalog

COPY ${OLM_SOURCE} /registry/performance-addon-operator-catalog

USER root

# replaces performance-addon-operator image with the one built by openshift ci
RUN find /registry/performance-addon-operator-catalog/ -type f -exec sed -i "s|REPLACE_IMAGE|${FULL_OPERATOR_IMAGE}|g" {} \; || :

USER 1001

# Initialize the database
RUN initializer --manifests /registry/performance-addon-operator-catalog --output bundles.db

# There are multiple binaries in the origin-operator-registry
# We want the registry-server
ENTRYPOINT ["registry-server"]
CMD ["--database", "bundles.db"]
