Ever since getting the M1 Macbook Pro, I’ve been impressed with the speed, hours upon hours of battery life, and the fact that it runs cool no matter what you throw at it. But the ARM architecture has made software compatibility challenging.

Now that there are ARMv8 native versions of MySQL and JAVA, there have been no issues running Liferay locally. But since many developers are running Liferay in a docker container, is the ARM ecosystem up to the challenge, while making sure our container stays compatible with traditional x64 machines? Let’s find out!

Install Docker

First, let’s install Docker. The installer for Apple Silicon is available at https://docs.docker.com/desktop/mac/apple-silicon/.

Once it’s installed, run the desktop application. You can find it pretty easily with Spotlight (Cmd + Space).

Creating a Liferay Docker Container on Apple Silicon Docker Installer

Blade CLI

Next, let’s install the Blade CLI. Most developers prefer a terminal over a GUI installer when we can help it, so let’s take that approach.

First, download and install the tool. Copy and paste this into a Terminal.

curl -L https://raw.githubusercontent.com/liferay/liferay-blade-cli/master/cli/installers/local | sh

MacOS now uses zshell instead of bash, so the bashrc script from Liferay’s knowledgebase won’t work. Add this path to ~/.zshrc using your favorite text editor:

export PATH="$PATH:$HOME/Library/PackageManager/bin"

Finally, we have to reload zsh so our terminal recognizes the path that we just added.

source ~/.zshrc

Creating Your Workspace

Now that blade is configured, you can see a list of available Liferay versions by typing the following into your terminal:

blade init -l

You’ll see a list of Liferay versions like the one below.

dxp-7.4-u20

dxp-7.3-sp3

dxp-7.2-sp6

dxp-7.1-sp7

dxp-7.0-sp17

portal-7.4-ga20

portal-7.3-ga8

portal-7.2-ga2

portal-7.1-ga4

portal-7.0-ga7

commerce-2.0.7-7.2

commerce-2.0.7-7.1

My particular project calls for 7.3, so I’m going to go with that one.

blade init -v dxp-7.3-sp3 m1test

You’ll now see a folder called m1test. Let’s navigate to it and check out the contents.

Creating a Liferay Docker Container on Apple Silicon m1test

Pull the Docker Image

You can find the image that corresponds to your version here:

DXP: https://hub.docker.com/r/liferay/dxp/tags

Portal: https://hub.docker.com/r/liferay/portal/tags

Creating a Liferay Docker Container on Apple Silicon Pull Image

Just click the copy button that they conveniently provided and paste it into the terminal.

Docker It Up!

Now we have our workspace set up and our docker image downloaded, so we’re ready to docker it up! Make sure you’re in your project folder, type ./gradlew createDockerContainer, and watch the magic happen!

Creating a Liferay Docker Container on Apple Silicon Create Docker Container

Permission Denied?

Sometimes you’ll get the following error: zsh: permission denied: ./gradlew

You’ll need to add the x permission to gradlew by typing chmod +x gradlew

Now you’ll see the Docker Image.

Creating a Liferay Docker Container on Apple Silicon Docker Image

Important: Increase Docker Memory

Important: If you don’t increase the allocated memory the container will exit on you with an esoteric message. 6GB is a safe value.

Creating a Liferay Docker Container on Apple Silicon Docker Memory

Start Your Container

Go to your browser and type localhost:8080. The default username/password is [email protected]/test

Creating a Liferay Docker Container on Apple Silicon Start Container

Adding a Theme

A huge advantage to basing our container on a Liferay Workspace is that we can add whatever portlets we want with blade, then use a single gradle command to deploy them all to our container. In this example we’re going to create a theme with the following command:

blade create -t js-theme [project-name]

Now we just run ./gradlew build in our root project folder to build, or ./gradlew deploy to build and deploy it into our docker workspace.

Oh No! The Build Failed.

If you’re using older versions up to 7.3, Liferay’s generated theme needs an adjustment.

Creating a Liferay Docker Container on Apple Silicon Fix Build

To fix it, copy build/_css/compat/components/_dropdowns.scss to src/css/compat/components/. Change line 34 to @extend .dropdown-item, .disabled;

Now your theme will build and deploy successfully!

Summary

We’ve now finished implementing a Liferay workspace Docker container on an Apple Silicon Mac. The best part is that we didn’t have to use any ARMv8 specific libraries, so our workspace can be deployed across Intel Mac, Windows, and Linux workstations as well!

If you’re a Liferay dev running a machine with Apple Silicon, we’d love to hear about your experience in the comments. And as always, our Liferay experts are ready to build! Contact us here to talk about what we can do for your organization!

Share This