Sitecore JSS in containers

Find out how to setup an XP0 installation supporting Sitecore JSS on the cm/cd role. Basic knowledge of Sitecore JSS as described on https://jss.sitecore.com/ is required.

To add JSS Server Components to your Sitecore server, 2 asset images are made available by Sitecore:

  • sxp/modules/jss-xm1-assets (to be used for xm topologies)
  • sxp/modules/jss-xp1-assets (to be used for xp topologies)

For our XP0 workerstation setup, we will use the jss-xp1-assets image.

Customize CM image

First let’s create a custom cm image. In docker-compose.override.xml we need to add a custom build.

We pass along, the base xp0 image, the tooling image and the jss-assets image. (You might also want to add your custom solution build image, but we will keep this out of scope for now.)

Moving to the Dockerfile of the CM build, we will take in the JSS_IMAGE and copy its contents from /module/cm/content into the CM base image. Next, we also want to copy some tools shipped in the JSS_IMAGE. We need to coy them as well and execute the initialize-content.ps1 script.

Customize MSSQL image

Next, we will have to install the Sitecore items of the JSS Server Components by creating a custom MSSQL image. In the docker-compose.override we need to add a section to build a custom mssql image.

In the dockerfile, we copy the dacpacs from the jss-asset image into the mssql image and execute the deploydatabases.ps1 script.

Node.JS is missing

Presuming you have created a jss-project and deployed it to your Sitecore instance (more info on https://jss.sitecore.com/), when you browse to your website now, you will receive an error explaining that node.js is missing.

To add node.js to our cm image, we will have to extends our custom cm build. First we will update the docker-compose.override to pass the build_image (mcr.microsoft.com/dotnet/framework/sdk:4.8) to the CM build. We could also pass “mcr.microsoft.com/windows/servercore:1803”, but opt to use the build image as we already use this one in our architecture.

Next, we will update the CM Dockerfile.

First let’s take in the build_image (line 5), and spin it up as a container “installer” (line 10). In this installer container, we will download nodejs (line 14), extract the zip file (line 15) and rename the extracted folder (line 16).

Next we will copy nodejs from the installer container to the nodejs folder of the custom cm image. (lines 33 + 34)

Finally, we will have to add the folder containing nodejs into the path of this containered windows. (line 35) Make sure to add the /m flag to change the system environment path instead of the user environment path.

Once we rebuild our images and spin up some new containers, we should have a working JSS website in containers!

Leave a Reply