Dockerize a Blazor WASM Application with dotnet watch run

264 Views Asked by At

I'm trying to dockerize a Blazor WASM application, but I want to run the application using dotnet watch run for the local development environment.

the src code is the default Blazor WASM template, I've just moved the project folder into the src folder this is the dockerfile I'm using:

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY . .
ENTRYPOINT dotnet watch run --project "./src/BlazorApp/BlazorApp.csproj" --urls="http://0.0.0.0:80"

I'm getting the following error:

web_1  | Building...
web_1  | Unhandled exception. System.Text.Json.JsonException: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
web_1  |  ---> System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
web_1  |    at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
web_1  |    at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
web_1  |    at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
web_1  |    at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
web_1  |    at System.Text.Json.Utf8JsonReader.Read()
web_1  |    at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
web_1  |    --- End of inner exception stack trace ---
web_1  |    at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
web_1  |    at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
web_1  |    at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
web_1  |    at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonReaderState& readerState, Boolean isFinalBlock, ReadOnlySpan`1 buffer, JsonSerializerOptions options, ReadStack& state, JsonConverter converterBase)
web_1  |    at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonConverter converter, JsonSerializerOptions options)
web_1  |    at System.Text.Json.JsonSerializer.ReadAll[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo)
web_1  |    at System.Text.Json.JsonSerializer.ReadAllUsingOptions[TValue](Stream utf8Json, Type returnType, JsonSerializerOptions options)
web_1  |    at System.Text.Json.JsonSerializer.Deserialize[TValue](Stream utf8Json, JsonSerializerOptions options)
web_1  |    at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssetsCore(IWebHostEnvironment environment, Stream manifest)
web_1  |    at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssets(IWebHostEnvironment environment, IConfiguration configuration)
web_1  |    at Microsoft.AspNetCore.WebHost.<>c.<ConfigureWebDefaults>b__9_0(WebHostBuilderContext ctx, IConfigurationBuilder cb)
web_1  |    at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass9_0.<ConfigureAppConfiguration>b__0(HostBuilderContext context, IConfigurationBuilder builder)
web_1  |    at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
web_1  |    at Microsoft.Extensions.Hosting.HostBuilder.Build()
web_1  |    at Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server.Program.BuildWebHost(String[] args)
web_1  |    at Microsoft.AspNetCore.Components.Web.DevServer.Commands.ServeCommand.Execute()
web_1  |    at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
web_1  |    at Microsoft.AspNetCore.Components.WebAssembly.DevServer.Program.Main(String[] args)
web_1  | watch : Exited with error code 134

Running dotnet watch run --project "./src/BlazorApp/BlazorApp.csproj" from the host system works like a charm instead

Does anyone know what the problem might depend on?

0

There are 0 best solutions below