Visual Studio, Blazor WASM, and Docker

 So as usual my attempts to create something take to places where i find things do not work the way i wanted, then i find myself searching for a way to get things to work i want them, and in this case it might be the way a lot of people want to.

last weekend i wanted to explore how easy or hard to containerize / Dockrize a .NET5 back-end, Blazor WASM front-end app.

for the back-end things were super easy, just right click, add docker support, add containers orchestration and all was working, running, and debugging according to plan.

Now when i tried to do the same for a Blazor WASM project things got a it ugly, seems like Visual Studio generate these according to project type, and i guess it saw the Blazor WASM as another .NET hosted web app, which is and is not quite!

See Blazor WASM are entirely client side running, the server is there to just provide files but no process occur at the server, so technically you can host a Blazor WASM app on any web server (like Nginx) without the need to install any additional frameworks or dependencies, the server just serve a bunch of static files to clients which do include all the app logic and the clients process and execute that logic not the server (is that edge computing?! 🙂 ).

anyway back to our original topic when you try to Dockrize this in VS using same steps things do not quite work, a quick search will confirm that.

Long story short i saw acouple of posts here and there about changing the dockerfile to use nginx:alpine image.

my problem was, it simple didn't work!, every time i had to get inside the container and run nginx manually or run the dockerfile outside Visual Studio, now that's a small detail for some but for me it's a chance to learn.

getting into the weeds of things after a good 3 hours of searching and scratching my head why non of my EntryPoint or CMD entries resulted in getting the nginx running at container start, i found out that Visual Studio override the EntryPoint when running the image for debug with

--entrypoint tail -f /dev/null

after some serious digging, i found this and tadaa!

creating that debug.yaml gave me back control and all what i had to do is changing entrypoint value to


nginx -g 'daemon off;'

and that's it, all is running from Visual Studio now as i wanted.

I do realize that this is not the best solution as i still don't know if i can do actual debugging or not, but it's convenient for the moment and a good start waiting for Microsoft to address this open issue since Visual Studio 2017! 😁

Popular posts from this blog

add extra files on deploy ASP Core web app using publish profile

how to copy NuGet packages from one project to another

Blazor how to generate that SHA256 check