Sitecore 10: the technical low-down

Containers, Sitecore Serialization, the CLI and ASP.NET Core

Sitecore 10 has been out for a few weeks, so it's time to look at the technical improvements compared to Sitecore 9: Sitecore containers, the ASP.NET Core SDK, the Sitecore CLI and Sitecore for Visual Studio. Let's dive in!

Sitecore containers

Containers

A quick recap of installing and hosting Sitecore 9: on a self-managed IaaS environment, on Azure Web Apps, or on Azure PaaS.

Besides those, there was a community-driven solution for Sitecore Docker images. Last year, Sitecore started supporting environments hosted in those containers, as long as issues were reproducible in a non-containerized environment. A good sign that Sitecore was moving towards containers. With Sitecore 10, it now provides documentation and officially supported images to deploy a solution in containers. That makes it a lot easier to deploy your Docker containers to Kubernetes, for example.

An image is a package with all code and dependencies: a blueprint for creating a container. An image is often based on another image, with some customisation. Once created, an image can't be changed.

Another big advantage is more freedom in where you host your environment in the cloud: Azure, Amazon or somewhere else? And containers reduce infrastructure costs compared to multiple virtual machines, because the OS kernel is shared between containers instead of duplicated.

Virtual machines compared to containers: containers share the host operating system through a container runtime

Sitecore now provides an official feed with base images, which wasn't possible with the community solution, where you built your own. The feed has public images for Sitecore XM, XP0, XP1 and JSS, plus images that Sitecore doesn't support in production, such as Solr, SQL and Redis cache. Those are labelled non-production and meant for developers. You'll need your own base images if you want, for example, a custom SQL database or custom Solr indexes.

A faster development setup

Faster setup

We're really excited about this:

  1. No installation: everything you need is in the Sitecore Docker image.
  2. No more worrying about the OS: the containers abstract it away.
  3. Spin up the containers you need and get going. Sharing with colleagues is easy, because the environment is entirely configuration-based.
  4. Dependencies are easier to manage. Every Sitecore version has a supported Solr version. As a developer working for several clients on several Sitecore versions, I have to install and maintain different Solr versions. With Solr in a container, that's no longer a worry.

Example: a Docker XM setup

The running containers of a local, scaled Sitecore XM environment in Docker

Above, you see a local, scaled XM environment. You can run XP too: just spin up the right containers. The new Traefik reverse proxy role lets you run all these instances and work on several projects at once: the proxy finds the right container to return to the browser.

Containers give us more options for local development, and more hosting options for our clients' acceptance and production environments.

Getting started with Sitecore 10
Getting started locally was a breeze, and Sitecore documents it very well. In short:

  • Install Docker Desktop for Windows.
  • Clone the Docker Examples repository.
  • Set your environment variables (Sitecore license, passwords) in the .env file.
  • Install the Sitecore DockerTools PowerShell module, with various helper methods.
  • Run docker-compose up -d.

Docker Compose starts the containers from their images. If they already exist, it checks whether the configuration or image changed and, if so, recreates the container. -d runs the containers in the background. The first time you run docker-compose up, it downloads the images, which takes far longer than starting the containers. Be patient the first time.

Result of docker-compose up for the Helix example with the ASP.NET Core rendering container

This is the result for the Sitecore Helix example with the new ASP.NET Core rendering container, from the Helix Examples repository. More about ASP.NET Core below.

Sitecore Serialization, the Sitecore CLI and Sitecore for Visual Studio

Serialization

Serialization takes an item from the Sitecore content tree, saves it on your disk and lets developers synchronise it to another Sitecore instance. It moves items from a local environment to acceptance and production, and makes it easier to write or generate code that works with those items, such as reading fields.

Only a year and a few months ago, Sitecore acquired Hedgehog, including its tool TDS (Team Development for Sitecore). Another popular tool for item synchronisation is Unicorn. The new Sitecore Serialization combines the best of both.

The Sitecore logo with a toy hedgehog, next to the Unicorn logo

You can still use Unicorn, so projects that use it can easily be upgraded to Sitecore 10.

Setting up Sitecore Serialization
You define which items to serialise in a module.json file, very much like Unicorn. If you follow the Helix principles with several foundation, feature and project modules, each has its own configuration file. In module.json, you can include or exclude paths. It supports aliasing, which solves Windows issues with paths that are too long. The order matters: define templates before the items that rely on them.

