From 0395c740413e4da0faa91f4615d3d69264c60c19 Mon Sep 17 00:00:00 2001 From: masoud Date: Sun, 7 Dec 2025 22:48:28 +0000 Subject: [PATCH] fix: Change FrontOffice Dockerfile to nginx runtime for Blazor WASM - Changed from aspnet to nginx:alpine - Copy wwwroot output instead of FrontOffice.dll - Configure nginx SPA routing (try_files for client-side routing) - Remove ENTRYPOINT dotnet command - Fix project name references (FrontOffice.Main.csproj) --- src/FrontOffice.Main/Dockerfile | 35 ++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/FrontOffice.Main/Dockerfile b/src/FrontOffice.Main/Dockerfile index 607f58f..7a8b61f 100644 --- a/src/FrontOffice.Main/Dockerfile +++ b/src/FrontOffice.Main/Dockerfile @@ -1,18 +1,35 @@ FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build WORKDIR /src + +# Copy NuGet config and project file COPY ["FrontOffice.Main/NuGet.config", "NuGet.config"] -COPY ["FrontOffice.Main/FrontOffice.csproj", "FrontOffice.Main/"] -RUN dotnet restore "FrontOffice.Main/FrontOffice.csproj" --configfile NuGet.config +COPY ["FrontOffice.Main/FrontOffice.Main.csproj", "FrontOffice.Main/"] + +# Restore dependencies +RUN dotnet restore "FrontOffice.Main/FrontOffice.Main.csproj" --configfile NuGet.config + +# Copy all source code COPY . . + +# Build and publish WORKDIR "/src/FrontOffice.Main" -RUN dotnet publish "./FrontOffice.csproj" -c Release -o /app/publish +RUN dotnet publish "FrontOffice.Main.csproj" -c Release -o /app/publish +# Runtime stage - nginx for Blazor WebAssembly +FROM nginx:alpine AS final +WORKDIR /usr/share/nginx/html -FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime -WORKDIR /app -COPY --from=build /app/publish . -ENV ASPNETCORE_URLS=http://+:8080 -EXPOSE 8080 -ENTRYPOINT ["dotnet", "FrontOffice.dll"] +# Copy published wwwroot (Blazor WASM output) +COPY --from=build /app/publish/wwwroot . +# Configure nginx for SPA routing +RUN echo 'server { \ + listen 80; \ + server_name _; \ + location / { \ + root /usr/share/nginx/html; \ + try_files $uri $uri/ /index.html; \ + } \ +}' > /etc/nginx/conf.d/default.conf +EXPOSE 80