
# 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 rhdm-7/rhdm-decisioncentral-rhel8:7.10.1 image.

FROM registry.redhat.io/ubi8/ubi-minimal: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.4-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 \
    artifacts/jboss-eap-7.3.zip \
    jboss-eap-7.3.4-patch.zip \
    artifacts/jolokia-jvm-1.6.2.redhat-00002-agent.jar \
    activemq-rar-5.11.0.redhat-630371.rar \
    artifacts/rh-sso-7.3.1-eap7-adapter.zip \
    artifacts/rh-sso-7.3.1-saml-eap7-adapter.zip \
    artifacts/jmx_prometheus_javaagent-0.3.1.redhat-00006.jar \
    /tmp/artifacts/

# begin jboss.kie.common.dependencies:1.0

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

# end jboss.kie.common.dependencies:1.0
# begin jboss.container.user:1.0

# Install required RPMs and ensure that the packages were installed
USER root
RUN microdnf --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 microdnf --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 eap-73-env:7.3.4

# Environment variables
ENV \
    JBOSS_EAP_VERSION="7.3.4" \
    JBOSS_HOME="/opt/eap" \
    JBOSS_PRODUCT="eap" \
    LAUNCH_JBOSS_IN_BACKGROUND="true" \
    PRODUCT_VERSION="7.3.4" \
    WILDFLY_VERSION="7.3.4.GA-redhat-00003" 

# Labels
LABEL \
      com.redhat.deployments-dir="/opt/eap/standalone/deployments"  \
      com.redhat.dev-mode="DEBUG:true"  \
      com.redhat.dev-mode.port="DEBUG_PORT:8787"  \
      org.jboss.product="eap"  \
      org.jboss.product.eap.version="7.3.4"  \
      org.jboss.product.version="7.3.4" 

# Exposed ports
EXPOSE 8080
# end eap-73-env:7.3.4
# begin eap-73-env-latest:1.0

# end eap-73-env-latest:1.0
# begin eap-734:7.3.4

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

# end eap-734:7.3.4
# begin eap-install-cleanup:1.0

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

# end eap-install-cleanup:1.0
# begin eap-73-latest:7.3-latest

# end eap-73-latest:7.3-latest
# begin jboss.container.eap.setup:1.0

# Environment variables
ENV \
    SSO_FORCE_LEGACY_SECURITY="true" 

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

# end jboss.container.eap.setup:1.0
# begin rhdm-7-decisioncentral:1.0

# Environment variables
ENV \
    DECISION_CENTRAL_DISTRIBUTION_EAP="jboss-eap-7.3" \
    DECISION_CENTRAL_DISTRIBUTION_ZIP="rhdm_decision_central_distribution.zip" \
    JBOSS_PRODUCT="rhdm-decisioncentral" \
    PRODUCT_VERSION="7.10.1" \
    RHDM_DECISION_CENTRAL_VERSION="7.10.1" 

# Labels
LABEL \
      org.jboss.product="rhdm-decisioncentral"  \
      org.jboss.product.rhdm-decisioncentral.version="7.10.1"  \
      org.jboss.product.version="7.10.1" 

# Exposed ports
EXPOSE 8001
# Custom scripts
USER root
RUN [ "bash", "-x", "/tmp/scripts/rhdm-7-decisioncentral/install" ]

# end rhdm-7-decisioncentral:1.0
# begin jboss.container.maven.35.bash:3.5

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

# Environment variables
ENV \
    JBOSS_CONTAINER_MAVEN_35_MODULE="/opt/jboss/container/maven/35/" \
    MAVEN_VERSION="3.5" 

# Labels
LABEL \
      io.fabric8.s2i.version.maven="3.5" 

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

# end jboss.container.maven.35.bash:3.5
# begin jboss.container.maven.api:1.0

# end jboss.container.maven.api: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 jboss.container.maven.default.bash:1.0

# Environment variables
ENV \
    JBOSS_CONTAINER_MAVEN_DEFAULT_MODULE="/opt/jboss/container/maven/default/" 

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

# end jboss.container.maven.default.bash:1.0
# begin jboss.container.jolokia.api:1.0

