Dockerising the Sitecore Publishing Service

Overview
The sitecore publising service module is entirely new way of publishing the items from source database to the publishing targets unlike the current sitecore publishing. It will be running as a seperate instance and thus increases the publishing thoroughput when we do publishing large volume of data.
As running sitecore instance in Docker became popular in recent times, it is necessary to have the Publishing Service also in docker. In this article let us see how to do this. The below diagram shows a quick overview of the publishing service as we are not going to see it in deep.

Basically the above diagram explains that the Content Authors will be working in the Content Management servers and only the Publishing Service running as a standalone instance is responsible for pushing the contents from source databases to the target databases which Content Delivery servers are based upon.
We will be seeing how to dockerize the Publishing Service further.
Dependencies
This blog assumes that you already have a running sql container within the docker which has core, master and web databases accessible. And also a running Sitecore instance inside docker to be able to use the publishing service after the setup.
As I am using Sitecore 9.0 Update 2, I will be using the Publishing Service version 3.1 and can be downloaded from sitecore downloads. Download the file from this site and place it inside the assets folder.
The publishing service uses the below prebuilt images,
https://hub.docker.com/_/microsoft-windows-servercore-iis – This image is IIS for the windows server to host anything inside the docker
The other two images are,
- asp.net windows servercore
- dotnetcore windows hosting
The above two images are from Microsoft Container Registry (MCR); more info about MCR can be read from here.
We are using these images as the Publishing Service has a dependency on the .NET framework.
Building the Docker file
Inside the docker file, the logic to build and run the publishing service are as follows,
- Download the required prebuild images from docker hub and from the MCR
- Unzip the downloaded Publishing Service into the website
- Update the connection strings
- Update the schemas using the Sitecore.Framework.Publishing.Host.exe
Let us see the commands inside the docker file one by one,

The above commands are to download the required dependancy images

These are to define the arguments which some of them being passed from the docker-compose file.

The above command will download the dotnetcore windows hosting file and put it into the folder mentioned in the ARG section.
If we explore the docker container, the result of the above commands will be as highlighted below ( notice that the required windows hosting excutable are downloaded and moved into the install directory) ,

The next is to install the prerequisities and to add the necessary features.

Next is to copy the downloaded Publishing Service ( from assets folder) to the actual docker asset folder which we defined in the ARG section and to set working directory to the iis web root folder

Again if we explore the docker container, the result will be as below. The sitecore publishing service zip file gets copied from local asset folder into the docker container

Next we will be unzipping the Publishing Service ( from docker asset folder) into the web root folder. The below docker commands are responsible for it.

The above commands will result like below; you can notice that the files are unziped into the website folder.

And then we will need to update the connection strings core, master and web. This will be achieved with the help of the following commands.

The above command will result the below. If we explore the connectionstring json file from the container, we can observe that the core, master and web database connectionstrings are updated.

As the Sitecore Publishing Service will not be using any of the sitecore’s publishing pipelines, it requires to have some tables to process the publishing queue etc., The below commands will update the current sitecore’s master database schema to have these tables.

The result of the above command will be to have the below highlighted tables inside the master database,

Now with the above mentioned list of commands, we have our docker file ready. Let us see below to have the docker-compose file.
Docker-Compose File
From the docker-compose file we will be passing the required connection strings, name of the publishing service package, ports and the hostname using which the publishing service can be accessed.

Building and Running the Container
I am using the docker file from the below folder path and this can be anywhere based on the need.

and I have the docker-compose.yml file in my solution root folder. When the docker file is inside a different folder than the docker-compose file, please make sure to point the context to the location where the docker file exists like below.

After this just run the docker-compose up -d command from the location where the docker-compose.yml file exists. It will build the image and up the publishing service container eventually.

You can then notice that the publishing service is up and running from the docker once the above commands executed without any issues.

To make sure the publishing service is running without any issues, access the below url. If it gives “status:0”, then the publishing service is running properly.

That’s all. Now we have the publishing service running inside the docker. This publishing service url can be used within the sitecore running in the same docker container.
The source code of this can be found from the github url.
Happy Dockering…!!!
