# Copyright 2017 Red Hat
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------
#
# This is a Dockerfile for the rhdm-7/rhdm71-kieserver-openshift:1.1 image.

FROM rhdm-7/rhdm71-kieserver:latest

# Environment variables
ENV \
    AB_JOLOKIA_AUTH_OPENSHIFT="true" \
    AB_JOLOKIA_HTTPS="true" \
    AB_JOLOKIA_PASSWORD_RANDOM="true" \
    DEFAULT_ADMIN_USERNAME="eapadmin" \
    HTTPS_ENABLE_HTTP2="true" \
    JBOSS_IMAGE_NAME="rhdm-7/rhdm71-kieserver-openshift" \
    JBOSS_IMAGE_VERSION="1.1" \
    JBOSS_MODULES_SYSTEM_PKGS="org.jboss.logmanager,jdk.nashorn.api" \
    JOLOKIA_VERSION="1.5.0" \
    MAVEN_VERSION="3.5" \
    STI_BUILDER="jee" 

# Labels
LABEL \
      com.redhat.component="rhdm-7-rhdm71-kieserver-openshift-container"  \
      description="Red Hat Decision Manager Kie Server 7.1 container image"  \
      io.cekit.version="2.1.4"  \
      io.fabric8.s2i.version.jolokia="1.5.0-redhat-1"  \
      io.fabric8.s2i.version.maven="3.5"  \
      io.k8s.description="Platform for running Red Hat Decision Manager KIE Server"  \
      io.k8s.display-name="Red Hat Decision Manager KIE Server 7.1"  \
      io.openshift.expose-services="8080:http,8443:https"  \
      io.openshift.s2i.scripts-url="image:///usr/local/s2i"  \
      io.openshift.tags="builder,javaee,eap,eap7,rhdm,rhdm7"  \
      name="rhdm-7/rhdm71-kieserver-openshift"  \
      org.concrt.version="2.1.4"  \
      summary="Red Hat Decision Manager Kie Server 7.1 container image"  \
      version="1.1" 

# Exposed ports
EXPOSE 8778 8080 8443

USER root


# Install required RPMs and ensure that the packages were installed
RUN yum install -y rh-maven35 rh-mongodb32-mongo-java-driver postgresql-jdbc mysql-connector-java python-requests python-enum34 PyYAML hostname \
    && yum clean all && rm -rf /var/cache/yum && \
    rpm -q  rh-maven35 rh-mongodb32-mongo-java-driver postgresql-jdbc mysql-connector-java python-requests python-enum34 PyYAML hostname

# Add all artifacts to the /tmp/artifacts
# directory
COPY \
    jolokia-jvm-1.5.0.redhat-1-agent.jar \
    openshift-ping-common-1.2.1.Final-redhat-1.jar \
    openshift-ping-dns-1.2.1.Final-redhat-1.jar \
    openshift-ping-kube-1.2.1.Final-redhat-1.jar \
    oauth-20100527.jar \
    activemq-rar-5.11.0.redhat-630347.rar \
    javax.json-1.0.4.jar \
    jboss-logmanager-ext-1.0.0.Alpha5-redhat-1.jar \
    rh-sso-7.2.2-eap7-adapter.zip \
    rh-sso-7.2.2-saml-eap7-adapter.zip \
    hawkular-javaagent-1.0.1.Final-redhat-2-shaded.jar \
    slf4j-simple-1.7.22.redhat-1.jar \
    /tmp/artifacts/

# Add scripts used to configure the image
COPY modules /tmp/scripts

# Custom scripts
USER root
RUN [ "bash", "-x", "/tmp/scripts/os-java-run/install_as_root" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/dynamic-resources/install.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/s2i-common/install.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/java-alternatives/run.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/os-eap-s2i/prepare.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/os-java-jolokia/install_as_root" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/jolokia/configure.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/os-eap7-openshift/prepare.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap7-openshift/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap71-openshift/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap7-modules/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap71-modules/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap7-ping/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap-activemq-rar/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap-launch/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap-node-name/configure.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/os-partition-txnrecovery/install_as_root.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap-migration/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap7-launch/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.eap.logging.ext/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap-probes/configure.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss-maven/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap-db-drivers/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap-sso/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap70-sso/configure.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/os-java-hawkular/install_as_root" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/os-eap70-hawkular/install_as_root" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap-hawkular/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap-deployment-scanner/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap-extensions/configure.sh" ]

USER 185
RUN [ "bash", "-x", "/tmp/scripts/openshift-layer/configure_layers.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/openshift-passwd/configure_passwd.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/os-logging/configure.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss.kie.common/configure.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss.kie.kieserver/configure.sh" ]

USER root
RUN rm -rf /tmp/scripts
USER root
RUN rm -rf /tmp/artifacts

USER 185



CMD ["/opt/eap/bin/openshift-launch.sh"]

