# 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 rhpam-7/rhpam70-businesscentral-monitoring-openshift:1.1 image.

FROM rhpam-7/rhpam70-businesscentral-monitoring:latest

# Environment variables
ENV JBOSS_IMAGE_NAME="rhpam-7/rhpam70-businesscentral-monitoring-openshift" \
    JBOSS_IMAGE_VERSION="1.1" \
    JBOSS_MODULES_SYSTEM_PKGS="org.jboss.logmanager,jdk.nashorn.api" \
    DEFAULT_ADMIN_USERNAME="eapadmin" \
    HTTPS_ENABLE_HTTP2="true" \
    JOLOKIA_VERSION="1.5.0" \
    AB_JOLOKIA_PASSWORD_RANDOM="true" \
    AB_JOLOKIA_AUTH_OPENSHIFT="true" \
    AB_JOLOKIA_HTTPS="true" \
    MAVEN_VERSION="3.5" 

# Labels
LABEL name="$JBOSS_IMAGE_NAME" \
      version="$JBOSS_IMAGE_VERSION" \
      architecture="x86_64"  \
      com.redhat.component="rhpam-7-rhpam70-businesscentral-monitoring-openshift-container" \
      io.k8s.description="Platform for running Red Hat Business Central Monitoring" \
      io.k8s.display-name="Red Hat Business Central Monitoring 7.0" \
      io.openshift.expose-services="8080:http,8443:https" \
      io.openshift.tags="javaee,eap,eap7,rhpam,rhpam7" \
      org.concrt.version="1.4.1" \
      description="Red Hat Business Central Monitoring 7.0 OpenShift container image" \
      summary="Red Hat Business Central Monitoring 7.0 OpenShift container image" \
      io.fabric8.s2i.version.jolokia="1.5.0-redhat-1" \
      io.fabric8.s2i.version.maven="3.5"

# Exposed ports
EXPOSE 8080 8443 8778

USER root

# Add custom repo files
COPY repos/*.repo /etc/yum.repos.d/

# Install required RPMs and ensure that the packages were installed
RUN yum install -y --disablerepo=\* --enablerepo=jboss-rhel-os --enablerepo=jboss-rhel-rhscl rh-mongodb32-mongo-java-driver postgresql-jdbc mysql-connector-java hostname python-requests python-enum34 PyYAML rh-maven35 \
    && yum clean all && \
    rpm -q  rh-mongodb32-mongo-java-driver postgresql-jdbc mysql-connector-java hostname python-requests python-enum34 PyYAML rh-maven35
# Remove custom repo files
RUN rm /etc/yum.repos.d/jboss-rhel-os.repo /etc/yum.repos.d/jboss-rhel-rhscl.repo

# Add all artifacts to the /tmp/artifacts
# directory
COPY \
    javax.json-1.0.4.jar \
    jboss-logmanager-ext-1.0.0.Alpha5-redhat-1.jar \
    oauth-20100527.jar \
    activemq-rar-5.11.0.redhat-630329.rar \
    rh-sso-7.1.0-eap7-adapter.zip \
    rh-sso-7.1.2-saml-eap7-adapter.zip \
    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 \
    hawkular-javaagent-1.0.1.Final-redhat-2-shaded.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/java-alternatives/run.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-eap7-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/install_as_root" ]

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

USER 185
RUN [ "bash", "-x", "/tmp/scripts/os-eap-logging/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/os.bpmsuite.common/configure.sh" ]

USER root
RUN [ "bash", "-x", "/tmp/scripts/os.bpmsuite.businesscentral/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"]
