
# 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-process-migration-rhel8:7.9.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.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 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 rhpam-7-process-migration:1.0

# Environment variables
ENV \
    ADD_ONS_DISTRIBUTION_ZIP="rhpam_add_ons_distribution.zip" \
    CONFIG_DIR="/opt/rhpam-process-migration/config" \
    JBOSS_HOME="/opt/rhpam-process-migration" \
    JBOSS_PRODUCT="rhpam-process-migration" \
    KIE_PROCESS_MIGRATION_DISTRIBUTION_JAR="rhpam-7.9.1-process-migration-service-standalone.jar" \
    LAUNCH_DIR="/opt/rhpam-process-migration/launch" \
    PRODUCT_VERSION="7.9.1" \
    RHPAM_PROCESS_MIGRATION_VERSION="7.9.1" 

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

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

# end rhpam-7-process-migration: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-kie-process-migration:1.0

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

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

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

# 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 \
    JBOSS_IMAGE_NAME="rhpam-7/rhpam-process-migration-rhel8" \
    JBOSS_IMAGE_VERSION="7.9.1" 

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

# Exposed ports
EXPOSE 8080
# end rhpam-7/rhpam-process-migration-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 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/rhpam-process-migration/openshift-launch.sh"]
