Docker Instance Package Installation vs Content Serialization with Sitecore CLI 4.0.0

As any other developer, I like to breakdown my work into tasks so that I have a good grasp of what I do and I can accomplish the end-result. In this blog article:

1. Created the 404 page as a content item (for this cycle, copied and modified Thank-you item)

2. Created a package so that I can manually install it to a Docker instance 

3. Used Sitecore CLI to serialize the 404-content items 

4. Checked if up.ps1 can de-serialize the 404-item while creating the Docker instance

Create a package to manually install it to a Docker instance 

If you understand the up.ps1 flow, the script gets up the site running every time and pushes the Sitecore items from the file system to the instance. So, if you don't have the items serialized in the file system, you need to install a package. Based on this blog, I understood that I needed to provide permission to my cm instance in case I need to install a Sitecore package. So, made the following change to the Dockerfile:

docker/build/cm/Dockerfile:

RUN icacls 'C:\inetpub\wwwroot' /grant 'IIS_IUSRS:(F)' /t


Note that this change is not required once your items get serialized in the file system. That part is covered down the line in this blog.

Now, I was able to install the package through the installation wizard.and could see the 404 item in the content tree. But, the disadvantage of this approach is, you must manually do the installation every time you compose-up the Docker instance.

So, the better approach is to serialize once and allow up.ps1 to pick the files from the file system to perform the Sync to Sitecore.

So, the next step is:

Use Sitecore CLI to serialize the 404-content items

Frankly, my first instinct as I started this exercise was: I didn't see the serialize item / tree buttons in the Sitecore Docker instance toolbar so, started customizing the toolbar:


But, on clicking the serialize tree or serialize item buttons in the Sitecore customized toolbar didn't produce any yml files in the file system. So, wasn't sure if this was the right approach and decided to forego this approach for now.

This is when it appealed me to use the dotnet sitecore ser pull command since CLI 4.0.0 was part of the Docker instance:


Now, good to see the 404 items serialized to the file system:

Unless, I covered one full round, the development workflow didn't seem perfect. So, cleared my docker folder using clean.ps1, dockered down and ran the up.ps1 and got the GraphQL error (listed down below).

As a resolution, since the below GraphQL error seemed a rogue one based on what I saw in the generated .yml files, deleted the .scindex file generated under \src\Project\MvpSite\items\content folder, 



Then, executed clean.ps1 and re-executed .\up.ps1 and the below GraphQL error was gone.

.\up.ps1 picking up the yml files:

Here is my content tree after a successful up.ps1 push:


Now, I could access just my 404 page from the Docker instance:


So, the development workflow is one full cycle with Docker, CLI, VS and Sitecore in place.

GraphQL Error:

GraphQL.ExecutionError: Error trying to resolve a. ---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)

   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()

   at Sitecore.Data.DataProviders.CompositeDataProvider.<DoGetChildIDs>d__94.MoveNext()

   at Sitecore.Common.EnumerableExtensions.ForEach[T](IEnumerable`1 sequence, Action`1 action)

   at Sitecore.Data.DataProviders.CompositeDataProvider.GetChildIDs(ItemDefinition itemDefinition, CallContext context)

   at Sitecore.Data.DataProviders.DataProvider.GetChildIDs(ItemDefinition item, CallContext context, DataProviderCollection providers)

   at Sitecore.Data.DataSource.GetChildIDs(ID itemID)

   at Sitecore.Nexus.Data.DataCommands.GetChildrenCommand.Execute(Item item)

   at Sitecore.Data.Engines.EngineCommand`2.Execute()

   at Sitecore.Data.Managers.ItemProvider.GetChildren(Item item, ChildListOptions options)

   at Sitecore.Data.Managers.ItemProvider.GetChildren(Item item, SecurityCheck securityCheck, ChildListOptions options)

   at Sitecore.Nexus.Data.DataCommands.ResolvePathCommand.ResolvePath(String[] parts, Int32 index, ItemList items)

   at Sitecore.Nexus.Data.DataCommands.ResolvePathCommand.ResolvePath(String[] parts, Int32 index, ItemList items)

   at Sitecore.Nexus.Data.DataCommands.ResolvePathCommand.ResolvePath(String itemPath, Database database)

   at Sitecore.Nexus.Data.DataCommands.ResolvePathCommand.Execute(String itemPath, Database database)

   at Sitecore.Data.Engines.EngineCommand`2.Execute()

   at Sitecore.Data.Managers.ItemProvider.GetItem(String itemPath, Language language, Version version, Database database, SecurityCheck securityCheck)

   at Sitecore.Data.Managers.DefaultItemManager.GetItem(String itemPath, Language language, Version version, Database database)

   at Sitecore.Data.Managers.ItemManager.GetItem(String itemPath, Language language, Version version, Database database)

   at Sitecore.Services.GraphQL.Content.GraphTypes.IdHelper.TryResolveItem(Database database, String inputPathOrIdOrShortId, Language language, Nullable`1 version, Item& item)

   at Sitecore.DevEx.GraphQL.Serialization.Queries.SerializationQuery.<Resolve>d__2.MoveNext()

   at GraphQL.Execution.ExecutionStrategy.SetArrayItemNodes(ExecutionContext context, ArrayExecutionNode parent)

   at GraphQL.Execution.ExecutionStrategy.<ExecuteNodeAsync>d__7.MoveNext()

   --- End of inner exception stack trace ---

C:\MVP-Site-new\up.ps1 : Serialization push failed, see errors above.

At line:1 char:1

+ .\up.ps1

+ ~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException

    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,up.ps1




Comments

Popular Posts