{"id":13677664,"url":"https://github.com/jongio/BlazorDocker","last_synced_at":"2025-04-29T11:31:28.226Z","repository":{"id":69183919,"uuid":"269539304","full_name":"jongio/BlazorDocker","owner":"jongio","description":"How to Containerize Blazor WebAssembly Standalone, WebAssembly Hosted, and Blazor Server apps","archived":false,"fork":false,"pushed_at":"2020-06-18T18:17:41.000Z","size":258,"stargazers_count":97,"open_issues_count":3,"forks_count":24,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T22:15:11.057Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jongio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-05T05:32:47.000Z","updated_at":"2025-04-03T15:09:27.000Z","dependencies_parsed_at":"2023-04-10T21:31:24.705Z","dependency_job_id":null,"html_url":"https://github.com/jongio/BlazorDocker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2FBlazorDocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2FBlazorDocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2FBlazorDocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2FBlazorDocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jongio","download_url":"https://codeload.github.com/jongio/BlazorDocker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251493856,"owners_count":21598182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:00:45.465Z","updated_at":"2025-04-29T11:31:28.220Z","avatar_url":"https://github.com/jongio.png","language":"HTML","funding_links":[],"categories":["Docker Docs"],"sub_categories":["Blazor"],"readme":"# Blazor Docker - How to Containerize Blazor WebAssembly Standalone, WebAssembly Hosted, and Blazor Server apps\n\nThis repo contains working examples for containerizing Blazor applications with four different hosting models.\n\n\n**ClientServer** - A Blazor WebAssembly client app hosted on nginx and ASP.NET Core server app hosted in ASP.NET Core. \n\n    - Created with `dotnet new blazorwasm --hosted -o . -n BlazorClientServer`\n\n**Hosted** - A Blazor WebAssembly client app hosted on ASP.NET Core server.\n\n    - Created with `dotnet new blazorwasm --hosted -o . -n BlazorHosted`\n\n**Server** - A Blazor Server app hosted by ASP.NET Core.\n\n    - Created with `dotnet new blazorserver -o . -n BlazorServer`\n\n**Standalone** - A Blazor WebAssembly client app hosted on nginx.\n\n    - Created with `dotnet new blazorwasm -o . -n BlazorStandalone`\n\n\n## How to run\n\nRun `docker-compose up --build` from ClientServer, Hosted, Server, or Standalone folders to run each version and open the corresdponding localhost endpoint that is found in the docker-compose file for the Blazor app.\n\n## ClientServer\n\nA Blazor WebAssembly client app hosted on nginx and ASP.NET Core server app hosted in ASP.NET Core.  It is broken up into three projects \"Client\", \"Server\", and \"Shared\".\n\n- docker-compose.yml - builds and runs both the Client and the Server projects.  \n\n\n### How to run\n\nRun `docker-compose up --build` from ClientServer folder.  Open browser and go to http://localhost:5080/\n\n### Client Project - uses nginx on alpine base image.\n - **/Pages/FetchData.razor** - includes the following code to show you what endpoint is being hit.\n    ```csharp\n    @using Microsoft.Extensions.Configuration\n    @inject IConfiguration Configuration\n\n    \u003ch1\u003eWeather forecast\u003c/h1\u003e\n    \u003cp\u003eSERVER_HOST: @Configuration[\"SERVER_HOST\"]\u003c/p\u003e\n    ```\n - **/wwwroot/appsettings.json** - includes SERVER_HOST setting for production or when running in a container.  You'll want to change this to match your production endpoint.\n - **/wwwroot/appsettings.Development.json** - includes SERVER_HOST setting for development machine.\n - **/Dockerfile** - builds, publishes, and uses nginx to host it.\n - **/nginx.conf** - the nginx.conf file needed to serve the site.\n - **/Program.cs** - includes the following code to read the SERVER_HOST setting from appsettings.json\n\n    ```csharp\n    var serverHost = string.IsNullOrEmpty(builder.Configuration[\"SERVER_HOST\"]) ?\n        builder.HostEnvironment.BaseAddress :\n        builder.Configuration[\"SERVER_HOST\"];\n\n        builder.Services.AddTransient(sp =\u003e new HttpClient { BaseAddress = new Uri(serverHost) });\n    ```\n\n### Server Project- uses ASP.NET runtime image\n\n- **/Dockerfile** - builds and starts ASP.NET app\n- **/Startup.cs** - includes code to enable Cors, so the client app can call from a different host.\n\n    ```csharp\n    readonly string CorsOrigins = \"CorsOrigins\";\n\n    services.AddCors(options =\u003e\n           {\n               options.AddPolicy(CorsOrigins,\n                   builder =\u003e builder.AllowAnyOrigin()\n                   .AllowAnyMethod()\n                   .AllowAnyHeader());\n           });\n\n    app.UseCors(CorsOrigins);\n    ```\n\n## Hosted\n\nA Blazor WebAssembly client app hosted on ASP.NET Core server.\n\n### How to run\n\nRun `docker-compose up --build` from Hosted folder.  Open browser and go to http://localhost:6080/\n\n### Client Project\n\n- No changes made to Client project from base template.\n\n### Server - uses ASP.NET runtime image\n\n- **/Dockerfile** - builds and starts ASP.NET app\n\n## Server\n\n### How to run\n\nRun `docker-compose up --build` from Server folder.  Open browser and go to http://localhost:7080/\n\n### Server - Uses ASP.NET Core runtime host\n\n- **/Dockerfile** - builds, publishes, and starts the ASP.NET site.\n\n## Standalone\n\n### How to run\n\nRun `docker-compose up --build` from Standalone folder.  Open browser and go to http://localhost:8080/\n\n### Standalone - uses nginx on alpine base image.\n\n - **Dockerfile** - builds, publishes, and uses nginx to host it.\n - **/nginx.conf** - the nginx.conf file needed to serve the site.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongio%2FBlazorDocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjongio%2FBlazorDocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongio%2FBlazorDocker/lists"}