DavidAJohn / FotoStorioMicroservices

.NET application built using a microservice architecture with Docker containers. Includes a Blazor WebAssembly e-commerce store with Stripe Elements payment integration.
23 stars 4 forks source link

Breaking changes in .NET 8 Docker images #19

Closed DavidAJohn closed 6 months ago

DavidAJohn commented 6 months ago

There are some breaking changes that have been introduced with the .NET 8 Docker images.

While testing, I found that several services that had been updated to .NET 8 where no longer responding, although no errors where visible in the logs. I quickly discovered that I'd missed a memo about the default port changing from 80 to 8080.

There are some other changes as well, which Andrew Lock has explained excellently, as ever:

https://andrewlock.net/exploring-the-dotnet-8-preview-updates-to-docker-images-in-dotnet-8/

Also here's a practical example of a .NET 8 app that uses docker compose:

https://www.yogihosting.com/docker-compose-aspnet-core/

DavidAJohn commented 6 months ago

All of the projects that had been updated to target .NET 8 so far have now been changed so that they expose port 8080 within Docker.

The changes required were quite simple - just a change of port in each Dockerfile and an update to the docker-compose.override.yml file so each updated project uses port 8080.

While updating the Dockerfiles, I took the opportunity to use the new 'app' user which has been added to improve container security by avoiding running everything as root.

I also added a couple of lines where the build configuration is passed as an ARG in the build and publish steps. This is straight out of the Dockerfile generated by one of the new .NET 8 templates with Docker support added.

The gateway projects also needed the Ocelot config files updated to refer to containers running on port 8080.

I'll also do the same with the remaining projects as and when they get updated to .NET 8.