· Jahia  · 5 min read

Jahia with Docker

Download and use Jahia Docker images and run them using Docker Compose

Download and use Jahia Docker images and run them using Docker Compose

Run Jahia CMS with Docker Compose

Use Docker to run your Jahia environment in a container

Sample Jahia environment

In this case we are running Jahia Docker latest Enterprise with an embedded Derby database (by default if not added)

Env file

.env
JAHIA_IMAGE=jahia/jahia-ee:latest
SUPER_USER_PASSWORD=${SUPER_USER_PASSWORD:-root1234}
CATALINA_OPTS="-Xms2g -Xmx2g"

Docker compose file

docker-compose.yaml
name: gladtek-jahia
services:
jahia:
image: '${JAHIA_IMAGE}'
container_name: jahia
hostname: jahia
deploy:
resources:
limits:
memory: 3gb
networks:
stack:
ports:
- "8080:8080"
- "8101:8101"
- "8000:8000"
environment:
DB_NAME: jahia
DB_USER: jahia
DB_PASS: jahia
SUPER_USER_PASSWORD: '${SUPER_USER_PASSWORD}'
PROCESSING_SERVER: 'true'
MAX_RAM_PERCENTAGE: 95
CATALINA_OPTS: '${CATALINA_OPTS}'
JPDA: 'true'
networks:
stack:
name: gladtek-jahia-network
driver: bridge

Run docker compose

Terminal window
docker compose up -d

Logs at the end of the run

[JahiaContextLoaderListener] - Context initialization phase finished
[EndInit] - --------------------------------------------------------------------------------------------------
[EndInit] - D E V E L O P M E N T M O D E A C T I V E
[EndInit] - In development mode, Jahia will allow JSPs to be modified, modules to be
[EndInit] - re-deployed and other modifications to happen immediately, but these DO have a performance impact.
[EndInit] - It is strongly recommended to switch to production mode when running performance tests or going live.
[EndInit] - The setting to change modes is called operatingMode in the jahia.properties configuration file.
[EndInit] - --------------------------------------------------------------------------------------------------
[EndInit] - Modules:
[EndInit] - Started: 49
INFO [EndInit] - --------------------------------------------------------------------------------------------------
INFO [EndInit] - Jahia 8.2.2.0 is now ready. Initialization completed in 61 seconds
[EndInit] - --------------------------------------------------------------------------------------------------

Adding a Maria Database

We want to run Jahia with a MariaDB instead of the default embedded derby

Env file

.env
JAHIA_IMAGE=jahia/jahia-ee:latest
MARIADB_IMAGE=library/mariadb:10-focal
SUPER_USER_PASSWORD=${SUPER_USER_PASSWORD:-root1234}
CATALINA_OPTS="-Xms2g -Xmx2g"

Docker compose file

docker-compose.yaml
name: gladtek-jahia
services:
mariadb:
image: '${MARIADB_IMAGE}'
hostname: mariadb
deploy:
resources:
limits:
memory: 1gb
networks:
- stack
command: --max_allowed_packet=1073741824 --transaction-isolation=READ-UNCOMMITTED --innodb-lock-wait-timeout=10
environment:
MYSQL_ROOT_PASSWORD: mariadbP@55
MYSQL_DATABASE: jahia
MYSQL_USER: jahia
MYSQL_PASSWORD: jahia
volumes:
- mariadb:/var/lib/mysql
jahia:
image: '${JAHIA_IMAGE}'
container_name: jahia
hostname: jahia
deploy:
resources:
limits:
memory: 3gb
networks:
stack:
depends_on:
- mariadb
ports:
- "8080:8080"
- "8101:8101"
- "8000:8000"
environment:
DB_VENDOR: mariadb
DB_HOST: mariadb
DB_NAME: jahia
DB_USER: jahia
DB_PASS: jahia
SUPER_USER_PASSWORD: '${SUPER_USER_PASSWORD}'
PROCESSING_SERVER: 'true'
MAX_RAM_PERCENTAGE: 95
CATALINA_OPTS: '${CATALINA_OPTS}'
JPDA: 'true'
volumes:
mariadb:
networks:
stack:
name: gladtek-jahia-network
driver: bridge

