FROM openshift/golang-builder:1.10 AS builder
ENV SOURCE_GIT_COMMIT=ad62020e2fd0e4ba11eb937da9bbb434f753ca2e SOURCE_DATE_EPOCH=1565854483 BUILD_VERSION=v4.1.22 SOURCE_GIT_URL=https://github.com/openshift/openshift-tuned SOURCE_GIT_TAG=v0.0.1-11-gad62020 BUILD_RELEASE=201910291109
WORKDIR /go/src/github.com/openshift/openshift-tuned
COPY . .
RUN make build

FROM openshift/ose-base:ubi7
ENV SOURCE_GIT_COMMIT=ad62020e2fd0e4ba11eb937da9bbb434f753ca2e SOURCE_DATE_EPOCH=1565854483 BUILD_VERSION=v4.1.22 SOURCE_GIT_URL=https://github.com/openshift/openshift-tuned SOURCE_GIT_TAG=v0.0.1-11-gad62020 BUILD_RELEASE=201910291109
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/openshift-tuned /usr/bin/
COPY --from=builder /go/src/github.com/openshift/openshift-tuned/assets ${APP_ROOT}
RUN INSTALL_PKGS=" \
      tuned hdparm kernel-tools patch \
      " && \
    yum install --setopt=tsflags=nodocs -y $INSTALL_PKGS && \
    rpm -V $INSTALL_PKGS && \
    (LC_COLLATE=C cat patches/*.diff | patch -Np1 -d /usr/lib/python*/site-packages/tuned/ || :) && \
    sed -i 's/^\s*daemon.*$/daemon = 0/' /etc/tuned/tuned-main.conf && \
    touch /etc/sysctl.conf && \
    yum -y remove patch && \
    yum clean all && \
    rm -rf /var/cache/yum ~/patches
ENTRYPOINT [ "/var/lib/tuned/bin/run" ]

LABEL \
        com.redhat.component="tuned-container" \
        io.openshift.build.commit.url="https://github.com/openshift/openshift-tuned/commit/ad62020e2fd0e4ba11eb937da9bbb434f753ca2e" \
        version="v4.1.22" \
        name="openshift/ose-cluster-node-tuned" \
        io.openshift.build.commit.id="ad62020e2fd0e4ba11eb937da9bbb434f753ca2e" \
        release="201910291109" \
        io.openshift.build.source-location="https://github.com/openshift/openshift-tuned"

