FROM openshift/golang-builder:1.13 AS builder
ENV __doozer=update BUILD_RELEASE=202102200202.p0 BUILD_VERSION=v4.5.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=5 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.5.0-202102200202.p0 SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge KUBE_GIT_COMMIT=4f2c0be1a50b9b77865373088630f3aa2d3cd6db KUBE_GIT_MAJOR=1 KUBE_GIT_MINOR=18+ KUBE_GIT_TREE_STATE=clean KUBE_GIT_VERSION=v1.18.0+4f2c0be OS_GIT_COMMIT=4f2c0be OS_GIT_VERSION=4.5.0-202102200202.p0-4f2c0be SOURCE_DATE_EPOCH=1602078611 SOURCE_GIT_COMMIT=4f2c0be1a50b9b77865373088630f3aa2d3cd6db SOURCE_GIT_TAG=4f2c0be1 SOURCE_GIT_URL=https://github.com/openshift/cluster-node-tuning-operator 
WORKDIR /go/src/github.com/openshift/cluster-node-tuning-operator
COPY . .
RUN make build

FROM openshift/ose-base:v4.5.0.20210220.024259
ENV __doozer=update BUILD_RELEASE=202102200202.p0 BUILD_VERSION=v4.5.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=5 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.5.0-202102200202.p0 SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge KUBE_GIT_COMMIT=4f2c0be1a50b9b77865373088630f3aa2d3cd6db KUBE_GIT_MAJOR=1 KUBE_GIT_MINOR=18+ KUBE_GIT_TREE_STATE=clean KUBE_GIT_VERSION=v1.18.0+4f2c0be OS_GIT_COMMIT=4f2c0be OS_GIT_VERSION=4.5.0-202102200202.p0-4f2c0be SOURCE_DATE_EPOCH=1602078611 SOURCE_GIT_COMMIT=4f2c0be1a50b9b77865373088630f3aa2d3cd6db SOURCE_GIT_TAG=4f2c0be1 SOURCE_GIT_URL=https://github.com/openshift/cluster-node-tuning-operator 
COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/_output/cluster-node-tuning-operator /usr/bin/
COPY manifests /manifests
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/cluster-node-tuning-operator/_output/openshift-tuned /usr/bin/
COPY --from=builder /go/src/github.com/openshift/cluster-node-tuning-operator/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) && \
    mkdir -p /etc/grub.d/ /boot && \
    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 / || :) && \
    chmod 755 /usr/lib/tuned/*/script.sh && \
    touch /etc/sysctl.conf && \
    yum -y remove patch && \
    yum clean all && \
    rm -rf /var/cache/yum ~/patches && \
    useradd -r -u 499 cluster-node-tuning-operator
ENTRYPOINT ["/usr/bin/cluster-node-tuning-operator"]

LABEL \
        io.k8s.display-name="OpenShift cluster-node-tuning-operator" \
        io.k8s.description="This is a component of OpenShift and manages the lifecycle of node-level tuning." \
        io.openshift.release.operator="true" \
        name="openshift/ose-cluster-node-tuning-operator" \
        com.redhat.component="cluster-node-tuning-operator-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="Node Tuning Operator" \
        release="202102200202.p0" \
        io.openshift.build.commit.id="4f2c0be1a50b9b77865373088630f3aa2d3cd6db" \
        io.openshift.build.source-location="https://github.com/openshift/cluster-node-tuning-operator" \
        io.openshift.build.commit.url="https://github.com/openshift/cluster-node-tuning-operator/commit/4f2c0be1a50b9b77865373088630f3aa2d3cd6db" \
        version="v4.5.0"

