I built a blazor WASM app which I want to publish as a docker image, but in a way that it is someone configurable for consumers of the image. The API endpoints it talks to should be configurable, as well as some colors and icons.
The default .NET way of configuring applications is through AppSettings.json
, so I explored that route.
The best solution I was able to find, is to map an external AppSettings.json
file into the docker container which is started, which then contains custom configuration.
I noticed that besides AppSettings.json
, after my build there is also a AppSettings.json.br
and AppSettings.json.gz
file, which given their extension, I presume are compressed versions of the original file.
Also, the app is configured as a PWA app, and is built using AOT. I noticed if I only replace AppSettings.json
and leave the compressed versions in place (with their original content), the installed PWA app seems to revert back to the default settings every now and then.
This leaves me with the following process of publishing a customizable docker image:
- Publish application using
dotnet publish ...
- In my
Dockerfile
, copy published files on top op nginx docker image - In same
Dockerfile
, removeAppSettings.json.br
andAppSettings.json.gz
files - Publish docker image with instructions to mount external
AppSettings.json
file to customize the application
But it feels wrong to delete files our of the set of published files the dotnet SDK produces. Am I missing something? How are other people doing this?