# This Dockerfile is a used by CI to publish an installer image
# It builds an image containing openshift-install.

FROM openshift/golang-builder:rhel_8_golang_1.16 AS builder
ENV __doozer=update BUILD_RELEASE=202112070138.p0.g4ee186b.assembly.stream BUILD_VERSION=v4.9.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=9 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.9.0-202112070138.p0.g4ee186b.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=4ee186b OS_GIT_VERSION=4.9.0-202112070138.p0.g4ee186b.assembly.stream-4ee186b SOURCE_DATE_EPOCH=1638837804 SOURCE_GIT_COMMIT=4ee186bb88bf6aeef8ccffd0b5d4e98e9ddd895f SOURCE_GIT_TAG=unreleased-master-5007-g4ee186bb8 SOURCE_GIT_URL=https://github.com/openshift/installer 
ARG TAGS="libvirt baremetal"
RUN yum install -y libvirt-devel-6.0.0 && \
    yum clean all && rm -rf /var/cache/yum/*
WORKDIR /go/src/github.com/openshift/installer
COPY . .
RUN DEFAULT_ARCH="$(go env GOHOSTARCH)" GOFLAGS='-mod=vendor -p=8' hack/build.sh


FROM openshift/ose-base:v4.9.0-202111151318.p0.gf93eca8.assembly.stream
ENV __doozer=update BUILD_RELEASE=202112070138.p0.g4ee186b.assembly.stream BUILD_VERSION=v4.9.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=9 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.9.0-202112070138.p0.g4ee186b.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=4ee186b OS_GIT_VERSION=4.9.0-202112070138.p0.g4ee186b.assembly.stream-4ee186b SOURCE_DATE_EPOCH=1638837804 SOURCE_GIT_COMMIT=4ee186bb88bf6aeef8ccffd0b5d4e98e9ddd895f SOURCE_GIT_TAG=unreleased-master-5007-g4ee186bb8 SOURCE_GIT_URL=https://github.com/openshift/installer 
COPY --from=builder /go/src/github.com/openshift/installer/bin/openshift-install /bin/openshift-install
COPY --from=builder /go/src/github.com/openshift/installer/data/data/rhcos.json /var/cache/

RUN yum update -y && \
    yum install --setopt=tsflags=nodocs -y \
    libvirt-libs-6.0.0 openssl unzip jq openssh-clients && \
    yum clean all && rm -rf /var/cache/yum/* && \
    chmod g+w /etc/passwd

RUN mkdir /output && chown 1000:1000 /output
USER 1000:1000
ENV PATH /bin
ENV HOME /output
WORKDIR /output
ENTRYPOINT ["/bin/openshift-install"]

LABEL \
        name="openshift/ose-baremetal-installer" \
        com.redhat.component="ose-baremetal-installer-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="Installer" \
        release="202112070138.p0.g4ee186b.assembly.stream" \
        io.openshift.build.commit.id="4ee186bb88bf6aeef8ccffd0b5d4e98e9ddd895f" \
        io.openshift.build.source-location="https://github.com/openshift/installer" \
        io.openshift.build.commit.url="https://github.com/openshift/installer/commit/4ee186bb88bf6aeef8ccffd0b5d4e98e9ddd895f" \
        version="v4.9.0"

