FROM openshift/golang-builder:1.10 AS builder
ENV SOURCE_GIT_COMMIT=57620ee2f090512828605458da4676bfc3629646 SOURCE_GIT_TAG=57620ee SOURCE_DATE_EPOCH=1556288222
COPY . /go/src/github.com/operator-framework/operator-sdk
RUN cd /go/src/github.com/operator-framework/operator-sdk \
 && make build/operator-sdk-dev-x86_64-linux-gnu VERSION=dev

FROM openshift/apb-base:v4.1.3.20190619.171706
ENV SOURCE_GIT_COMMIT=57620ee2f090512828605458da4676bfc3629646 SOURCE_GIT_TAG=57620ee SOURCE_DATE_EPOCH=1556288222
RUN yum -y install ansible-runner-http python-kubernetes python-openshift

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-x86_64-linux-gnu ${OPERATOR}
COPY --from=builder /go/src/github.com/operator-framework/operator-sdk/bin /usr/local/bin
COPY --from=builder /go/src/github.com/operator-framework/operator-sdk/library/k8s_status.py /usr/share/ansible/openshift/

RUN /usr/local/bin/user_setup
ENTRYPOINT ["/usr/local/bin/entrypoint"]
USER ${USER_UID}

LABEL \
        com.redhat.component="openshift-enterprise-ansible-operator-container" \
        io.openshift.build.commit.url="https://github.com/openshift/ocp-release-operator-sdk/commit/57620ee2f090512828605458da4676bfc3629646" \
        version="v4.1.3" \
        name="openshift/ose-ansible-operator" \
        io.openshift.build.commit.id="57620ee2f090512828605458da4676bfc3629646" \
        release="201906191717" \
        io.openshift.build.source-location="https://github.com/openshift/ocp-release-operator-sdk"

