# Stage 1: Build the application FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build WORKDIR /src # Copy the project files COPY ["dotnet/Contoso.BlazorApp/Contoso.BlazorApp.csproj", "Contoso.BlazorApp/"] RUN dotnet restore "Contoso.BlazorApp/Contoso.BlazorApp.csproj" # Copy the rest of the application code COPY ["dotnet/Contoso.BlazorApp/", "Contoso.BlazorApp/"] # Build the application WORKDIR "/src/Contoso.BlazorApp" RUN dotnet build "Contoso.BlazorApp.csproj" -c Release -o /app/build # Stage 2: Publish the application FROM build AS publish RUN dotnet publish "Contoso.BlazorApp.csproj" -c Release -o /app/publish /p:UseAppHost=false # Stage 3: Final stage with the runtime image FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final WORKDIR /app EXPOSE 8080 # Set the environment variables ENV ASPNETCORE_URLS=http://+:8080 ENV DOTNET_RUNNING_IN_CONTAINER=true ENV ApiSettings__BaseUrl="${ApiSettings__BaseUrl}" # Copy the published files from the build stage COPY --from=publish /app/publish . # Set the entry point for the container ENTRYPOINT ["dotnet", "Contoso.BlazorApp.dll"]