FROM openshift/golang-builder:1.13 AS builder
ENV __doozer=update BUILD_RELEASE=202006211643.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-202006211643.p? 
ENV __doozer=merge OS_GIT_COMMIT=5fd53e5 OS_GIT_VERSION=4.4.0-202006211643.p?-5fd53e5 SOURCE_DATE_EPOCH=1582844412 SOURCE_GIT_COMMIT=5fd53e572b3aa013b5159aba81ea1c7d7bb31f32 SOURCE_GIT_TAG=5fd53e57 SOURCE_GIT_URL=https://github.com/openshift/ocp-release-operator-sdk 

ENV GO111MODULE=on \
    GOFLAGS=-mod=vendor

COPY . /go/src/github.com/operator-framework/operator-sdk
RUN cd /go/src/github.com/operator-framework/operator-sdk \
 && make build/operator-sdk-dev VERSION=dev

FROM openshift/ose-base:v4.4.0.20200621.171015
ENV __doozer=update BUILD_RELEASE=202006211643.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-202006211643.p? 
ENV __doozer=merge OS_GIT_COMMIT=5fd53e5 OS_GIT_VERSION=4.4.0-202006211643.p?-5fd53e5 SOURCE_DATE_EPOCH=1582844412 SOURCE_GIT_COMMIT=5fd53e572b3aa013b5159aba81ea1c7d7bb31f32 SOURCE_GIT_TAG=5fd53e57 SOURCE_GIT_URL=https://github.com/openshift/ocp-release-operator-sdk 

RUN yum install -y \
      ansible \
      ansible-runner \
      ansible-runner-http \
      python-kubernetes \
      python-openshift \
      python-jmespath \
      tini \
      inotify-tools \
      python-requests-2.6.0-7.el7_7 \
 && yum clean all \
 && rm -rf /var/cache/yum

RUN mkdir -p /etc/ansible \
    && echo "localhost ansible_connection=local" > /etc/ansible/hosts \
    && echo '[defaults]' > /etc/ansible/ansible.cfg \
    && echo 'roles_path = /opt/ansible/roles' >> /etc/ansible/ansible.cfg \
    && echo 'library = /usr/share/ansible/openshift' >> /etc/ansible/ansible.cfg

ENV OPERATOR=/usr/local/bin/ansible-operator \
    USER_UID=1001 \
    USER_NAME=ansible-operator\
    HOME=/opt/ansible

COPY --from=builder /go/src/github.com/operator-framework/operator-sdk/build/operator-sdk-dev ${OPERATOR}
COPY bin /usr/local/bin
COPY library/k8s_status.py /usr/share/ansible/openshift/

RUN /usr/local/bin/user_setup

# Ensure directory permissions are properly set
RUN mkdir -p ${HOME}/.ansible/tmp \
 && chown -R ${USER_UID}:0 ${HOME} \
 && chmod -R ug+rwx ${HOME}

ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/entrypoint"]

USER ${USER_UID}

LABEL \
        name="openshift/ose-ansible-operator" \
        com.redhat.component="openshift-enterprise-ansible-operator-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        version="v4.4.0" \
        release="202006211643.p0" \
        io.openshift.build.commit.id="5fd53e572b3aa013b5159aba81ea1c7d7bb31f32" \
        io.openshift.build.source-location="https://github.com/openshift/ocp-release-operator-sdk" \
        io.openshift.build.commit.url="https://github.com/openshift/ocp-release-operator-sdk/commit/5fd53e572b3aa013b5159aba81ea1c7d7bb31f32"

