Showing posts with label docker. Show all posts
Showing posts with label docker. Show all posts

Wednesday, May 4, 2022

Windows Hosts Writer 2.0

 Today I'm pleased to announce the release of Windows Hosts Writer 2.0! In this article we'll learn about what is new and how to get started. Also, a reminder about the pain of managing the hosts file.



There are many steps needed to get a website running locally. For traditional sites hosted with IIS you have to add application pools, websites, perhaps configure services accounts...the list goes on. One of the tasks that feel the most tedious is adding entries to the hosts file. If you are not familiar, this is an extension-less file found at C:\Windows\System32\drivers\etc\hosts and contains IP-to-Hostname mappings. Each row will have an IP address such as 127.0.0.1 followed by the hostname such as scms.dev.local

If you open the hosts file you may already see something like the following:


As you can see from the above image, there is not much going on. This file comes in handy when you want a fancy url to loop back to the local machine. So now you must be wondering how does Windows Hosts Writer (WHW) relate to this? When paired with Docker it can save a tremendous amount of time in managing the everchanging IP addresses.

A while back Rob introduced the Sitecore community to a neat tool distributed through its own Docker container. Check out his series of articles detailing the improvements made over time.

Finally, what is so important about this new 2.0 version of WHW? I'm glad you asked before bailing out on this lame blog post. Below is a breakdown of all the goodies.

  • Support for .net 3.1 ends December 3, 2022 while 6.0 is the latest version released with LTS. We went ahead and upgraded before we forget.
  • Fixed an issue with the TERMINATION_MAP feature. 🥇
  • Aliases that are space-delimited are treated like all the other host entries.
  • Consolidated the Dockerfile which enables contributors to debug locally with Visual Studio, build from docker-compose.yml, and ensure @RAhnemann can still do releases. 👍🏼
  • Encriched the readme with helpful details on getting started. Run docker compose up -d from the root directory to try it out.
  • Updated the referenced Docker.Dotnet assembly to address the dreaded exception Docker.DotNet.DockerApiException: Docker API responded with status code=BadRequest, response=400 Bad Request. This might have been revealed after upgrading Docker to 4.7.1.
If you want to get started, check out the readme on GitHub. The Docker images have been pushed to DockerHub here.

Thursday, January 2, 2020

Secure Docker Websites for Sitecore

In this article Michael shares how to configure Sitecore running on Docker locally with HTTPS. A sample repository is provided to help you get started.

If you don't care to read this article and just want the source code then check out this link right here. There you can see how to get thing setup.


The Background


There comes a time when every developer is going to need Sitecore running over HTTPS. If you have been following the progress the Sitecore Demo Team is making with Docker you'll see that getting started is going to be far less complex for everyone. If you have not yet already seen the GitHub repository feel free to do that once you've finished reading this post.

There are a few articles written recent to this post around getting started with Docker running Sitecore. You may find that some eventually are outdated because the Sitecore Demo Team is moving at such a fast pace the instructions in the articles go stale. Nevertheless the articles provide valuable insight into what you need to do for things to run smoothly. I trust that you will take the time to (if not already) to familiarize yourself with Docker. For those that have worked with Sitecore for any amount of time, surely you will appreciate the simplicity Docker brings.

Note: At the time of this article SIF is no longer used for the Sitecore Docker images. I'm very thankful for this because it makes setup much easier to follow on how things work.

Recommended articles:

  • Sitecore Docker for Dummies - This 3-part series is actually the nudge I needed to get started. Mark Cassidy does such a fantastic job covering the basics. No time is wasted on unnecessary tasks, like setting up a Docker Hub account. If you install Docker through Chocolatey no account is needed.
  • Yet Another Sitecore Docker Series - This 9-part series goes into a bit more detail about how the build of images and running containers come together. Rob Ahnemann is very clear about how things work and at times provide a bit of comic relief.
  • Maintain Your Hosts File with a Docker Container - This helps make the management of hosts entries painless. Thanks Rob! Thank you Hosts Writer!
  • Sitecore Docker and HTTPS with Traefik - At the writing of this I've not tested this approach but if Per Manniche Bering says try it then I recommend you do.


For those wondering about Sitecore supporting Docker, there is a question and answer on Sitecore Stack Exchange which provides more detail.

The Setup


The following steps should help you get things rolling and troubleshoot:
  1. Clone the following repository : https://github.com/michaellwest/docker-https.git
  2. Open the file docker-compose.yml to have a look at what is going on. This compose file assumes you have images built and available on your machine for Sitecore 9.3 XM. 
  3. Open the file .env to ensure they match what is used for your built images. You can try to copy the .env file from the Sitecore repository if things don't work right. An example path would be https://github.com/Sitecore/docker-images/blob/master/windows/tests/9.3.x/.env
  4. Open the folder Startup and with an elevated PowerShell console run the createcert.ps1. By default the script creates a Self-Signed Certificate using the DNS "*.dev.local" then installs locally. Files will be generated in the same directory to be used by the running container (pfx and txt files should now exist).
  5. The file startup.ps1 will be used by the running container to install the certificate and configure the HTTPS bindings.
  6. Run docker-compose up.
  7. Navigate to https://docker-https.dev.local/sitecore.
If everything is setup properly you'll end up with a console full of log messages and finally the login screen to Sitecore.

The Magic


I made this video to help walk you through the different parts with a tad bit of colorful commentary.



- I hope you have a wonderful 2020!