# 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-controller-openshift:1.0 image.

FROM rhpam-7/rhpam70-controller: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="rhpam-7/rhpam70-controller-openshift" \
    JBOSS_IMAGE_VERSION="1.0" \
    JBOSS_MODULES_SYSTEM_PKGS="org.jboss.logmanager,jdk.nashorn.api" \
    JOLOKIA_VERSION="1.5.0" \
    MAVEN_VERSION="3.5" 

# Labels
LABEL \
      architecture="x86_64"  \
      com.redhat.component="rhpam-7-rhpam70-controller-openshift-container"  \
      description="Red Hat Process Automation Manager Standalone Controller 7.0 container image"  \
      io.cekit.version="2.0.0rc4"  \
      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 Process Automation Manager Standalone Controller"  \
      io.k8s.display-name="Red Hat Process Automation Manager Standalone Controller 7.0"  \
      io.openshift.expose-services="8080:http,8443:https"  \
      io.openshift.tags="javaee,eap,eap7,rhpam,rhpam7"  \
      name="rhpam-7/rhpam70-controller-openshift"  \
      org.concrt.version="2.0.0rc4"  \
      summary="Red Hat Process Automation Manager Standalone Controller 7.0 container image"  \
      version="1.0" 

# Exposed ports
EXPOSE 8080 8443 8778

USER root

# Add custom repo files
COPY \  
    repos/jboss-os.repo \
 
    repos/jboss-rhscl.repo \
    /etc/yum.repos.d/


# Install required RPMs and ensure that the packages were installed
RUN yum install -y rh-mongodb32-mongo-java-driver postgresql-jdbc mysql-connector-java hostname python-requests python-enum34 PyYAML rh-maven35 \
    && yum clean all && rm -rf /var/cache/yum && \
    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-os.repo /etc/yum.repos.d/jboss-rhscl.repo

# Add all artifacts to the /tmp/artifacts
# directory
COPY \
    javax.json-1.0.4.jar \
    jboss-logmanager-ext-1.0.0.Alpha2-redhat-1.jar \
    oauth-20100527.jar \
    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 \
    jboss-logmanager-ext-1.0.0.Alpha5-redhat-1.jar \
    rh-sso-7.1.0-eap7-adapter.zip \
    rh-sso-7.1.2-saml-eap7-adapter.zip \
    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-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.standalonecontroller/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"]
