Options. There’s always options. Some options, like paying to change your flight, suck. Some, like getting a free upgrade to first class…don’t suck. What does this have to do with Docker? Nothing, aside from the fact they are options. Anyway, I suck at intros to my blog posts, but it’s out of the way. Let’s get nerdy!
There’s been a lot said about Docker for your local environment. Whether you’re deploying to On-Premise, IaaS, Azure PaaS, Containers, Managed Cloud, or even Vercel, it makes sense to have an easy, repeatable local setup process. Docker does that, and it does it really well. That said, there has been a bunch of movement on the Docker front since I got involved back in version 9.3. There was a community repo, then a official, then samples, then examples, then MVP site…
I can get behind all of those, frankly. And I’m sure everyone who has done docker locally has tweaked it in some way or fashion.
Here’s my take on a basic XM1 with SXA and Headless. Why roll my own? Well, I changed a couple things:
- Updated to support Docker Compose V2 and V3. There were a couple small changes here around paths and specifically increasing the memory footprint of SQL. This was an important one as Docker Compose v1 hits end of life pretty soon: Read more here.
- Segmented out build vs init vs run. It never made sense to me why these were all jumbled together. CI and CD are split apart to two phases, why would Build/Run be stuck together. You’ll notice the project has a different file for each, now. The standard ‘docker compose up -d’ works for your day to day and you don’t get nagged about init containers exiting.
- I moved the .env into the docker folder, and the init script copies it to the root before setting the vars. It’s also been added to the .gitignore so you don’t accidentally commit your local settings.
- Baked in WHW. Shameless plug here, but it really does make life easier.
- I moved to a wildcard cert for all local development: *.dev.localhost. You’ll see the entries generate for Project-CM, Project-CD, etc. but are all treated in the wildcard. This allows for a single cert for all instances and a single CA.
So how do you run this when you get it? It’s in the README.md, but here’s the TL;DR:
#Init your folders .\init.ps1 -LicenseXmlPath <path_to_license> -Project <project name> #Build the Images docker compose -f .\docker-compose.build.yml build #Init your SQL and solr docker compose -f .\docker-compose.override-init.yml up -d #Run it. --remove-orphans not necessary, but keeps your project clean. Only needed the first time. docker compose up -d --remove-orphans
Check out the Git Repo here: https://github.com/RAhnemann/sitecore-xm-boilerplate and let me know if you have any feedback!