Skip to content

Commit

Permalink
Adapt dockerfiles to work in both OKD and OCP
Browse files Browse the repository at this point in the history
A decision was made to force using the same dockerfiles for containers
in both OKD and OCP. As those use two distinct buildsystems and the OKD
one doesn't handle RPMs well, we had the files separated with the OKD
one having a hack to enable repo with RPMs built by the build.

This commit attempts to unify the files in order to use just a single
one. That's done by trying to enable missing repo using sed which will
work for OKD. In order to make it run fine in OCP result of that
operation is simply ignored.

Change-Id: I49a423ffae372b7d8259faf256c68e48324a1b53
  • Loading branch information
dulek committed Aug 18, 2020
1 parent 94a5af0 commit f445cfd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
10 changes: 5 additions & 5 deletions openshift-kuryr-cni-ci-rhel8.Dockerfile
Expand Up @@ -9,13 +9,13 @@ FROM ubi8
ENV container=oci
ARG OSLO_LOCK_PATH=/var/kuryr-lock

# FIXME(dulek): For some reason the local repos are disabled by default and
# yum-config-manager is unable to enable them. Using sed for now.
RUN sed -i -e 's/enabled \?= \?0/enabled = 1/' /etc/yum.repos.d/*

COPY --from=builder /go/bin/kuryr-cni /kuryr-cni

RUN dnf install -y openshift-kuryr-cni iproute openvswitch \
# FIXME(dulek): For some reason the local repo in OKD builds is disabled,
# using sed to enable it. Ignoring fail as it won't work (nor
# it's necessary) in OCP builds.
RUN (sed -i -e 's/enabled \?= \?0/enabled = 1/' /etc/yum.repos.d/built.repo || true) \
&& dnf install -y openshift-kuryr-cni iproute openvswitch \
&& dnf clean all \
&& rm -rf /var/cache/yum

Expand Down
6 changes: 5 additions & 1 deletion openshift-kuryr-cni-rhel8.Dockerfile
Expand Up @@ -11,7 +11,11 @@ ARG OSLO_LOCK_PATH=/var/kuryr-lock

COPY --from=builder /go/bin/kuryr-cni /kuryr-cni

RUN dnf install -y openshift-kuryr-cni iproute openvswitch \
# FIXME(dulek): For some reason the local repo in OKD builds is disabled,
# using sed to enable it. Ignoring fail as it won't work (nor
# it's necessary) in OCP builds.
RUN (sed -i -e 's/enabled \?= \?0/enabled = 1/' /etc/yum.repos.d/built.repo || true) \
&& dnf install -y openshift-kuryr-cni iproute openvswitch \
&& dnf clean all \
&& rm -rf /var/cache/yum

Expand Down
10 changes: 5 additions & 5 deletions openshift-kuryr-controller-ci-rhel8.Dockerfile
Expand Up @@ -2,11 +2,11 @@ FROM ubi8

ENV container=oci

# FIXME(dulek): For some reason the local repos are disabled by default and
# yum-config-manager is unable to enable them. Using sed for now.
RUN sed -i -e 's/enabled \?= \?0/enabled = 1/' /etc/yum.repos.d/*

RUN dnf install -y openshift-kuryr-controller \
# FIXME(dulek): For some reason the local repo in OKD builds is disabled,
# using sed to enable it. Ignoring fail as it won't work (nor
# it's necessary) in OCP builds.
RUN (sed -i -e 's/enabled \?= \?0/enabled = 1/' /etc/yum.repos.d/built.repo || true) \
&& dnf install -y openshift-kuryr-controller \
&& dnf clean all \
&& rm -rf /var/cache/yum

Expand Down
6 changes: 5 additions & 1 deletion openshift-kuryr-controller-rhel8.Dockerfile
Expand Up @@ -2,7 +2,11 @@ FROM ubi8

ENV container=oci

RUN dnf install -y openshift-kuryr-controller \
# FIXME(dulek): For some reason the local repo in OKD builds is disabled,
# using sed to enable it. Ignoring fail as it won't work (nor
# it's necessary) in OCP builds.
RUN (sed -i -e 's/enabled \?= \?0/enabled = 1/' /etc/yum.repos.d/built.repo || true) \
&& dnf install -y openshift-kuryr-controller \
&& dnf clean all \
&& rm -rf /var/cache/yum

Expand Down
10 changes: 5 additions & 5 deletions tools/build-rpm-rhel8.sh
Expand Up @@ -4,11 +4,11 @@ source_path=_output/SOURCES

mkdir -p ${source_path}

# Getting version from last tag in git
version=`git describe --tags --abbrev=0`
version=${version#openshift-kuryr-} # remove prefix
release=${version#*-} # remove prefix
version=${version%-*} # remove date suffix
# Getting version from args
version=${1:-4.6.0}

# Trick to make sure we'll install this RPM later on, not the one from the repo.
release=999999999999

# NOTE(dulek): rpmbuild requires that inside the tar there will be a
# ${service}-${version} directory, hence this --transform option.
Expand Down

0 comments on commit f445cfd

Please sign in to comment.