The products.module.json file from the helix-basic-aspnetcore example project:

The products.module.json file from the helix-basic-aspnetcore example project

The resulting YAML files differ slightly from the Unicorn format. On the left, the Hero Banner template serialised with Unicorn; on the right, with Sitecore Serialization.

The Hero Banner template serialized with Unicorn on the left and with Sitecore Serialization on the right

  • Both are YAML files.
  • Sitecore Serialization has no Database field.
  • It does serialise some extra fields by default: Revision ID, Updated by and the update date and time.

So how do you create those files? With the Sitecore CLI or with a Visual Studio interface.

The Sitecore CLI
The Sitecore command line interface is a new tool to improve the developer experience in Sitecore 10, specifically for serialising items. It will get more features later, but for now you use it for serialisation and publishing. Install the CLI first. Then you log in in one of two ways:

Console output of sitecore login: device login, authorization pending, login complete

1. Log in as a user

sitecore login `
 --authority https://<identity authority> `
 --cm http://<sitecore instance> `
 --allow-write true

A pop-up opens where you log in to the Sitecore environment as a user.

The Sitecore login pop-up in the browser

2. Log in with client credentials

sitecore login `
 --authority https://<identity authority> `
 --cm http://<sitecore instance> `
 --allow-write true `
 --client-credentials true `
 --client-id <client id> `
 --client-secret <client secret>

You configure the client credentials in the Identity Server first. CI/CD pipelines use them to work with an environment and send it any available command.

Table of Sitecore CLI commands: login, init, publish and the serialization commands

An example of sitecore ser info:

Console output of the sitecore ser info command

Sitecore for Visual Studio
The CLI isn't the only way. There's also a Visual Studio plugin, SVS: Sitecore for Visual Studio. You only need a license, which comes with the Sitecore TDS license. The plugin adds a Sitecore Module Explorer window to Visual Studio.

The Sitecore Module Explorer window in Visual Studio

In the Module Explorer, you change which items are serialised, and pull or push specific item folders. On the right is an interactive window to manage the module.json files. A small drawback in this version: you type the path to a Sitecore item by hand, with no easy way to pick it from Sitecore. SVS will certainly get updates.

ASP.NET Core

ASP.NET Core

Sitecore used ASP.NET Core before, for example for the Publishing Service. Sitecore Host, behind the Universal Tracker and Sitecore Identity, is based on .NET Core too. Sitecore keeps moving towards .NET Core, and Sitecore 10 adds a new development option: the ASP.NET Core SDK. This headless option joins the ones you already had with Sitecore JSS: Vue, React, React Native and Angular, which are front-end frameworks for front-end developers. The ASP.NET Core SDK is aimed at back-end developers and lets us work with the latest .NET technology.

Sitecore headless architecture: the JavaScript SDK (JSS) and the ASP.NET Core Rendering SDK on top of Sitecore Headless Services

You can use the Helix ASP.NET Core example as a test environment, set up locally with the new Sitecore Docker containers. This is the ListProducts view:

The ListProducts view in the Helix ASP.NET Core example

It's great to develop Sitecore applications in ASP.NET Core and still use the Experience Editor. It should make demo environments easier to set up. But it's new, so we'll need some time to adapt!

Final thoughts and useful links

Final thoughts

Sitecore 10 brings a revolution to the platform, and we're excited to start using Docker, now officially documented and supported. The Sitecore CLI looks like a robust tool that will grow into a Swiss army knife to perform all kinds of tasks on any Sitecore environment.

Can't wait to get started with Sitecore 10? Some useful links:

Need a little help with Sitecore 10? Our Sitecore experts are happy to help.

Get in touch

Ready to take your digital experience to the next level? Feel free to contact us to learn more about our services and how we can help you leverage the full potential of your digital marketing.

Tell us about your project

And we'll come up with a tailor-made solution

Get in touch with one of our consultants to find the perfect match that fits your needs and enables you to grow.

Fields marked * are required.

Rather talk? Call us on +32 (0) 3 318 65 60

Cookie Policy

Our site uses cookies to improve the website experience. By using our website, you agree to our use of cookies.

Save preferences