# 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-indexing:7.0.1 image.

FROM jboss/openjdk18-rhel7:1.1

# Environment variables
ENV JBOSS_IMAGE_NAME="rhpam-7/rhpam70-businesscentral-indexing" \
    JBOSS_IMAGE_VERSION="7.0.1" \
    JBOSS_PRODUCT="rhpam-businesscentral-indexing" \
    RHPAM_BUSINESS_CENTRAL_INDEXING_VERSION="7.0.1" \
    PRODUCT_VERSION="7.0.1" \
    ELASTICSEARCH_HOME="/opt/elasticsearch" \
    ELASTICSEARCH_VERSION="5.6.5" \
    ELASTICSEARCH_DISTRIBUTION_ZIP="elasticsearch-5.6.5.zip" 

# Labels
LABEL name="$JBOSS_IMAGE_NAME" \
      version="$JBOSS_IMAGE_VERSION" \
      architecture="x86_64"  \
      com.redhat.component="rhpam-7-rhpam70-businesscentral-indexing-container" \
      org.jboss.product="rhpam-businesscentral-indexing" \
      org.jboss.product.version="7.0.1" \
      org.jboss.product.rhpam-businesscentral-indexing.version="7.0.1" \
      elasticsearch.version="5.6.5" \
      org.concrt.version="1.4.1" \
      description="Red Hat Business Central Indexing 7.0 Container Image" \
      summary="Red Hat Business Central Indexing 7.0 Container Image"


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 hostname \
    && yum clean all && \
    rpm -q  hostname
# 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 \
    elasticsearch-5.6.5.zip \
    /tmp/artifacts/

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

# Custom scripts
USER root
RUN [ "bash", "-x", "/tmp/scripts/businesscentral-indexing/install" ]

USER root
RUN rm -rf /tmp/scripts
USER root
RUN rm -rf /tmp/artifacts

USER 185



CMD ["/opt/elasticsearch/bin/elasticsearch"]