# Environment variables
ENV \
    AB_JOLOKIA_AUTH_OPENSHIFT="true" \
    AB_JOLOKIA_HTTPS="true" \
    AB_JOLOKIA_PASSWORD_RANDOM="true" 

# end jboss.container.jolokia.api:1.0
# begin jboss.container.jolokia.bash:1.0

# Environment variables
ENV \
    AB_JOLOKIA_AUTH_OPENSHIFT="true" \
    AB_JOLOKIA_HTTPS="true" \
    AB_JOLOKIA_PASSWORD_RANDOM="true" \
    JBOSS_CONTAINER_JOLOKIA_MODULE="/opt/jboss/container/jolokia" \
    JOLOKIA_VERSION="1.6.2" 

# Labels
LABEL \
      io.fabric8.s2i.version.jolokia="1.6.2-redhat-00002" 

# Exposed ports
EXPOSE 8778
# Custom scripts
USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.jolokia.bash/configure.sh" ]
USER root
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.jolokia.bash/backward_compatibility.sh" ]

# end jboss.container.jolokia.bash:1.0
# begin jboss.eap.cd.jolokia:1.0-kie

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.eap.cd.jolokia/configure.sh" ]

# end jboss.eap.cd.jolokia:1.0-kie
# begin os-eap7-openshift:1.0-kie

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

# end os-eap7-openshift:1.0-kie
# begin jboss.eap.config.openshift:EAP7.3.0-kie

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.eap.config.openshift/configure.sh" ]

# end jboss.eap.config.openshift:EAP7.3.0-kie
# begin os-eap-activemq-rar:1.1

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

# end os-eap-activemq-rar:1.1
# begin os-eap-launch:1.0-kie

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

# Environment variables
ENV \
    DEFAULT_ADMIN_USERNAME="eapadmin" 

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

# end os-eap-launch:1.0-kie
# begin jboss.container.wildfly.launch.os.node-name:1.0

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.wildfly.launch.os.node-name/configure.sh" ]

# end jboss.container.wildfly.launch.os.node-name:1.0
# begin os-eap-migration:1.0

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

# end os-eap-migration:1.0
# begin os-eap7-launch:1.0-kie

# Environment variables
ENV \
    JBOSS_MODULES_SYSTEM_PKGS="org.jboss.logmanager,jdk.nashorn.api" 

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

# end os-eap7-launch:1.0-kie
# begin jboss-kie-db-drivers:1.0

# Install required RPMs and ensure that the packages were installed
USER root
RUN microdnf --setopt=tsflags=nodocs install -y mariadb-java-client postgresql-jdbc \
    && rpm -q mariadb-java-client postgresql-jdbc

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss-kie-db-drivers/configure.sh" ]

# end jboss-kie-db-drivers:1.0
# begin jboss.container.wildfly.launch.messaging:1.0

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.wildfly.launch.messaging/configure.sh" ]

# end jboss.container.wildfly.launch.messaging:1.0
# begin jboss.container.wildfly.launch.json-logging:1.0

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.wildfly.launch.json-logging/configure.sh" ]

# end jboss.container.wildfly.launch.json-logging:1.0
# begin jboss.container.wildfly.launch.mp-config:1.0

# Environment variables
ENV \
    MICROPROFILE_CONFIG_DIR_ORDINAL="500" 

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.wildfly.launch.mp-config/configure.sh" ]

# end jboss.container.wildfly.launch.mp-config:1.0
# begin jboss.container.wildfly.launch-config.os:1.0

# Environment variables
ENV \
    JBOSS_MODULES_SYSTEM_PKGS="org.jboss.logmanager,jdk.nashorn.api,com.sun.crypto.provider" 

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.wildfly.launch-config.os/configure.sh" ]

# end jboss.container.wildfly.launch-config.os:1.0
# begin jboss.container.wildfly.launch.jgroups:1.0

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.wildfly.launch.jgroups/configure.sh" ]

# end jboss.container.wildfly.launch.jgroups:1.0
# begin jboss.container.wildfly.launch.elytron:1.0

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.wildfly.launch.elytron/configure.sh" ]

# end jboss.container.wildfly.launch.elytron:1.0
# begin jboss.container.wildfly.launch.keycloak:1.0

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.wildfly.launch.keycloak/configure.sh" ]

