Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Note

It is an open question whether Dockerizing / containerizing Magnolia is best practice.  Why?

1.  Magnolia is stateful - it's difficult to do k8s stateful set.

2. JCR clustering is difficult - You cannot easily run two Magnolia instances on the same DB.  JCR clustering uses a log - this log is used to spin up new instances and sync (index) them relatively quickly.  But the log grows fast; to clean it, you need to activate the janitor.  If you activate the janitor, you can't spin up new instances (unless using a snapshot taken from a synch'd cluster node after the last janitor run, or some other workaround) since part of the history will be missing (even with this mechanism, creating the new instance is not something obvious).

Because of those two things, we can't leverage advanced cloud features which are provided out-of the box by k8s or AWS such as auto-scalability or B/G deployment.  You may have to implement a lot of glue code to make it work, which removes some of the benefits of using such platforms.  With container-based orchestration, the situation is even worse, because you can reallocate dynamically the containers to different hosts.  This is the way failover is implemented and that the whole cluster scales.  Magnolia instances must be declared as "fixed" instances, which cannot be moved to a different host, again peeling away the advantages of having k8s (or other container-based orchestrator).

Dockerizing Magnolia is not considered best practice.  You have been warned (smile)

However, since using Docker together with Magnolia is clearly popular and growing in popularity, even if we do not advise Dockerizing Magnolia, we need to be able to provide a solution to those who must use it.  This section will go through some aspects of Dockerizing Magnolia.

...

Docker containers are basically lightweight type II virtual machines.  Another way to think of it: Docker containers are like apps that come bundled with all their dependencies.  That's really it.  You can drop a Docker container into any system running Docker, and it should just work.  For example, you can run a Docker container on an EC2 instance, as long as that instance has Docker installed.  In fact, you can run N Docker containers on any 1 or N EC2 instances.  The key question here is: Why would I want to do something like this? Well, let's assume some business rules force you to use Docker.  Or, our customers ask for k8s because they have invested in this technology to leverage these otb features and to have a consistent way of managing "services".

Next - Why (Not) Docker?

Advantages

...

Expand
Code Block
languagebash
[bandersen@li1397-60 docker]$ date ; sudo docker build -t magnolia-3 . ; date
Wed Apr 18 13:11:38 UTC 2018
Sending build context to Docker daemon 6.656 kB
Step 1/17 : FROM centos:latest
 ---> e934aafc2206
Step 2/17 : RUN yum -y update && yum -y install java wget && yum clean all
 ---> Using cache
 ---> 55a4fca18ee5
Step 3/17 : RUN mkdir -p /tomcat
 ---> Using cache
 ---> 8039f2f879a6
Step 4/17 : ENV CATALINA_HOME /tomcat
 ---> Using cache
 ---> 602cf9f15dd4
Step 5/17 : ENV PATH $CATALINA_HOME/bin:$PATH
 ---> Using cache
 ---> 77b836791f22
Step 6/17 : WORKDIR $CATALINA_HOME
 ---> Using cache
 ---> 6fdccd490e0b
Step 7/17 : ADD get_tomcat.sh $CATALINA_HOME
 ---> Using cache
 ---> a905e06737ef
Step 8/17 : RUN chmod +x $CATALINA_HOME/get_tomcat.sh
 ---> Using cache
 ---> f408c365b67a
Step 9/17 : RUN $CATALINA_HOME/get_tomcat.sh
 ---> Using cache
 ---> 78e123db89b8
Step 10/17 : RUN mv $CATALINA_HOME/apache-tomcat-8.5.30/* $CATALINA_HOME/
 ---> Using cache
 ---> b6598823e271
Step 11/17 : RUN rm -rf $CATALINA_HOME/apache-tomcat-8.5.30
 ---> Using cache
 ---> c466f5c0cc60
Step 12/17 : WORKDIR $CATALINA_HOME/webapps
 ---> Using cache
 ---> 5e4e1cda55b8
Step 13/17 : ADD get_latest_magnolia.sh $CATALINA_HOME/webapps
 ---> Using cache
 ---> b9e91f2ba419
Step 14/17 : RUN chmod +x $CATALINA_HOME/webapps/get_latest_magnolia.sh
 ---> Using cache
 ---> b3d6f0e074f6
Step 15/17 : RUN $CATALINA_HOME/webapps/get_latest_magnolia.sh
 ---> Using cache
 ---> 183406bb49e2
Step 16/17 : EXPOSE 8080
 ---> Using cache
 ---> e1e6b0e76442
Step 17/17 : CMD catalina.sh run
 ---> Using cache
 ---> bdd17317d6ff
Successfully built bdd17317d6ff
Wed Apr 18 13:11:38 UTC 2018
[bandersen@li1397-60 docker]$

See how it is "using cache" for all those steps? This took no time at all to run (literally less than one second).

https://blogsblog.magnolia-cms.com/nicolas-barbe/detail~&magnolia-devops-series--part-1--a-docker-image-for-magnolia~.html
https://blogsblog.magnolia-cms.com/nicolas-barbe/detail~&magnolia-devops-series--part-2--orchestration-with-docker-compose~.html
https://blogsblog.magnolia-cms.com/nicolas-barbe/detail~&magnolia-devops-series--part-3--automate-your-deployment-on-multiple-hosts~.html
https://blogsblog.magnolia-cms.com/jan-haderka/detail~&docker--amazon-ec2-and-continuous-builds-using-jenkins~.html

...