Skip to content

Sample docker-compose configurations for re-creating different environments

Notifications You must be signed in to change notification settings

EddEcho/liferay-workspace-docker-environments

 
 

Repository files navigation

liferay-workspace-docker-environments

A collection of docker-compose configurations for re-creating different Liferay environments

Quick start

This Liferay Workspace is set up so you can immediately spin up an environment with Liferay, a database, and Elasticsearch set up. Different features and services can be included or omitted as needed.

To start up the environment, run ./gradlew composeUp.

To shut down the environment, run ./gradlew composeDown.

Features

Liferay features overview

Database features overview

Elasticsearch features overview

Data features overview

Docker features overview

Gradle tasks overview

Requirements

  • You must have docker and docker compose installed

Manual

Liferay Features

Set the Liferay Docker image version

Set the liferay.workspace.docker.image.liferay property in gradle.properties.

This will override the Docker image version that is determined from the liferay.workspace.product property (see Set the the Liferay version for building modules).

gradle.properties:

liferay.workspace.docker.image.liferay=liferay/dxp:7.2.10-sp8

Deploy OSGi configs

Place OSGi .config files in the ./configs/common/configs directory. They will be included in the built Liferay image.

OSGi config files:

./configs/common/configs/SomeConfigFile.config

Deploy portal-ext.properties

Place *.properties files in the ./configs/common directory. They will be included in the built Liferay image.

Properties files:

./configs/common/portal-ext.properties

Deploy hotfixes

Add hotfix URLs to the lr.docker.environment.hotfix.urls property in gradle.properties as a comma-separated string. Each URL listed will be downloaded and placed into the ./configs/common/patching directory, which will be included in the built Liferay image.

gradle.properties:

lr.docker.environment.hotfix.urls=\
    https://releases-cdn.liferay.com/dxp/hotfix/2024.q2.7/liferay-dxp-2024.q2.7-hotfix-4.zip,\
    https://releases-cdn.liferay.com/dxp/hotfix/2024.q2.7/liferay-dxp-2024.q2.7-hotfix-5.zip

Note: Local file URLs are also supported using the file:// protocol.

Deploy custom modules and projects

Liferay Workspace will automatically build and deploy custom modules and projects contained in the Workspace to the built Liferay Docker image. More documentation on creating and building projects can be found at Liferay Learn.

Set the the Liferay version for building modules

Deploy a Document Library

Document library files can be added to Liferay in one of two ways:

  1. Add the document library folder to ./configs/common/data/document_library

  2. Include the document library as part of the data directory defined by the lr.docker.environment.data.directory property. See Data Features for more details on how to create and use data directories.

Document library files for method #1:

./configs/common/data/document_library

Deploy license files

Add a license files to ./configs/common/deploy.

Enable clustering

Clustering can be enabled by setting the lr.docker.environment.cluster.nodes property in gradle.properties. Setting it to 0 means no clustering is enabled. Setting it to 1 or more will add that many cluster nodes in addition to the main Liferay instance.

gradle.properties:

# This will start the main Liferay instance and 2 additional cluster nodes
lr.docker.environment.cluster.nodes=2

Database Features

Enable MySQL 5.7

Set the lr.docker.environment.service.enabled[mysql] property to true or 1 in gradle.properties.

gradle.properties:

lr.docker.environment.service.enabled[mysql]=true

Import a database dump

Database dump files can be added to the ./dumps directory at the root of the Workspace. It will automatically be copied into the MySQL container.

./dumps/dumpfile.sql

Elasticsearch Features

Enable standalone Elasticsearch

Set the lr.docker.environment.service.enabled[elasticsearch] property to true or 1 in gradle.properties.

gradle.properties:

lr.docker.environment.service.enabled[elasticsearch]=true

Data Features

Export container data to a timestamped directory

./gradlew exportContainerData

This will export data from each of the running containers to a timestamped directory inside of ./exported_data. This directory can then be directly referenced by the lr.docker.environment.data.directory property to re-use that data on future startups.

Note: This repo intentionally does not bind-mount container directories to host directories as it can easily cause startup issues due to user permission mismatches. It is a known issue with Docker Compose.

Import data for various containers

Set the lr.docker.environment.data.directory property in gradle.properties to a relative or absolute path to a directory. This directory structure illustrates where each service directory is mapped in the respective container:

data_folder          (directory in their repsective container)
├── elasticsearch -> /usr/share/elasticsearch/data/
├── liferay       -> /opt/liferay/data
└── mysql         -> /var/lib/mysql

gradle.properties:

lr.docker.environment.data.directory=exported_data/data_20241206.175343

Gradle tasks

Start up environment

./gradlew composeUp

Shut down environment

./gradlew composeDown

Export container data

./gradlew exportContainerData

Clean up prepared hotfixes

./gradlew cleanPrepareHotfixes

Clean up all prepared data and built Liferay Docker images

./gradlew clean

About

Sample docker-compose configurations for re-creating different environments

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dockerfile 61.3%
  • Shell 38.7%