FROM openshift/golang-builder:1.13 AS builder
ENV __doozer=update BUILD_RELEASE=202011142049.p0 BUILD_VERSION=v4.4.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=4 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.4.0-202011142049.p0 SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=927879f OS_GIT_VERSION=4.4.0-202011142049.p0-927879f SOURCE_DATE_EPOCH=1576697991 SOURCE_GIT_COMMIT=927879ff50be0cec707be97c357d2891786d346f SOURCE_GIT_TAG=v0.0.1-39-g927879f SOURCE_GIT_URL=https://github.com/openshift/openshift-tuned 
WORKDIR /go/src/github.com/openshift/openshift-tuned
COPY . .
RUN make build

FROM openshift/ose-base:ubi7
ENV __doozer=update BUILD_RELEASE=202011142049.p0 BUILD_VERSION=v4.4.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=4 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.4.0-202011142049.p0 SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=927879f OS_GIT_VERSION=4.4.0-202011142049.p0-927879f SOURCE_DATE_EPOCH=1576697991 SOURCE_GIT_COMMIT=927879ff50be0cec707be97c357d2891786d346f SOURCE_GIT_TAG=v0.0.1-39-g927879f SOURCE_GIT_URL=https://github.com/openshift/openshift-tuned 
ENV APP_ROOT=/var/lib/tuned
ENV PATH=${APP_ROOT}/bin:${PATH}
ENV HOME=${APP_ROOT}
WORKDIR ${APP_ROOT}
COPY --from=builder /go/src/github.com/openshift/openshift-tuned/_output/openshift-tuned /usr/bin/
COPY --from=builder /go/src/github.com/openshift/openshift-tuned/assets ${APP_ROOT}
RUN INSTALL_PKGS=" \
      tuned tuna tuned-profiles-cpu-partitioning patch socat \
      " && \
    ARCH_DEP_PKGS=$(if [ "$(uname -m)" != "s390x" ]; then echo -n hdparm kernel-tools ; fi) && \
    yum install --setopt=tsflags=nodocs -y $INSTALL_PKGS $ARCH_DEP_PKGS && \
    rpm -V $INSTALL_PKGS $ARCH_DEP_PKGS && \
    (LC_COLLATE=C cat patches/*.diff | patch -Np1 -d /usr/lib/python*/site-packages/tuned/ || :) && \
    touch /etc/sysctl.conf && \
    yum -y remove patch && \
    yum clean all && \
    rm -rf /var/cache/yum ~/patches
ENTRYPOINT [ "/var/lib/tuned/bin/run" ]

LABEL \
        name="openshift/ose-cluster-node-tuned" \
        com.redhat.component="tuned-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="Node Tuning Operator" \
        release="202011142049.p0" \
        io.openshift.build.commit.id="927879ff50be0cec707be97c357d2891786d346f" \
        io.openshift.build.source-location="https://github.com/openshift/openshift-tuned" \
        io.openshift.build.commit.url="https://github.com/openshift/openshift-tuned/commit/927879ff50be0cec707be97c357d2891786d346f" \
        version="v4.4.0"

