
# Copyright 2019 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/rhpam-smartrouter-rhel8:7.9.1 image.

FROM registry.redhat.io/ubi8/ubi:latest

USER root

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

# Add all artifacts to the /tmp/artifacts directory
COPY \
    jboss-eap-7.3.3-patch.zip \
    rhpam_business_central_distribution.zip \
    rhpam_business_central_monitoring_distribution.zip \
    rhpam_add_ons_distribution.zip \
    rhpam_kie_server_distribution.zip \
    rhdm_add_ons_distribution.zip \
    rhdm_decision_central_distribution.zip \
    rhdm_kie_server_distribution.zip \
    /tmp/artifacts/

# begin jboss.container.user:1.0

# Install required RPMs and ensure that the packages were installed
USER root
RUN yum --setopt=tsflags=nodocs install -y unzip tar rsync shadow-utils \
    && rpm -q unzip tar rsync shadow-utils

# Environment variables
ENV \
    HOME="/home/jboss" 

# Custom scripts
USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.user/configure.sh" ]

# end jboss.container.user:1.0
# begin jboss.container.openjdk.jdk:11

# Install required RPMs and ensure that the packages were installed
USER root
RUN yum --setopt=tsflags=nodocs install -y java-11-openjdk-devel \
    && rpm -q java-11-openjdk-devel

# Environment variables
ENV \
    JAVA_HOME="/usr/lib/jvm/java-11" \
    JAVA_VENDOR="openjdk" \
    JAVA_VERSION="11.0" \
    JBOSS_CONTAINER_OPENJDK_JDK_MODULE="/opt/jboss/container/openjdk/jdk" 

# Labels
LABEL \
      org.jboss.product="openjdk"  \
      org.jboss.product.openjdk.version="11.0"  \
      org.jboss.product.version="11.0" 

# Custom scripts
USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.openjdk.jdk/configure.sh" ]

# end jboss.container.openjdk.jdk:11
# begin jboss.container.java.jvm.api:1.0

# end jboss.container.java.jvm.api:1.0
# begin jboss.container.proxy.api:2.0

# end jboss.container.proxy.api:2.0
# begin jboss.container.java.proxy.bash:2.0

# Environment variables
ENV \
    JBOSS_CONTAINER_JAVA_PROXY_MODULE="/opt/jboss/container/java/proxy" 

# Custom scripts
USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.java.proxy.bash/configure.sh" ]
USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.java.proxy.bash/backward_compatibility.sh" ]

# end jboss.container.java.proxy.bash:2.0
# begin jboss.container.java.jvm.bash:1.0

# Environment variables
ENV \
    JBOSS_CONTAINER_JAVA_JVM_MODULE="/opt/jboss/container/java/jvm" 

# Custom scripts
USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.java.jvm.bash/configure.sh" ]
USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.java.jvm.bash/backward_compatibility.sh" ]

# end jboss.container.java.jvm.bash:1.0
# begin dynamic-resources:1.0

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

# end dynamic-resources:1.0
# begin rhpam-7-smartrouter:1.0

# Environment variables
ENV \
    ADD_ONS_DISTRIBUTION_ZIP="rhpam_add_ons_distribution.zip" \
    JBOSS_HOME="/opt/rhpam-smartrouter" \
    JBOSS_PRODUCT="rhpam-smartrouter" \
    KIE_ROUTER_DISTRIBUTION_JAR="rhpam-7.9.1-smart-router.jar" \
    LAUNCH_DIR="/opt/rhpam-smartrouter/launch" \
    PRODUCT_VERSION="7.9.1" \
    RHPAM_SMARTROUTER_VERSION="7.9.1" 

# Labels
LABEL \
      org.jboss.product="rhpam-smartrouter"  \
      org.jboss.product.rhpam-smartrouter.version="7.9.1"  \
      org.jboss.product.version="7.9.1" 

# Exposed ports
EXPOSE 9000
# Custom scripts
USER root
RUN [ "bash", "-x", "/tmp/scripts/rhpam-7-smartrouter/install" ]

# end rhpam-7-smartrouter:1.0
# begin jboss.container.util.logging.bash:1.0

# Environment variables
ENV \
    JBOSS_CONTAINER_UTIL_LOGGING_MODULE="/opt/jboss/container/util/logging/" 

# Custom scripts
USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.util.logging.bash/configure.sh" ]
USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.util.logging.bash/backward_compatibility.sh" ]

# end jboss.container.util.logging.bash:1.0
# begin os-eap-python:3.6

# Install required RPMs and ensure that the packages were installed
USER root
RUN yum --setopt=tsflags=nodocs install -y python36 \
    && rpm -q python36

# Custom scripts
USER root
RUN [ "bash", "-x", "/tmp/scripts/os-eap-python/configure.sh" ]

# end os-eap-python:3.6
# begin jboss-kie-common:1.0

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

# end jboss-kie-common:1.0
# begin jboss-kie-smartrouter:1.0

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

# end jboss-kie-smartrouter:1.0
# begin rhpam-7/rhpam-smartrouter-rhel8:7.9.1

# Install required RPMs and ensure that the packages were installed
USER root
RUN yum --setopt=tsflags=nodocs install -y hostname \
    && rpm -q hostname

# Environment variables
ENV \
    JBOSS_IMAGE_NAME="rhpam-7/rhpam-smartrouter-rhel8" \
    JBOSS_IMAGE_VERSION="7.9.1" \
    KIE_SERVER_ROUTER_PORT_TLS="9443" 

# Labels
LABEL \
      com.redhat.component="rhpam-7-smartrouter-rhel8-container"  \
      description="Red Hat Process Automation Manager Smart Router 7.9 container image"  \
      io.cekit.version="3.2.1"  \
      io.k8s.description="Platform for running Red Hat Process Automation Manager Smart Router"  \
      io.k8s.display-name="Red Hat Process Automation Manager Smart Router 7.9"  \
      io.openshift.expose-services="9000:http"  \
      io.openshift.tags="javaee,rhpam,rhpam7"  \
      name="rhpam-7/rhpam-smartrouter-rhel8"  \
      summary="Red Hat Process Automation Manager Smart Router 7.9 container image"  \
      version="7.9.1" 

# Exposed ports
EXPOSE 9000
# end rhpam-7/rhpam-smartrouter-rhel8:7.9.1

USER root
RUN [ ! -d /tmp/scripts ] || rm -rf /tmp/scripts
RUN [ ! -d /tmp/artifacts ] || rm -rf /tmp/artifacts

# Clear package manager metadata
RUN yum clean all && [ ! -d /var/cache/yum ] || rm -rf /var/cache/yum



# Run user
USER 185

# Specify the working directory
WORKDIR /home/jboss

# Specify run cmd
CMD ["/opt/rhpam-smartrouter/openshift-launch.sh"]
