Skip to content

Commit 3628d91

Browse files
committed
konflux: manage subscription and repository enablement
We need to enable the CRB in the builder image, but this requires managing the subscription too. The activation key and org ID are already available to us through a mount file, so we should be able to use them. Signed-off-by: Julien Ropé <[email protected]>
1 parent 50317a7 commit 3628d91

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/cloud-api-adaptor/Dockerfile.openshift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ USER root
1919
# the build process assumes go is under "/go", so let's make sure it works
2020
RUN ln -s /opt/app-root/src/go /go
2121
RUN go install github.com/mikefarah/yq/v4@$YQ_VERSION
22-
ARG ORG_ID
23-
ARG ACTIVATION_KEY
22+
2423
# This registering RHEL when building on an unsubscribed system
2524
# If you are running a UBI container on a registered and subscribed RHEL host,
2625
# the main RHEL Server repository is enabled inside the standard UBI container.
27-
# Uncomment this and provide the associated ARG variables to register.
28-
RUN if [[ -n "${ACTIVATION_KEY}" && -n "${ORG_ID}" ]]; then \
26+
RUN if command -v subscription-manager; then \
2927
REPO_ARCH=$(uname -m) && \
30-
subscription-manager register --org=${ORG_ID} --activationkey=${ACTIVATION_KEY} && \
28+
subscription-manager register --org "$(cat /activation-key/org)" --activationkey "$(cat /activation-key/activationkey)" && \
3129
subscription-manager repos --enable rhel-9-for-${REPO_ARCH}-appstream-rpms --enable codeready-builder-for-rhel-9-${REPO_ARCH}-rpms; \
30+
else \
31+
dnf -y install 'dnf-command(config-manager)' && dnf config-manager --enable crb; \
3232
fi
3333

3434
# For `dev` builds due to CGO constraints we have to emulate the target platform
@@ -79,11 +79,13 @@ RUN --mount=type=bind,target=/versions.yaml,source=cloud-api-adaptor/versions.ya
7979

8080
FROM registry.access.redhat.com/ubi9/ubi:9.5 AS base-release
8181
USER root
82-
ARG ORG_ID
83-
ARG ACTIVATION_KEY
84-
RUN REPO_ARCH=$(uname -m) && \
85-
subscription-manager register --org=${ORG_ID} --activationkey=${ACTIVATION_KEY} && \
86-
subscription-manager repos --enable rhel-9-for-${REPO_ARCH}-appstream-rpms --enable codeready-builder-for-rhel-9-${REPO_ARCH}-rpms
82+
RUN if command -v subscription-manager; then \
83+
REPO_ARCH=$(uname -m) && \
84+
subscription-manager register --org "$(cat /activation-key/org)" --activationkey "$(cat /activation-key/activationkey)" && \
85+
subscription-manager repos --enable rhel-9-for-${REPO_ARCH}-appstream-rpms --enable codeready-builder-for-rhel-9-${REPO_ARCH}-rpms; \
86+
else \
87+
dnf -y install 'dnf-command(config-manager)' && dnf config-manager --enable crb; \
88+
fi
8789

8890
RUN dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -y
8991
RUN dnf install -y iptables iptables-legacy iptables-nft nftables && dnf clean all

0 commit comments

Comments
 (0)