top of page
  • Writer's pictureGowtham

Building a Sitecore Solution from Scratch with Docker: Part 3

Updated: May 18, 2023

Our previous post focused on how we updated the folder structure to comply with Helix principles, enabling us to construct our solution utilizing the Helix methodology. Additionally, we aimed to simplify the implementation process by utilizing the XM topology. In this blog, we will delve into the process of integrating Sitecore modules such as SXA and SPE.


To start the process of integrating custom modules, the first step is to include the fundamental configuration necessary for the CM and CD setup in the "docker-compose.override.yml" file. This can be achieved by adding the appropriate entries for CM and CD. Additionally, we will need to include the DockerFile for this setup.


Add the below entries to the "docker-compose.override.yml"

  cm:
    image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-xm1-cm:${VERSION:-latest}
    build:
      context: ./docker/build/cm
      args:
        BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xm1-cm:${SITECORE_VERSION}

  cd:
    image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-xm1-cd:${VERSION:-latest}
    build:
      context: ./docker/build/cd
      args:
        BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xm1-cd:${SITECORE_VERSION}

Create two new folders named "cm" and "cd" under the "docker\build" directory. Afterwards, you can add the appropriate DockerFile with the necessary content in these folders.

# escape=`

ARG BASE_IMAGE

FROM ${BASE_IMAGE}

Once you have added the changes, execute the following commands to halt and restart with the updated modifications.

docker compose down
docker compose build
docker compose up -d
cm_docker

Now that the website is functioning properly, it's time to begin modifying the configuration for SXA and SPE.


Adding SXA and SPE module

This topic will cover the process of adding the SXA Module. The Sitecore Module Reference( SXA and SPE) page contains the official documentation for adding the Sitecore SXA Module.


Open the "docker-compose.override.yml" file and insert the following configurations under the corresponding roles.

  mssql-init:
    image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-xm1-mssql:${VERSION:-latest}
    build:
      context: ./docker/build/mssql-init
      args:
        BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xm1-mssql-init:${SITECORE_VERSION}
        SPE_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-spe-assets:${SPE_VERSION}

  solr-init:
    image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-xm1-solr-init:${VERSION:-latest}
    build:
      context: ./docker/build/solr-init
      args:
        BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xm1-solr-init:${SITECORE_VERSION}
        SXA_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-sxa-xm1-assets:${SXA_VERSION}
   id:
    image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-id6:${VERSION:-latest}
    build:
      context: ./docker/build/id
      args:
        BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-id6:${SITECORE_VERSION}
    volumes:
      - ${HOST_LICENSE_FOLDER}:C:\license
    environment:
      SITECORE_LICENSE_LOCATION: C:\license\license.xml
  cd:
    image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-xm1-cd:${VERSION:-latest}
    build:
      context: ./docker/build/cd
      args:
        BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xm1-cd:${SITECORE_VERSION}
        SXA_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-sxa-xm1-assets:${SXA_VERSION}
    volumes:
        - ${LOCAL_DATA_PATH}\cd:C:\inetpub\wwwroot\App_Data\logs

  cm:
    image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-xm1-cm:${VERSION:-latest}
    build:
      context: ./docker/build/cm
      args:
        BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xm1-cm:${SITECORE_VERSION}
        SPE_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-spe-assets:${SPE_VERSION}
        SXA_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-sxa-xm1-assets:${SXA_VERSION}
    volumes:
        - ${LOCAL_DATA_PATH}\cm:C:\inetpub\wwwroot\App_Data\logs

To store the log files for the CM and CD roles, create a new folder named "cm" and "cd" within the "docker\data" directory.

data_folder_structure

Include the following variables in the .env file, which will be utilized in the docker-compose.override.yml file.

SPE_VERSION=6.4-1809
SXA_VERSION=10.3-1809
HOST_LICENSE_FOLDER=C:\license
SITECORE_MODULE_REGISTRY=scr.sitecore.com/sxp/modules/

DockerFile

If you do not have the DockerFile, please create it under docker\build and then apply the provided configuration code for the mentioned roles.

cd:

# escape=`

ARG BASE_IMAGE
ARG SXA_IMAGE

FROM ${SXA_IMAGE} as sxa
FROM ${BASE_IMAGE}

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

WORKDIR C:\inetpub\wwwroot

COPY --from=sxa C:\module\cd\content C:\inetpub\wwwroot
COPY --from=sxa C:\module\tools C:\module\tools
RUN C:\module\tools\Initialize-Content.ps1 -TargetPath C:\inetpub\wwwroot; `Remove-Item -Path C:\module -Recurse -Force;

cm:

# escape=`

ARG BASE_IMAGE
ARG SXA_IMAGE
ARG SPE_IMAGE

FROM ${SPE_IMAGE} as spe
FROM ${SXA_IMAGE} as sxa
FROM ${BASE_IMAGE}

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

WORKDIR C:\inetpub\wwwroot

COPY --from=spe C:\module\cm\content C:\inetpub\wwwroot

COPY --from=sxa C:\module\cm\content C:\inetpub\wwwroot
COPY --from=sxa C:\module\tools C:\module\tools
RUN C:\module\tools\Initialize-Content.ps1 -TargetPath C:\inetpub\wwwroot; `Remove-Item -Path C:\module -Recurse -Force;

mssql-init:

# escape=`

ARG BASE_IMAGE
ARG SPE_IMAGE

FROM ${SPE_IMAGE} AS spe
FROM ${BASE_IMAGE}

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

COPY --from=spe C:\module\db C:\resources\spe

solr-init:

# escape=`

ARG BASE_IMAGE
ARG SXA_IMAGE

FROM ${SXA_IMAGE} as sxa
FROM ${BASE_IMAGE}

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

COPY --from=sxa C:\module\solr\cores-sxa.json C:\data\cores-sxa.json

id:

# escape=`

ARG BASE_IMAGE

FROM ${BASE_IMAGE}

After implementing the aforementioned modifications, execute the below commands to confirm that the installation of SXA and SPE is successful.

docker compose down
.\clean.ps1
docker compose build
docker compose up -d

Launch your web browser and access the URL https://cm.sitecoredocker.localhost/sitecore/login to confirm the successful installation of SXA and SPE.

spe_verification
sxa_verification

We have completed the setup and preparation of Sitecore for our project's solution creation and deployment. In the next blog, we will explore how to create a Docker solution with Helix and integrate it with Docker for deployment purposes.

106 views0 comments

Comments


bottom of page