Blazor项目通过docker和nginx部署为静态站点的步骤

  1. 通过visual studio或者其他方式发布程序,以保证在输出中移除不必要的依赖项,减少程序集的尺寸。

  2. 创建dockerfile
    dockerfile是相当直截了当的,拉取nginx镜像然后从WWWRoot文件夹拷贝Blazor WebAssembly文件到nginx的html文件夹

    FROM nginx:alpine   
    EXPOSE 80   
    COPY bin/Release/netcoreapp3.1/publish/wwwroot /usr/share/nginx/html
    
  3. build docker 镜像
    docker build --tag blazorstatic .

  4. Run docker 容器
    docker run -p 8080:80 blazorstatic

  5. 使用浏览器访问blazor webapp
    http://localhost:8080

原文地址

原文地址:https://www.cnblogs.com/Saints/p/blazor.html