Installing and running the Sitecore environment
This will guide you with installing Sitecore XM and Next.js in a docker container environment. The beauty with using docker is that you do not have to download and install Sitecore, Solr, SQL, etc manually; docker will take care of that for you.
If you haven't already, install the prerequisites.
Clear ports
In order to run Sitecore with docker, ports 443 and 8984 must be free as Sitecore uses those ports for SSL and Solr respectively.
-
Stop port 443, stop IIS by running
iisreset /stop
. Note: this will stop all websites running on IIS on your machine. -
Stop any Solr services running on port 8984
- In powershell, check what's using the port by running
Get-Process -Id (Get-NetTCPConnection -LocalPort 8984).OwningProcess
- If you get the error below, 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 it does return a process, run the below to stop the service.
- In cmd, run
Stop-Service -Name "the name of your service"
- or if using nssm, run
nssm stop "the name of your service"
- In cmd, run
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)- You will encounter a few prompts regarding dotnet restore, powershell, SSG, etc. If you're familiar with these settings, feel free to change these as you need. When it asks if you're deploying to XM Cloud, select No. You can select the default choices for the rest.
-
Once done, use Visual Studio Code to open your new project e.g. c:\repos\XmNextJs
-
Open a new terminal
- run
.\init.ps1 -InitEnv -Topology "xm1" -LicenseXmlPath "path\to\license.xml" -AdminPassword "yourpasswordhere"
⚠️Change
path\to\license.xml
with the correct path to your license.⚠️Change
yourpasswordhere
with a password of your choosing. You will need this for step 7. - run
-
Once the
.\init.ps1
script finishes, execute the command that is mentioned at the end. This will add SSL cert.setx NODE_EXTRA_CA_CERTS C:\Users\{yourusername}\AppData\Local\mkcert\rootCA.pem
⚠️Change
{yourusername}
with your windows user name. -
Restart Visual Studio Code
-
At the time of this writing, there is a bug in the docker compose, which we will fix.
- Open up C:\repos\XmNextJs\run\sitecore-xm1\docker-compose.override.yml
- Place an extra backslash to the entrypoints
entrypoint: powershell.exe -Command "& C:\\tools\\entrypoints\\iis\\Development.ps1"
-
Make sure you're running Docker for Windows
-
Make sure you clear ports before proceeding
-
We should now be ready to execute the powershell script that will download container images and build your environment. This process may take a while.
- Run
.\up.ps1
- Run
-
The CM server will prompt you to log into sitecore.
- Enter
admin
as the user name and the password you specified on step 3.11. - Click Yes, Allow
- Enter
-
When the script finishes, it will launch the Content Management (CM) instance. After a bit of time, (after the Content Delivery instance warms up) you should be able to visit your rendering host e.g. https://www.xmnextjs.localhost (opens in a new tab)