# end jboss.container.wildfly.launch.keycloak:1.0
# begin jboss.container.wildfly.launch.tracing:1.0

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.wildfly.launch.tracing/configure.sh" ]

# end jboss.container.wildfly.launch.tracing:1.0
# begin os-eap70-sso:1.0

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

# end os-eap70-sso:1.0
# begin jboss.container.wildfly.launch.deployment-scanner:1.0

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.wildfly.launch.deployment-scanner/configure.sh" ]

# end jboss.container.wildfly.launch.deployment-scanner:1.0
# begin jboss.container.wildfly.launch.extensions:1.0

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.wildfly.launch.extensions/configure.sh" ]

# end jboss.container.wildfly.launch.extensions:1.0
# begin openshift-layer:1.0

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

# end openshift-layer:1.0
# begin openshift-passwd:1.0

# end openshift-passwd:1.0
# begin jboss.container.prometheus.api:1.0

# end jboss.container.prometheus.api:1.0
# begin jboss.container.prometheus.bash:1.0

# Environment variables
ENV \
    AB_PROMETHEUS_JMX_EXPORTER_CONFIG="/opt/jboss/container/prometheus/etc/jmx-exporter-config.yaml" \
    AB_PROMETHEUS_JMX_EXPORTER_PORT="9799" \
    JBOSS_CONTAINER_PROMETHEUS_MODULE="/opt/jboss/container/prometheus" 

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

# end jboss.container.prometheus.bash:1.0
# begin jboss.container.eap.prometheus.agent:1.0

# Custom scripts
USER 185
RUN [ "bash", "-x", "/tmp/scripts/jboss.container.eap.prometheus.agent/configure.sh" ]

# end jboss.container.eap.prometheus.agent:1.0
# begin jboss.container.eap.prometheus.config:7.2-kie

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

# end jboss.container.eap.prometheus.config:7.2-kie
# begin jboss-kie-jdk-clean:11

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

# end jboss-kie-jdk-clean:11
# begin os-eap-txnrecovery.bash:1.0

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

# end os-eap-txnrecovery.bash:1.0
# begin os-eap-txnrecovery.run:python3

# Custom scripts
USER root
RUN [ "bash", "-x", "/tmp/scripts/os-eap-txnrecovery.run/install_as_root.sh" ]

# end os-eap-txnrecovery.run:python3
# begin os-eap-python:3.6

# Install required RPMs and ensure that the packages were installed
USER root
RUN microdnf --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-wildfly-common:1.0

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

# end jboss-kie-wildfly-common:1.0
# begin jboss-kie-workbench:1.0

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

# end jboss-kie-workbench:1.0
# begin rhdm-7/rhdm-decisioncentral-rhel8:7.10.1

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

# Environment variables
ENV \
    CONFIG_ADJUSTMENT_MODE="xml" \
    HTTPS_ENABLE_HTTP2="true" \
    JBOSS_IMAGE_NAME="rhdm-7/rhdm-decisioncentral-rhel8" \
    JBOSS_IMAGE_VERSION="7.10.1" \
    LOGGER_CATEGORIES="org.infinispan.client.hotrod.impl.protocol.Codec21:ERROR, org.infinispan.protostream.impl.AnnotatedDescriptorImpl:ERROR" 

# Labels
LABEL \
      com.redhat.component="rhdm-7-decisioncentral-rhel8-container"  \
      description="Red Hat Decision Central 7.10 OpenShift container image"  \
      io.cekit.version="3.2.1"  \
      io.k8s.description="Platform for running Red Hat Decision Central"  \
      io.k8s.display-name="Red Hat Decision Central 7.10"  \
      io.openshift.expose-services="8080:http,8443:https"  \
      io.openshift.tags="javaee,eap,eap7,rhdm,rhdm7"  \
      name="rhdm-7/rhdm-decisioncentral-rhel8"  \
      summary="Red Hat Decision Central 7.10 OpenShift container image"  \
      version="7.10.1" 

# Exposed ports
EXPOSE 8080 8443 8778
# end rhdm-7/rhdm-decisioncentral-rhel8:7.10.1

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

# Clear package manager metadata
RUN microdnf 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/eap/bin/openshift-launch.sh"]