Run docker compose

Terminal window
docker compose up -d

Logs

INFO JahiaGlobalConfigurator - Loaded configuration: {operatingMode=development, storeFilesInDB=true, externalizedConfigTargetPath=/etc/jahia, storeFilesInAWS=false, targetServerDirectory=/usr/local/tomcat, jahiaRootPassword=***, cluster_activated=false, fileDataStorePath=, databaseType=mariadb, jahiaVarDiskPath=/var/jahia, databasePassword=***, databaseUsername=jahia, overwritedb=if-necessary, databaseUrl=jdbc:mariadb://mariadb:3306/jahia?useUnicode=true&characterEncoding=UTF-8&useServerPrepStmts=false&useSSL=false, processingServer=true, jahiaProperties={"mvnPath":"/opt/apache-maven-3.9.9/bin/mvn","svnPath":"/usr/bin/svn","gitPath":"/usr/bin/git","karaf.remoteShell.host":"0.0.0.0"}}
INFO JahiaGlobalConfigurator - Check and clean database for type: mariadb
INFO JahiaGlobalConfigurator - driver: org.mariadb.jdbc.Driver
INFO JahiaGlobalConfigurator - url: jdbc:mariadb://mariadb:3306/jahia?useUnicode=true&characterEncoding=UTF-8&useServerPrepStmts=false&useSSL=false

More Advanced Cases

For this we can be inspired by Jahia default examples from their github repositories Augmented Search What their case describe as mentioned in their ReadMe file :

  • Start an Elasticsearch single-node cluster
  • Install augmented-search
  • Configure the database connection via a groovy script
  • Configure augmented-search to use that connection
  • Enable augmented-search on digitall
  • Index Digitall

The following are a copy of Jahia tutorial files.

Jahia UseCase Docker Compose File

docker-compose.yaml
version: '3.6'
services:
mariadb:
image: library/mariadb:10-focal
deploy:
resources:
limits:
memory: 1gb
networks:
- stack
command: --max_allowed_packet=134217728 --transaction-isolation=READ-UNCOMMITTED --innodb-lock-wait-timeout=10
environment:
MYSQL_ROOT_PASSWORD: mariadbP@55
MYSQL_DATABASE: jahia
MYSQL_USER: jahia
MYSQL_PASSWORD: jahia
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.14
environment:
- discovery.type=single-node
deploy:
resources:
limits:
memory: 2gb
ports:
- 9200:9200
networks:
stack:
jahia:
image: jahia/jahia-ee:8.2
networks:
- stack
depends_on:
- mariadb
ports:
- 8080:8080
deploy:
resources:
limits:
memory: 4gb
environment:
DB_VENDOR: mariadb
DB_HOST: mariadb
DB_NAME: jahia
DB_USER: jahia
DB_PASS: jahia
OPERATING_MODE: development
PROCESSING_SERVER: 'true'
MAX_RAM_PERCENTAGE: 95
EXECUTE_PROVISIONING_SCRIPT: 'https://raw.githubusercontent.com/Jahia/provisioning-tutorials/main/03-augmented-search/provisioning.yaml'
networks:
stack:

Jahia UseCase Provisioning File

provisioning.yaml
# For more details about the provisioning API, you can refer to the Academy: https://academy.jahia.com/home
# You can also find some details here: https://github.com/Jahia/jahia-private/blob/master/bundles/provisioning/README.md
# Start with the provisioning script from Tutorial #2
- include: https://raw.githubusercontent.com/Jahia/provisioning-tutorials/main/02-digitall-mariadb/provisioning.yaml
# Augmented-Search dependencies are only available from Jahia store
# So we're adding a new repository to be able to resolve these dependencies
- addMavenRepository: 'https://devtools.jahia.com/nexus/content/repositories/jahia-public-app-store/@id=JahiaStore'
# Install and start bundles for Augmented Search
- installBundle:
- 'mvn:org.jahia.modules/augmented-search/3.6.0'
- 'mvn:org.jahia.modules/augmented-search-ui/3.0.5'
- 'mvn:org.jahia.modules/database-connector/1.6.0'
- 'mvn:org.jahia.modules/elasticsearch-connector/3.3.0'
autoStart: true
uninstallPreviousVersion: true
# Enable Augmented Search sample UI on Digitall
- enable: "augmented-search-ui"
site: "digitall"
# Configure database connector with a groovy script
- executeScript: "https://raw.githubusercontent.com/Jahia/provisioning-tutorials/main/03-augmented-search/db-connection.groovy"
# Configure Augmented Search and digitall
- executeScript: "https://raw.githubusercontent.com/Jahia/provisioning-tutorials/main/03-augmented-search/as-config.graphql"
# Add Augmented-Search UI module below the slider in Digitall home
- executeScript: "https://raw.githubusercontent.com/Jahia/provisioning-tutorials/main/03-augmented-search/add-search-ui.graphql"
# Publish Augmented-Search UI
- executeScript: "https://raw.githubusercontent.com/Jahia/provisioning-tutorials/main/03-augmented-search/publish-search-ui.graphql"
# Trigger a full indexation
- executeScript: "https://raw.githubusercontent.com/Jahia/provisioning-tutorials/main/03-augmented-search/as-index.graphql"

Jahia UseCase Graphql and Groovy Scripts

To configure the database connector

db-connection.groovy
import org.jahia.services.content.JCRCallback
import org.jahia.services.content.JCRSessionWrapper
import org.jahia.services.content.JCRTemplate
import org.jahia.services.modulemanager.util.ModuleUtils
import javax.jcr.RepositoryException
JCRCallback<Object> callback = new JCRCallback<Object>() {
@Override
Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
def node = session.getNode("/settings")
session.checkout(node);
if (!node.hasNode("databaseConnector")) {
def databaseConnectorNode = node.addNode("databaseConnector", "dc:databaseConnector")
if (!databaseConnectorNode.hasNode("augmented-search-conn")) {
def elasticsearchConnection = databaseConnectorNode.addNode("augmented-search-conn", "ec:elasticsearchConnection")
elasticsearchConnection.setProperty("dc:databaseType", "ELASTICSEARCH7")
elasticsearchConnection.setProperty("dc:host", "elasticsearch")
elasticsearchConnection.setProperty("dc:id", "augmented-search-conn")
elasticsearchConnection.setProperty("dc:isConnected", "true")
elasticsearchConnection.setProperty("dc:port", "9200")
session.save();
}
ModuleUtils.getModuleManager().stop("database-connector", null);
ModuleUtils.getModuleManager().start("database-connector", null);
return null
}
}
}
JCRTemplate.instance.doExecuteWithSystemSession(callback);

Configure Augmented Search and digitall

as-config.graphql
mutation {
admin {
search {
setDbConnection(connectionId: "augmented-search-conn")
addSite(siteKey: "digitall")
}
}
}

Add Augmented-Search UI module below the slider in Digitall home

add-search-ui.graphql
mutation {
jcr {
addNode(
parentPathOrId: "/sites/digitall/home/landing",
name: "augmented-search",
primaryNodeType: "sui:augmentedSearch") {
uuid
}
}
}

Publish Augmented-Search UI

publish-search-ui.graphql
mutation {
jcr(workspace: EDIT) {
mutateNode(pathOrId: "/sites/digitall/home/landing/augmented-search") {
publish(languages: "en")
}
}
}

Trigger a full indexation on digitall website

as-index.graphql
mutation {
admin {
search {
startIndex(siteKeys: ["digitall"]) {
jobs {
id
}
}
}
}
}

Want to collaborate with us ?

Interested in a demo or want to learn more? Reach out to us or request a personalized walkthrough with your own environment.


Made with ❤️ by the Gladtek Team.

Back to Blog

Related Posts

View All Posts »