Publish docker container for Blazor WASM Hosted app (.net 6) with SQL Server

154 Views Asked by At

As the title suggests, I want help regarding how to publish a docker container for my Blazor WASM hosted app which is using a SQL Server. I am a complete docker noob.

From what I gathered from the reading on the internet, I need a Docker file at the root of my project. So which root? Server? Or main folder containing all the project folders?

Then how do I reference dependencies for the shared folder? How do I add my migrations and data-update (EF Core) to SQL Server container? and how to publish that all with pointing to my domain?

Adding docker support to my server folder adds the following docker file:

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
 ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Server/RestaurantManager.Server.csproj", "Server/"]
COPY ["Client/RestaurantManager.Client.csproj", "Client/"]
COPY ["Shared/RestaurantManager.Shared.csproj", "Shared/"]
RUN dotnet restore "./Server/./RestaurantManager.Server.csproj"
COPY . .
WORKDIR "/src/Server"
RUN dotnet build "./RestaurantManager.Server.csproj" -c $BUILD_CONFIGURATION -o 
/app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./RestaurantManager.Server.csproj" -c $BUILD_CONFIGURATION -o 
/app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "RestaurantManager.Server.dll"]

But and this is creating a Docker image that I can see from Docker desktop client, but the thing is this is only working when I launch it through Visual Studio Docker option. but not from the desktop client.

SO I imagine if I somehow get to publish this to a public registry (that is what a Docker container host is called?) it will not work?

I would really appreciate a step by step solution/help.

0

There are 0 best solutions below