dotnet-docker
dotnet-docker copied to clipboard
Create a Blazor WASM sample
Describe the Problem
We currently have samples for standard ASP.NET Core apps. However, Blazor WASM apps are unique in that the build output is a static site, not a .dll
or executable that can be run with the dotnet
cli. Our existing ASP.NET Core samples won't work for Blazor WASM apps.
Describe the Solution
We should create a Blazor WASM sample app and provide example Dockerfiles for building and deploying it using a static web server using IIS, nginx, Apache, or python (or whichever other server, perhaps even a simple .NET one). Additionally, we should point to the Azure and GitHub docs for deploying static sites.
Additional Context
- Related:
- https://github.com/dotnet/dotnet-docker/pull/5066
- https://github.com/dotnet/dotnet-docker/issues/5033
- https://github.com/dotnet/sdk/issues/37668
- Blazor WASM deployment documentation: https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-8.0#standalone-deployment
[Triage] The primary concern of this repo is building and deploying apps on .NET containers. Since a Blazor WASM static site wouldn't be deployed on a .NET container image, it seems outside the scope of this repo.
@danroth27, would it make sense to add some documentation to the existing Blazor WASM deployment documentation about deploying via containers?
For example, here's a customer's issue and Dockerfile who is trying to deploy Blazor WASM via our ASP.NET Core image with a .dll that Blazor WASM doesn't produce.
@lbussell Standalone Blazor WebAssembly apps are just a bunch of static files, like a JavaScript based single page app. You need to publish the app to a web server that can then serve the files. It's convenient to host the files in an ASP.NET Core app, which is what a Blazor Web App in .NET 8 is set up to do and is the recommended approach for a container-based deployment. Publishing a Blazor Web App to a container shouldn't be any different from publishing an ASP.NET Core app to a container.
@danroth27 Ah, thank you for the clarification. I didn't realize that the blazor
template had anything to do with WebAssembly so I overlooked it. I see now that it can set up a server with interactive WebAssembly as well. I'll test it out and report back here.
From a discussion in standup today:
Hosting static files is outside the scope of the .NET Docker project, but we should still have some sort of sample for Blazor.
The Auto/Hybrid functionality from the blazor
template seems like an appropriate middle-ground:
Auto
: Uses interactive server-side rendering while downloading the Blazor bundle and activating the Blazor runtime on the client, then uses client-side rendering with WebAssembly.