Skip to content

Commit f7fcf8c

Browse files
Unify OKD and OCP Dockerfiles (#1058)
Co-authored-by: Prashanth684 <[email protected]>
1 parent c3239c6 commit f7fcf8c

File tree

3 files changed

+68
-42
lines changed

3 files changed

+68
-42
lines changed

Dockerfile

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,24 @@ COPY . .
44
RUN make update-tuned-submodule
55
RUN make build
66

7-
FROM quay.io/centos/centos:stream9 as tuned
8-
WORKDIR /root
9-
COPY assets /root/assets
10-
RUN INSTALL_PKGS=" \
11-
gcc git rpm-build make desktop-file-utils patch dnf-plugins-core \
12-
" && \
13-
dnf install --setopt=tsflags=nodocs -y $INSTALL_PKGS && \
14-
cd assets/tuned/tuned && \
15-
LC_COLLATE=C cat ../patches/*.diff | patch -Np1 && \
16-
dnf build-dep tuned.spec -y && \
17-
make rpm PYTHON=/usr/bin/python3 && \
18-
rm -rf /root/rpmbuild/RPMS/noarch/{tuned-gtk*,tuned-utils*,tuned-profiles-compat*}
19-
207
FROM quay.io/centos/centos:stream9
218
COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/cluster-node-tuning-operator /usr/bin/
229
COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/performance-profile-creator /usr/bin/
2310
COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/gather-sysinfo /usr/bin/
11+
12+
ENV ASSETS_DIR=/root/assets
13+
COPY assets $ASSETS_DIR
14+
15+
COPY hack/dockerfile_install_support.sh /tmp
16+
RUN /bin/bash /tmp/dockerfile_install_support.sh
17+
2418
COPY manifests/*.yaml manifests/image-references /manifests/
2519
ENV APP_ROOT=/var/lib/ocp-tuned
2620
ENV PATH=${APP_ROOT}/bin:${PATH}
2721
ENV HOME=${APP_ROOT}
2822
ENV SYSTEMD_IGNORE_CHROOT=1
2923
WORKDIR ${APP_ROOT}
30-
COPY --from=tuned /root/assets/bin /usr/local/bin
31-
COPY --from=tuned /root/rpmbuild/RPMS/noarch /root/rpms
32-
RUN INSTALL_PKGS=" \
33-
nmap-ncat procps-ng pciutils \
34-
" && \
35-
mkdir -p /etc/grub.d/ /boot /var/lib/ocp-tuned && \
36-
dnf install --setopt=tsflags=nodocs -y $INSTALL_PKGS && \
37-
rpm -V $INSTALL_PKGS && \
38-
dnf --setopt=tsflags=nodocs -y install /root/rpms/*.rpm && \
39-
rm -rf /etc/tuned/recommend.d && \
40-
echo auto > /etc/tuned/profile_mode && \
41-
sed -Ei 's|^#?\s*enable_unix_socket\s*=.*$|enable_unix_socket = 1|;s|^#?\s*rollback\s*=.*$|rollback = not_on_exit|;s|^#?\s*profile_dirs\s*=.*$|profile_dirs = /var/lib/ocp-tuned/profiles,/usr/lib/tuned|' \
42-
/etc/tuned/tuned-main.conf && \
43-
touch /etc/sysctl.conf && \
44-
dnf clean all && \
24+
RUN dnf clean all && \
4525
rm -rf /var/cache/yum ~/patches /root/rpms && \
4626
useradd -r -u 499 cluster-node-tuning-operator
4727
ENTRYPOINT ["/usr/bin/cluster-node-tuning-operator"]

Dockerfile.rhel9

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,21 @@ FROM registry.ci.openshift.org/ocp/4.16:base-rhel9
77
COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/cluster-node-tuning-operator /usr/bin/
88
COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/performance-profile-creator /usr/bin/
99
COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/gather-sysinfo /usr/bin/
10+
11+
ENV ASSETS_DIR=/root/assets
12+
COPY assets $ASSETS_DIR
13+
14+
COPY hack/dockerfile_install_support.sh /tmp
15+
RUN /bin/bash /tmp/dockerfile_install_support.sh
16+
1017
COPY manifests/*.yaml manifests/image-references /manifests/
1118
ENV APP_ROOT=/var/lib/ocp-tuned
1219
ENV PATH=${APP_ROOT}/bin:${PATH}
1320
ENV HOME=${APP_ROOT}
1421
ENV SYSTEMD_IGNORE_CHROOT=1
1522
WORKDIR ${APP_ROOT}
16-
COPY assets/bin /usr/local/bin
17-
RUN INSTALL_PKGS=" \
18-
tuned tuned-profiles-atomic tuned-profiles-cpu-partitioning tuned-profiles-mssql tuned-profiles-nfv tuned-profiles-nfv-guest \
19-
tuned-profiles-nfv-host tuned-profiles-openshift tuned-profiles-oracle tuned-profiles-postgresql tuned-profiles-realtime \
20-
tuned-profiles-sap tuned-profiles-sap-hana tuned-profiles-spectrumscale \
21-
nmap-ncat procps-ng pciutils" && \
22-
mkdir -p /etc/grub.d/ /boot /var/lib/ocp-tuned && \
23-
dnf install --setopt=tsflags=nodocs -y $INSTALL_PKGS && \
24-
rm -rf /etc/tuned/recommend.d && \
25-
echo auto > /etc/tuned/profile_mode && \
26-
sed -Ei 's|^#?\s*enable_unix_socket\s*=.*$|enable_unix_socket = 1|;s|^#?\s*rollback\s*=.*$|rollback = not_on_exit|;s|^#?\s*profile_dirs\s*=.*$|profile_dirs = /var/lib/ocp-tuned/profiles,/usr/lib/tuned|' \
27-
/etc/tuned/tuned-main.conf && \
28-
touch /etc/sysctl.conf && \
29-
dnf clean all && \
23+
24+
RUN dnf clean all && \
3025
rm -rf /var/cache/yum ~/patches /root/rpms && \
3126
useradd -r -u 499 cluster-node-tuning-operator
3227
ENTRYPOINT ["/usr/bin/cluster-node-tuning-operator"]

hack/dockerfile_install_support.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
set -o xtrace
5+
6+
source /etc/os-release
7+
if [[ "${ID}" == "centos" ]]; then
8+
9+
# CentOS OKD build
10+
BUILD_INSTALL_PKGS="gcc git rpm-build make desktop-file-utils patch dnf-plugins-core"
11+
dnf install --setopt=tsflags=nodocs -y ${BUILD_INSTALL_PKGS}
12+
cd /root/assets/tuned/tuned
13+
LC_COLLATE=C cat ../patches/*.diff | patch -Np1
14+
dnf build-dep tuned.spec -y
15+
make rpm PYTHON=/usr/bin/python3
16+
rm -rf /root/rpmbuild/RPMS/noarch/{tuned-gtk*,tuned-utils*,tuned-profiles-compat*};
17+
dnf --setopt=protected_packages= history -y undo 0 # Remove builddep
18+
19+
INSTALL_PKGS="nmap-ncat procps-ng pciutils"
20+
cp -r /root/assets/bin /usr/local/bin
21+
cp -r /root/rpmbuild/RPMS/noarch /root/rpms
22+
mkdir -p /etc/grub.d/ /boot /var/lib/ocp-tuned
23+
dnf install --setopt=tsflags=nodocs -y ${INSTALL_PKGS}
24+
rpm -V ${INSTALL_PKGS}
25+
dnf --setopt=tsflags=nodocs -y install /root/rpms/*.rpm
26+
rm -rf /etc/tuned/recommend.d
27+
echo auto > /etc/tuned/profile_mode
28+
sed -Ei 's|^#?\s*enable_unix_socket\s*=.*$|enable_unix_socket = 1|;s|^#?\s*rollback\s*=.*$|rollback = not_on_exit|;s|^#?\s*profile_dirs\s*=.*$|profile_dirs = /var/lib/ocp-tuned/profiles,/usr/lib/tuned|' /etc/tuned/tuned-main.conf;
29+
30+
# Clean up build tools to remove image footprint
31+
dnf remove --setopt=protected_packages= -y ${BUILD_INSTALL_PKGS}
32+
dnf autoremove -y
33+
34+
else
35+
36+
# RHEL OCP build
37+
INSTALL_PKGS=" \
38+
tuned tuned-profiles-atomic tuned-profiles-cpu-partitioning tuned-profiles-mssql tuned-profiles-nfv tuned-profiles-nfv-guest \
39+
tuned-profiles-nfv-host tuned-profiles-openshift tuned-profiles-oracle tuned-profiles-postgresql tuned-profiles-realtime \
40+
tuned-profiles-sap tuned-profiles-sap-hana tuned-profiles-spectrumscale \
41+
nmap-ncat procps-ng pciutils"
42+
cp -r /root/assets/bin /usr/local/bin
43+
mkdir -p /etc/grub.d/ /boot /var/lib/ocp-tuned
44+
dnf install --setopt=tsflags=nodocs -y ${INSTALL_PKGS}
45+
rm -rf /etc/tuned/recommend.d
46+
echo auto > /etc/tuned/profile_mode
47+
sed -Ei 's|^#?\s*enable_unix_socket\s*=.*$|enable_unix_socket = 1|;s|^#?\s*rollback\s*=.*$|rollback = not_on_exit|;s|^#?\s*profile_dirs\s*=.*$|profile_dirs = /var/lib/ocp-tuned/profiles,/usr/lib/tuned|' /etc/tuned/tuned-main.conf;
48+
49+
fi
50+
51+
touch /etc/sysctl.conf

0 commit comments

Comments
 (0)