Blogs

Blogs

liferayctl - download and run Liferay locally from Docker images.

Looking at Liferay 7 Milestone 7 download stats, it seams many have tried it already. Yet considering the size of the community, the numbers are not that impressive. I'm pretty sure it's not because it's too hard or too time consuming to do it. However if that was your excuse, you may need to think of another one because trying out Liferay just got easier. How much easier? As easy as typing ./liferayctl start in your command prompt!

liferayctl

If you are Linux or OS X user, please allow me to introduce to you liferayctl - a command line tool to download and run a Liferay version from a Docker container.

Obviously you need to have Docker installed before you can use it (if you still don't, I really admire your resistance to IT trends)!

Let me give you some examples:

Before we start, let's get the tool and make it executable

curl -LO http://tiny.cc/liferayctl && chmod +x liferayctl

Now lets run Liferay 7 Milestone 7 (attention OS X users, make sure you are in a boot2docker terminal window)

./liferayctl -v 7.0m7 start

Be patient - it needs to download the image the first time you start it. This may take few minutes. Once it starts go to http://localhost:8080 and enjoy it ;)

Now let's say you want to compare it to the latest stable release (6.2ga4 at the time of writing), side by side in your browser. Type

./liferayctl -p 8180 -a 8109 start

and point you browser to http://localhost:8180. Feel free to add and modify whatever you want. Once you are done playing with it, simply run

./liferayctl -v 7.0m7 stop
./liferayctl stop

to stop both instances. You can start it again later on by repeating the steps above.

As you see, you don't have to be a Docker expert to use liferayctl. However it helps to get to know how it works!

Liferay Docker images

Now that you know liferayctl starts Liferay from a Docker container, you may wander which images it uses. If you search for Liferay in Docker Hub you'll find quite some images. Those vary widely in size, configuration and what Liferay version they target.

As much as I hate to reinvent the wheel, I had to create own images to satisfy the following requirements:

  • have minimal size images (based on Apline Linux image)
  • have minimal layers (single layer above Alpine providing all the data and several layers with meta data only)
  • make sure images do not depend nor contain anything but Java and Liferay Tomcat bundle
  • image structure is the same for each Liferay version (here is how they are generated)
  • hove control over stable and latest tags and make sure they point to the latest stable release and latest milestone release respectively

The images are uploaded in azzazzel/liferay-standalone Docker Hub repository. Sticking to those allows liferayctl to make some assumptions and provide very simple command line interface. However those are regular docker images and can be used directly with Docker. For example there is nothing that prevents you from running

docker run -ti --rm azzazzel/liferay-standalone:7.0m7

Be aware though that liferayctl makes some assumptions about container names and if you start liferay-standalone container directly from docker, it may interfere with the containers created by liferayctl!

Disclaimer and feedback request

I hope you'll enjoy liferayctl and the images and find them useful. Please keep in mind they are NOT meant to be used in production!

Please also keep in mind liferayctl as well as the docker images are NOT Liferay official artifacts and thus are NOT officially supported by Liferay. All images are build upon Liferay Community Edition versions.

As of now, there are only 3 images uploaded

  • 6.2ga4 (also tagged as stable)
  • 7.0m6
  • 7.0m7 (also tagged as latest)

I can release other versions on request. There are currently no plans to release Liferay Enterprise Edition images as far as I know! In the future Liferay may or may not decide to release official and supported tool and images. Meanwhile I will do my best to support those tools (I have plans for some more, such as allowing to use different database, automated creation of dev environment, ....) and images as long as there is interest!

So please, please send feedback, pull requests and report issues at liferay-docker-images project page on GitHub. Of course you can also drop me an e-mail or comment here, but this may take longer for me to notice and react.

Last but not least, you can meet me and discuss those and other subjects face to face at Liferay DEVCONLiferay Portal Solutions Forum - UK and Liferay Symposium North America.

Neat. Installing Tomcat Demos is easy already, but this is another order of magnitude. Sounds like well digestible magic ingredients.
My issue has not been getting LR7 up and running, that has been pretty standard if you heed the instructions.

But without the build chain in place, I can't do much with it. I have a SB portlet which I just can't build for 7 because SB is broken. There's discussion about having to have a particular version of maven (or other) artifacts but I haven't yet been able to complete a single build targeting LR7.

I'm guessing I'm not alone in this challenge.

As soon as I can successfully build artifacts targeting LR7, I'll be able to work on converting my plugins and see how they fit in the new environment. Until then all I can really do is look at the brochure site and see how it looks.

I'm sure the toolchain will stabilize soon, and I'm just chomping at the bit waiting to get to work...
You are unfortunately right. Neither `liferayctl` nor the docker images make Liferay 7 more ready then it actually is ;)
Very nice tool Milen!!

It could be great adding the ability to fetch a specific commit instead of a released version. How difficult could it be implement it?
IMHO it makes no sense to use Docker for this kind of thing. I agree that such script / command line tool may come handy. Basically it would need to grab the source code from GitHub, try compile it, deal with all the potential errors, make sure the target artifacts are created properly. At that point it could create a Docker container and put the result in, but honestly speaking I don't see why would one want to do that. Releasing images on Docker Hub that contain Liferay portal built from a particular commit would hardly be useful to anyone but the author IMHO.
What about a continuous-release process? Imagine having that tool to generate dockerfiles for engineers to tests/release an specific commit of Liferay?
So you can actually try it out using the docker image build process from https://github.com/milendyankov/liferay-docker-images/tree/master/liferay-standalone
You need to:
- build Liferay from git tag, commit, ...
- zip it and put it `liferay-releases` dir
- provide `env` file
- run `build.sh`
If that is what you are looking for, the steps above can be automated. Images can be put into separate docker repo (for example `liferay-snapshots`) and `liferayctl` can be made to work with those too. It's not too hard to do, just I'm still not sure it's worth the effort.
Very nice, tried it on the weekend, works like a charm.

Feature request: Add a deploy option. It is very painful to cp files from the host to the container since only Docker 1.8 (released in August 2015) added a non-painful feature to do that.

Also: EE images would be swell. Since one needs a trial key anyway, it shouldn't be a problem (or is it?) and it would be great for testing purposes.
Any chance you could make it expose the tomcat-folder as well?
We have automated complex Liferay deployments for our customers using Docker and Nirmata. Doing so has given our enterprise customers tremendous productivity boost as the developers dont have to wait for VMs to be setup to develop and test their features. Nirmata provides complete self service provisioning of application containers on any cloud - public or private. Here is a blog describing this:

http://nirmata.com/2016/04/flexible-deployment-of-liferay-using-docker-and-nirmata-container-services/

Disclaimer: I am a founder or Nirmata
Thank you for your guide, you have mentioned that the application server used is Tomcat, how can we bundle dockerize Liferay with JBoss?

Thank you

Best regards