Skip to content

Commit

Permalink
Merge pull request #1 from smclab/feature/add-support-to-liferay-74-a…
Browse files Browse the repository at this point in the history
…nd-jboss-eap-74

Feature/Added support to Liferay 74 and JBoss EAP 7.4
  • Loading branch information
amusarra authored May 26, 2022
2 parents f8c4b7c + 9eb38fd commit 9f61c0b
Show file tree
Hide file tree
Showing 4 changed files with 709 additions and 24 deletions.
67 changes: 56 additions & 11 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ adds the ability to build Liferay local Docker images based on JBoss EAP.
For more info about this project, you can read this article
[How to create Docker images Liferay DXP + Red Hat JBoss EAP](https://techblog.smc.it/en/2020-10-21/come-creare-immagini-docker-liferay-dxp-jboss-eap)

For more information about Liferay Docker images I recommend reading the
documentation [Starting with a Docker Image](https://learn.liferay.com/dxp/latest/en/getting-started/starting-with-a-docker-image.html)

## 1. Requirements
So that you can successfully complete the image creation Docker, a number of
software requirements must be met for the machine dedicated to the build operation.
Expand Down Expand Up @@ -67,7 +70,7 @@ the Docker repository.

### 2.1 How to build a Liferay local Docker image based on JBoss EAP
Before running the build image command, the following requirements must be met.
The image creation process refers to the documentation [Installing on JBoss EAP](https://learn.liferay.com/dxp/7.x/en/installation-and-upgrades/installing-liferay/installing-liferay-on-an-application-server/installing-on-jboss-eap.html).
The image creation process refers to the documentation [Installing on JBoss EAP](https://learn.liferay.com/dxp/latest/en/installation-and-upgrades/installing-liferay/installing-liferay-on-an-application-server/installing-on-jboss-eap.html).

Installing on JBoss EAP requires deploying dependencies, modifying scripts,
modifying config xml files, and deploying the DXP WAR file.
Expand All @@ -83,6 +86,9 @@ Liferay Community Downloads and RedHat Customer Portal
3. OSGi Dependencies ZIP file
4. JBoss EAP ZIP file

**Attention!** As of Liferay version 7.4, the *Dependencies ZIP file* is no longer
needed and is therefore no longer available for download.

Note that Liferay Home is the folder containing the JBoss server folder.
After installing and deploying DXP, the Liferay Home folder contains the
JBoss server folder as well as data, deploy, logs, and osgi folders.
Expand All @@ -99,35 +105,73 @@ liferay-dxp-osgi-7.2.10.3-sp3-202009100727.zip
liferay-dxp-7.2.10.3-sp3-202009100727.war
```

In the case of the build of the base image of Liferay 7.4 DXP Update 25 with
JBoss EAP 7.4 (with patch number 4), the necessary files are those indicated
below.

In this software release, you can create the image with JBoss EAP 7.4 only
with Liferay 7.4. In case you want to install Liferay 7.3 with JBoss EAP 7.4,
you need to add the modules directory structure to the JBoss EAP 7.4 template
configuration.

```bash
jboss-eap-7.4.0.zip
jboss-eap-7.4.4-patch.zip
liferay-dxp-7.4.13.u25-20220517155936227.war
liferay-dxp-osgi-7.4.13.u25-20220517155936227.zip
```

It is not necessary that the downloaded files are necessarily present in the
project, the path must be indicated as an argument of the build command.
**It is important not to rename the file names.**

At this point you can proceed with the build of the image using the command below.
In this case the downloaded bundles are inside the xxx directory and the resulting
image will have the name `amusarra:liferay72-dxp-dev`.
In this case the downloaded bundles are inside the `../../bundles/` directory
and the resulting image will have the name `amusarra:liferay72-dxp-dev`.

The image will not be published on the Docker repository (`no-push` param).

The `jboss-eap` parameter indicates to create the Liferay Docker image with JBoss EAP.

```bash
./build_local_image.sh ../../bundles/ amusarra liferay72-dxp-dev no-push jboss-eap
```

The basic JBoss EAP configuration is governed by configuration files located
within the following directory.
within the following directory. For each version of JBoss there is a dedicated directory.

```bash
template
└── jboss-eap
   └── 7.2.0
   ├── 7.2.0
   │   ├── bin
   │   │   └── standalone.conf
   │   ├── modules
   │   │   └── com
   │   │   └── liferay
   │   │   └── portal
   │   │   └── main
   │   │   ├── module.xml
   │   │   └── ojdbc8.jar
   │   └── standalone
   │   └── configuration
   │   └── standalone.xml
   ├── 7.3.0
   │   ├── bin
   │   │   └── standalone.conf
   │   ├── modules
   │   │   └── com
   │   │   └── liferay
   │   │   └── portal
   │   │   └── main
   │   │   ├── module.xml
   │   │   └── ojdbc8.jar
   │   └── standalone
   │   └── configuration
   │   └── standalone.xml
   └── 7.4.0
   ├── bin
   │   └── standalone.conf
   ├── modules
   │   └── com
   │   └── liferay
   │   └── portal
   │   └── main
   │   └── module.xml
   └── standalone
   └── configuration
   └── standalone.xml
Expand All @@ -144,6 +188,7 @@ The `docker images` command displays the newly created image.
REPOSITORY TAG IMAGE ID CREATED SIZE
amusarra liferay72-dxp-dev dc47e5d30128 6 hours ago 1.89GB
amusarra liferay72-dxp-dev-202009291154 dc47e5d30128 6 hours ago 1.89GB
amusarra liferay74-dxp-jboss-eap-74 32b2f5fac0f6 54 minutes ago 1.7GB
```

To launch the new image, just run the following command. As indicated in the
Expand Down
28 changes: 15 additions & 13 deletions _common.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

function check_liferay_additional_files() {
local found_additional_files=()
local found_additional_files=("-" "-" "-")

local regex_osgi_dependencies='liferay-(dxp|ce)-(dependencies|osgi)-(([0-9]+\.)?([0-9]+\.)?(\*|[0-9]+)).+'
local regex_war='liferay-(dxp|ce)-(([0-9]+\.)?([0-9]+\.)?(\*|[0-9]+)).+'
Expand All @@ -10,17 +10,17 @@ function check_liferay_additional_files() {
if [[ $additional_file =~ $regex_osgi_dependencies ]]; then

if [[ ${BASH_REMATCH[2]} == "osgi" ]]; then
found_additional_files+=("${additional_file}")
found_additional_files[2]="${additional_file}"
fi

if [[ ${BASH_REMATCH[2]} == "dependencies" ]]; then
found_additional_files+=("${additional_file}")
found_additional_files[1]="${additional_file}"
fi
fi

if [[ $additional_file =~ $regex_war ]]; then
if [[ ${additional_file} == *.war ]]; then
found_additional_files+=("${additional_file}")
found_additional_files[0]="${additional_file}"
fi
fi
done
Expand Down Expand Up @@ -378,8 +378,10 @@ function prepare_jboss_eap() {
local jboss_version=$(get_jboss_version "${TEMP_DIR}/bundles")

# Copy Liferay Module Configuration from template
cp ${TEMP_DIR}/jboss-eap/${jboss_version}/modules/com/liferay/portal/main/* \
${TEMP_DIR}/liferay/jboss-eap/modules/com/liferay/portal/main/
if [[ -d "${TEMP_DIR}/jboss-eap/${jboss_version}/modules/com/liferay/portal/main" ]]; then
cp ${TEMP_DIR}/jboss-eap/${jboss_version}/modules/com/liferay/portal/main/* \
${TEMP_DIR}/liferay/jboss-eap/modules/com/liferay/portal/main/
fi

# Copy JBoss EAP Standalone xml configuration for Liferay
cp ${TEMP_DIR}/jboss-eap/${jboss_version}/standalone/configuration/* \
Expand Down Expand Up @@ -419,11 +421,6 @@ function prepare_temp_for_manual_installation() {
additional_files=$(check_liferay_additional_files "${TEMP_DIR}/bundles")
additional_files_array=($additional_files)

if [[ ${#additional_files_array[@]} -lt 3 ]]; then
echo "Check if all additional files is present in ${TEMP_DIR}/bundles"
exit 2
fi

local liferay_war_archive=$(get_abs_filename "${additional_files_array[0]}")
local liferay_dependencies_archive=$(get_abs_filename "${additional_files_array[1]}")
local liferay_osgi_archive=$(get_abs_filename "${additional_files_array[2]}")
Expand All @@ -438,7 +435,12 @@ function prepare_temp_for_manual_installation() {
cd "${temp_dir_abs}/liferay/jboss-eap" || exit 3
tar -xvf "${as_archive_file_abs}" --strip 1

if [[ $? -eq 0 ]]; then
echo "-- Liferay additional files --"
echo "Liferay WAR archive: ${additional_files_array[0]} version: ${liferay_war_archive_version}"
echo "Liferay OSGi Dependencies: ${additional_files_array[2]} version: ${liferay_osgi_archive_version}"
echo "Liferay Dependencies: ${additional_files_array[3]} version: ${liferay_dependencies_archive_version}"

if [[ $? -eq 0 && -n "${liferay_dependencies_archive_version}" ]]; then
mkdir -p "${temp_dir_abs}/liferay/jboss-eap/modules/com/liferay/portal/main"
cd "${temp_dir_abs}/liferay/jboss-eap/modules/com/liferay/portal/main" || exit 3
tar -xvf $(get_abs_filename "${liferay_dependencies_archive}") --strip 1
Expand All @@ -457,7 +459,7 @@ function prepare_temp_for_manual_installation() {

# Version check required because the directory structure inside the zip is
# different for liferay osgi archive
if [ "${liferay_osgi_archive_version}" == "7.3.10" ]; then
if [[ "${liferay_osgi_archive_version}" == "7.3.10" || "${liferay_osgi_archive_version}" == "7.4.13" ]]; then
tar -xvf $(get_abs_filename "${liferay_osgi_archive}") --strip 1
else
tar -xvf $(get_abs_filename "${liferay_osgi_archive}") --strip 2
Expand Down
94 changes: 94 additions & 0 deletions template/jboss-eap/7.4.0/bin/standalone.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
## -*- shell-script -*- ######################################################
## ##
## JBoss EAP Bootstrap Script Configuration ##
## ##
##############################################################################

#
# This file is optional; it may be removed if not needed.
#

#
# Specify the maximum file descriptor limit, use "max" or "maximum" to use
# the default, as queried by the system.
#
# Defaults to "maximum"
#
#MAX_FD="maximum"

#
# Specify the profiler configuration file to load.
#
# Default is to not load profiler configuration file.
#
#PROFILER=""

#
# Specify the location of the Java home directory. If set then $JAVA will
# be defined to $JAVA_HOME/bin/java, else $JAVA will be "java".
#
#JAVA_HOME="/opt/java/jdk"

# tell linux glibc how many memory pools can be created that are used by malloc
# MALLOC_ARENA_MAX="5"

#
# Specify the exact Java VM executable to use.
#
#JAVA=""

if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then
JAVA_OPTS="-Djava.net.preferIPv4Stack=true"
JBOSS_MODULES_SYSTEM_PKGS="org.jboss.byteman"
fi

# Uncomment the following line to prevent manipulation of JVM options
# by shell scripts.
#
#PRESERVE_JAVA_OPTS=true

#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Djava.net.preferIPv4Stack=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
else
echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi

# Sample JPDA settings for remote socket debugging
#JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"

# Sample JPDA settings for shared memory debugging
#JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_shmem,server=y,suspend=n,address=jboss"

# Uncomment to not use JBoss Modules lockless mode
#JAVA_OPTS="$JAVA_OPTS -Djboss.modules.lockless=false"

# Uncomment to gather JBoss Modules metrics
#JAVA_OPTS="$JAVA_OPTS -Djboss.modules.metrics=true"

# Uncomment this to run with a security manager enabled
# SECMGR="true"

# Uncomment to add a Java agent. If an agent is added to the module options, then jboss-modules.jar is added as an agent
# on the JVM. This allows things like the log manager or security manager to be configured before the agent is invoked.
# MODULE_OPTS="-javaagent:agent.jar"

# Uncomment this in order to be able to run WildFly on FreeBSD
# when you get "epoll_create function not implemented" message in dmesg output
#JAVA_OPTS="$JAVA_OPTS -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider"

# enable garbage collection logging if not set in environment differently
if [ "x$GC_LOG" = "x" ]; then
GC_LOG="true"
else
echo "GC_LOG set in environment to $GC_LOG"
fi

# On JDK 11, add this JVM argument to display four-digit years.
# See https://learn.liferay.com/dxp/7.x/en/installation-and-upgrades/installing-liferay/installing-liferay-on-an-application-server/installing-on-jboss-eap.html
# -Djava.locale.providers=JRE,COMPAT,CLDR

JAVA_OPTS="$JAVA_OPTS $LIFERAY_JVM_OPTS -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Dlog4j2.formatMsgNoLookups=true -Duser.timezone=GMT -Xms2560m -Xmx2560m -XX:MaxNewSize=1536m -XX:MaxMetaspaceSize=768m -XX:MetaspaceSize=768m -XX:NewSize=1536m -XX:SurvivorRatio=7 -Djboss.as.management.blocking.timeout=480"
Loading

0 comments on commit 9f61c0b

Please sign in to comment.