FROM openshift3/golang-builder AS dv-builder

ENV DV_OPERATOR_TAG=e0498dae38001cdc6ce1723c1a123a61aa4b9201

COPY teiid-operator-$DV_OPERATOR_TAG.tar.gz /
RUN tar zxf /teiid-operator-$DV_OPERATOR_TAG.tar.gz 

RUN [ "/bin/bash", "-lc", "mkdir -p /go/src/github.com/teiid/ \
    && mv /teiid-operator-$DV_OPERATOR_TAG /go/src/github.com/teiid/teiid-operator \
    && cd /go/src/github.com/teiid/teiid-operator \
    && go build -o /teiid-operator ./cmd/manager/main.go" ]

FROM ubi7-minimal:7-released

LABEL name="fuse7-tech-preview/dv-rhel7-operator" \
      version="1.6" \
      maintainer="Van Halbert <vhalbert@redhat.com>" \
      summary="Data Virtualization Cloud Operator for deployment and management of Virtual Database services." \
      description="Data Virtualization (DV) system allows applications to access data from multiple, heterogeneous data stores. Through its abstraction and federation layers, data is accessed and  integrated in real-time across distributed data sources without copying or otherwise moving data from its system of record.   \
      For example, you can access your all data in Oracle, Postgres, MongoDB and/or Rest API (many more) with a single request. Data Virtualization gives you all the tools required to build logical/abstraction layer that can exposed as Virtual Database by essentially making all sources underneath as a black box to the consuming user. Since this integration of data happens in real time there is no ETL process to run and data is always fresh. For the end user the Virtual Database exactly looks like a relational database like Postgres, that can be accessed using JDBC, ODBC, OData V4 and Postgres protocols, i.e. can be accessed from any language that you have your application written in.  \
      DV, out of box also exposes the OData v4 REST API without any further coding, with this you can expose you single or multiple databases as rest services without any coding. Alternatively if you want expose a Open API directly over your data that is also possible with DV." \
      com.redhat.component="dv-operator-container" \
      io.k8s.display-name="Red Hat Fuse - Data Virtualization Operator" \
      io.openshift.tags="Data, Integration, Data Virtualization, VDB" \
      com.redhat.delivery.appregistry=true


ENV NAMESPACE_NAME=ns-dv \
    APP_IMAGE="dv-operator" \
    USER_NAME=operator \
    OPERATOR=/usr/local/bin/teiid-operator

USER root

COPY --from=dv-builder /teiid-operator ${OPERATOR}

COPY --from=dv-builder /go/src/github.com/teiid/teiid-operator/build/bin /usr/local/bin


COPY build/bin /usr/local/bin


ADD manifests /manifests
# Add conf directory
ADD build/conf /conf

RUN /usr/local/bin/user_setup

USER 1001

ENTRYPOINT ["/usr/local/bin/entrypoint"]


