With Sitecore s transformation to composable DXP and their recent release of the Next.js SDK, I thought I would set up a docker container environment with Sitecore XM and Next.js for learning purposes. It turns out, Sitecore's guide was very straightforward. For the XM topology, we only needed to change the init.ps1 step. For completeness, I've included all the steps here.
Verifying / Installing prerequisites
- Powershell 5.1 - comes bundled with Windows 10, but to verifyIn cmd, run
powershell
- Run
$PSversionTable
- .Net Core 3.1Download and install .Net 3.1
- Verify: In cmd,
run dotnet version
- .Net Framework 4.8Download and install .Net Framework 4.8
- Verify: In Powershell run
(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Release -ge 528040
- If it returns true, that means 4.8 is installed. More info on
- how to determine .Net Framework version
- Download and install dockerRun Docker Desktop
- Switch to windows containersOpen the windows system tray, and right click on Docker Desktop
- Click "Switch to windows containers "
- Node.jsFor node.js, I like to use NVM for windows, which will allow you to easily switch node versions
- To use NVM, uninstall any pre-existing node installations
- Download NVM for windows
- To use node ltsInstall lts:
nvm install lts
- Switch to lts:
nvm use lts
- Sitecore templateInstall Sitecore template:
dotnet new -i Sitecore.DevEx.Templates --nuget-source https://sitecore.myget.org/F/sc-packages/api/v3/index.json
Stop services
In order to run docker, ports 443 and 8984 must be free.
- Stop port 443, stop IIS by running
iisreset /stop
- Stop any Solr services running on port 8984In powershell, check what's using the port by running
Get-Process -Id (Get-NetTCPConnection -LocalPort 8984).OwningProcess
- If you get the error, there's nothing running on port 8984 and you're good to go.
Get-NetTCPConnection : No MSFT_NetTCPConnection objects found with property 'LocalPort' equal to '8984'. Verify the value of the property and retry.
- If you need to stop the servicerun
Stop-Service -Name "the name of your service"
- or if using nssm, run
nssm stop "the name of your service"
Installing
- In powershell, navigate to a directory e.g. c:\repos
- Run
dotnet new sitecore.nextjs.gettingstarted -n XmNextJs
- (replace XmNextJs with your own project name)
- Navigate to the directory of your project e.g. XmNextJsrun
.\init.ps1 -InitEnv -Topology "xm1" -LicenseXmlPath "path\to\license.xml" -AdminPassword "yourpasswordhere"
- The script will prompt you on how you want to configure your solution such as SSG vs SSR. I left most of this as the default
- Once the script finishes, run
setx NODE_EXTRA_CA_CERTS C:\Users\{yourusername}\AppData\Local\mkcert\rootCA.pem
- Restart Powershell (or VSCode if you re using that)
- Run
.\up.ps1
- The CM server will prompt you to log into sitecore - go ahead and do so using your admin credentials
- When the script finishes, you should be able to visit your rendering host e.g. https://www.xmnextjs.localhost/