diff --git a/Dockerfile b/Dockerfile index 5eb02a290d..7d57076c08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,44 +4,24 @@ COPY . . RUN make update-tuned-submodule RUN make build -FROM quay.io/centos/centos:stream9 as tuned -WORKDIR /root -COPY assets /root/assets -RUN INSTALL_PKGS=" \ - gcc git rpm-build make desktop-file-utils patch dnf-plugins-core \ - " && \ - dnf install --setopt=tsflags=nodocs -y $INSTALL_PKGS && \ - cd assets/tuned/tuned && \ - LC_COLLATE=C cat ../patches/*.diff | patch -Np1 && \ - dnf build-dep tuned.spec -y && \ - make rpm PYTHON=/usr/bin/python3 && \ - rm -rf /root/rpmbuild/RPMS/noarch/{tuned-gtk*,tuned-utils*,tuned-profiles-compat*} - FROM quay.io/centos/centos:stream9 COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/cluster-node-tuning-operator /usr/bin/ COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/performance-profile-creator /usr/bin/ COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/gather-sysinfo /usr/bin/ + +ENV ASSETS_DIR=/root/assets +COPY assets $ASSETS_DIR + +COPY hack/dockerfile_install_support.sh /tmp +RUN /bin/bash /tmp/dockerfile_install_support.sh + COPY manifests/*.yaml manifests/image-references /manifests/ ENV APP_ROOT=/var/lib/ocp-tuned ENV PATH=${APP_ROOT}/bin:${PATH} ENV HOME=${APP_ROOT} ENV SYSTEMD_IGNORE_CHROOT=1 WORKDIR ${APP_ROOT} -COPY --from=tuned /root/assets/bin /usr/local/bin -COPY --from=tuned /root/rpmbuild/RPMS/noarch /root/rpms -RUN INSTALL_PKGS=" \ - nmap-ncat procps-ng pciutils \ - " && \ - mkdir -p /etc/grub.d/ /boot /var/lib/ocp-tuned && \ - dnf install --setopt=tsflags=nodocs -y $INSTALL_PKGS && \ - rpm -V $INSTALL_PKGS && \ - dnf --setopt=tsflags=nodocs -y install /root/rpms/*.rpm && \ - rm -rf /etc/tuned/recommend.d && \ - echo auto > /etc/tuned/profile_mode && \ - 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 && \ - touch /etc/sysctl.conf && \ - dnf clean all && \ +RUN dnf clean all && \ rm -rf /var/cache/yum ~/patches /root/rpms && \ useradd -r -u 499 cluster-node-tuning-operator ENTRYPOINT ["/usr/bin/cluster-node-tuning-operator"] diff --git a/Dockerfile.rhel9 b/Dockerfile.rhel9 index d827da1322..0db4677668 100644 --- a/Dockerfile.rhel9 +++ b/Dockerfile.rhel9 @@ -7,26 +7,21 @@ FROM registry.ci.openshift.org/ocp/4.16:base-rhel9 COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/cluster-node-tuning-operator /usr/bin/ COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/performance-profile-creator /usr/bin/ COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/gather-sysinfo /usr/bin/ + +ENV ASSETS_DIR=/root/assets +COPY assets $ASSETS_DIR + +COPY hack/dockerfile_install_support.sh /tmp +RUN /bin/bash /tmp/dockerfile_install_support.sh + COPY manifests/*.yaml manifests/image-references /manifests/ ENV APP_ROOT=/var/lib/ocp-tuned ENV PATH=${APP_ROOT}/bin:${PATH} ENV HOME=${APP_ROOT} ENV SYSTEMD_IGNORE_CHROOT=1 WORKDIR ${APP_ROOT} -COPY assets/bin /usr/local/bin -RUN INSTALL_PKGS=" \ - tuned tuned-profiles-atomic tuned-profiles-cpu-partitioning tuned-profiles-mssql tuned-profiles-nfv tuned-profiles-nfv-guest \ - tuned-profiles-nfv-host tuned-profiles-openshift tuned-profiles-oracle tuned-profiles-postgresql tuned-profiles-realtime \ - tuned-profiles-sap tuned-profiles-sap-hana tuned-profiles-spectrumscale \ - nmap-ncat procps-ng pciutils" && \ - mkdir -p /etc/grub.d/ /boot /var/lib/ocp-tuned && \ - dnf install --setopt=tsflags=nodocs -y $INSTALL_PKGS && \ - rm -rf /etc/tuned/recommend.d && \ - echo auto > /etc/tuned/profile_mode && \ - 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 && \ - touch /etc/sysctl.conf && \ - dnf clean all && \ + +RUN dnf clean all && \ rm -rf /var/cache/yum ~/patches /root/rpms && \ useradd -r -u 499 cluster-node-tuning-operator ENTRYPOINT ["/usr/bin/cluster-node-tuning-operator"] diff --git a/hack/dockerfile_install_support.sh b/hack/dockerfile_install_support.sh new file mode 100644 index 0000000000..ab691ad130 --- /dev/null +++ b/hack/dockerfile_install_support.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +set -euo pipefail +set -o xtrace + +source /etc/os-release +if [[ "${ID}" == "centos" ]]; then + + # CentOS OKD build + BUILD_INSTALL_PKGS="gcc git rpm-build make desktop-file-utils patch dnf-plugins-core" + dnf install --setopt=tsflags=nodocs -y ${BUILD_INSTALL_PKGS} + cd /root/assets/tuned/tuned + LC_COLLATE=C cat ../patches/*.diff | patch -Np1 + dnf build-dep tuned.spec -y + make rpm PYTHON=/usr/bin/python3 + rm -rf /root/rpmbuild/RPMS/noarch/{tuned-gtk*,tuned-utils*,tuned-profiles-compat*}; + dnf --setopt=protected_packages= history -y undo 0 # Remove builddep + + INSTALL_PKGS="nmap-ncat procps-ng pciutils" + cp -r /root/assets/bin /usr/local/bin + cp -r /root/rpmbuild/RPMS/noarch /root/rpms + mkdir -p /etc/grub.d/ /boot /var/lib/ocp-tuned + dnf install --setopt=tsflags=nodocs -y ${INSTALL_PKGS} + rpm -V ${INSTALL_PKGS} + dnf --setopt=tsflags=nodocs -y install /root/rpms/*.rpm + rm -rf /etc/tuned/recommend.d + echo auto > /etc/tuned/profile_mode + 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; + + # Clean up build tools to remove image footprint + dnf remove --setopt=protected_packages= -y ${BUILD_INSTALL_PKGS} + dnf autoremove -y + +else + + # RHEL OCP build + INSTALL_PKGS=" \ + tuned tuned-profiles-atomic tuned-profiles-cpu-partitioning tuned-profiles-mssql tuned-profiles-nfv tuned-profiles-nfv-guest \ + tuned-profiles-nfv-host tuned-profiles-openshift tuned-profiles-oracle tuned-profiles-postgresql tuned-profiles-realtime \ + tuned-profiles-sap tuned-profiles-sap-hana tuned-profiles-spectrumscale \ + nmap-ncat procps-ng pciutils" + cp -r /root/assets/bin /usr/local/bin + mkdir -p /etc/grub.d/ /boot /var/lib/ocp-tuned + dnf install --setopt=tsflags=nodocs -y ${INSTALL_PKGS} + rm -rf /etc/tuned/recommend.d + echo auto > /etc/tuned/profile_mode + 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; + +fi + +touch /etc/sysctl.conf